Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
yangdefeng committed Nov 18, 2021
1 parent 7b06479 commit 5fc3829
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
18 changes: 18 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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}"
}
}
]
}
3 changes: 3 additions & 0 deletions nb_log/set_nb_log_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from shutil import copyfile



# noinspection PyProtectedMember,PyUnusedLocal,PyIncorrectDocstring,PyPep8
def nb_print(*args, sep=' ', end='\n', file=None):
"""
Expand All @@ -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):
Expand Down
21 changes: 21 additions & 0 deletions tests/d1/d2/d3/t6
Original file line number Diff line number Diff line change
@@ -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")
6 changes: 5 additions & 1 deletion tests/example.py
Original file line number Diff line number Diff line change
@@ -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是天蓝色,日志正常 ')
Expand All @@ -15,3 +18,4 @@



# raise(1)

0 comments on commit 5fc3829

Please sign in to comment.