-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
建议移除logging.basicConfig #163
Comments
@Aiee could you kindly review this suggestion? thanks :) |
Hello @zifeiYv, thanks for your feedback. Would you say a module-specific logger may solve this problem as proposed in #150 (comment)? |
If there is no handlers in root logger, call For example, if you code like this: from nebula2.gclient.net import ConnectionPool
import logging
logging.basicConfig(level=logging.DEBUG, format='[%(asctime)s] %(levelname)-8s [%(filename)s:%(lineno)d]:%(message)s')
logger = logging.getLogger(__name__)
logger.debug('debug msg') will not print 'debug msg' in console because the logger level was already set to be To avoid this, there are two choices: # option 1, call basicConfig earlier than import nebula2
import logging
logging.basicConfig(level=logging.DEBUG, format='[%(asctime)s] %(levelname)-8s [%(filename)s:%(lineno)d]:%(message)s')
from nebula2.gclient.net import ConnectionPool
logger = logging.getLogger(__name__)
logger.debug('debug msg') or # option 2, remove all handlers in root logger and reset basicConfig
from nebula2.gclient.net import ConnectionPool
import logging
for handler in logging.root.handlers:
logging.root.removeHandler(handler)
logging.basicConfig(level=logging.DEBUG, format='[%(asctime)s] %(levelname)-8s [%(filename)s:%(lineno)d]:%(message)s')
logger = logging.getLogger(__name__)
logger.debug('debug msg') It's troublesome, right? I don't know clearly if there is great demand for you developers to use |
项目在这里调用了
logging.basicConfig
,我认为这种方式是不友好的,会使用户试图定义自己的logger对象时无法直接生效。建议移除。
The text was updated successfully, but these errors were encountered: