diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..0cf124b --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,18 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: 当前文件", + "type": "python", + "request": "launch", + "program": "${file}", + "console": "integratedTerminal", + "env": { + "PYTHONPATH": "F:/coding2/nb_log;${env:PYTHONPATH}" + } + } + ] +} \ No newline at end of file diff --git a/nb_log/set_nb_log_config.py b/nb_log/set_nb_log_config.py index 14529cf..59d53b8 100644 --- a/nb_log/set_nb_log_config.py +++ b/nb_log/set_nb_log_config.py @@ -14,6 +14,7 @@ from shutil import copyfile + # noinspection PyProtectedMember,PyUnusedLocal,PyIncorrectDocstring,PyPep8 def nb_print(*args, sep=' ', end='\n', file=None): """ @@ -39,6 +40,8 @@ def nb_print(*args, sep=' ', end='\n', file=None): # sys.stdout.write(f'\033[0;30;44m"{file_name}:{line}" {time.strftime("%H:%M:%S")} {"".join(args)}\033[0m\n') +nb_print(f'当前项目的根目录是:\n {sys.path[1]}') # 如果获取的项目根目录不正确,请不要在python代码硬编码操作sys.path。pycahrm自动给项目根目录加了PYTHONPATh,如果是shell命令行运行python命令前脚本前先在会话中设置临时环境变量 export PYTHONPATH=项目根目录 + def show_nb_log_config(): nb_print('显示nb_log 包的默认的低优先级的配置参数') for var_name in dir(nb_log_config_default): diff --git a/tests/d1/d2/d3/t6 b/tests/d1/d2/d3/t6 new file mode 100644 index 0000000..8007a00 --- /dev/null +++ b/tests/d1/d2/d3/t6 @@ -0,0 +1,21 @@ + +print('导入nb_log之前的print是普通的') + +import sys +print(sys.path) + +from nb_log import get_logger + +logger = get_logger('lalala',log_filename='jinzhifengzhuang.log',formatter_template=5) + +logger.debug(f'debug是绿色,说明是调试的,代码ok ') +logger.info('info是天蓝色,日志正常 ') +logger.warning('黄色yello,有警告了 ') +logger.error('粉红色说明代码有错误 ') +logger.critical('血红色,说明发生了严重错误 ') + +print('导入nb_log之后的print是强化版的可点击跳转的') + + + +#raise Exception("dsadsd") \ No newline at end of file diff --git a/tests/example.py b/tests/example.py index 1c4303d..23ac4e8 100644 --- a/tests/example.py +++ b/tests/example.py @@ -1,9 +1,12 @@ print('导入nb_log之前的print是普通的') +import sys +print(sys.path) + from nb_log import get_logger -logger = get_logger('lalala',log_filename='jinzhifengzhuang.log',formatter_template=11) +logger = get_logger('lalala',log_filename='jinzhifengzhuang.log',formatter_template=5) logger.debug(f'debug是绿色,说明是调试的,代码ok ') logger.info('info是天蓝色,日志正常 ') @@ -15,3 +18,4 @@ +# raise(1) \ No newline at end of file