Write failed files (errors) to an errors.log and summarize to console#126
Write failed files (errors) to an errors.log and summarize to console#126yma955 merged 4 commits intoCommonjava:mainfrom
Conversation
Pull Request Test Coverage Report for Build 1767741200
💛 - Coveralls |
ligangty
left a comment
There was a problem hiding this comment.
Generally looks good to me except two changes. And as this is not urgent, we can hold it later for John's review to see if this is what he want.
charon/config.py
Outdated
| CONFIG_FILE = "charon.yaml" | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
| add_file_handler(logger) |
There was a problem hiding this comment.
Maybe we should extract these two lines together in logs.py as a new method like get_charon_logger(name: str)? So if we want to change something in future, we don't need to change it everywhere.
charon/utils/logs.py
Outdated
|
|
||
|
|
||
| def add_file_handler(logger: logging): | ||
| handler = logging.FileHandler('errors.log') |
There was a problem hiding this comment.
Can we make this "errors.log" configurable for different location? I think we can configure this in CharonConfig, and give it a default location like this "./errors.log".
There was a problem hiding this comment.
@ligangty If we introduce the CharonConfig in logs.py, it will cause the error of partially initialized, it's likely a circular import issue, otherwise, we could use another config(or log properties) rather than CharonConfig instead.
There was a problem hiding this comment.
Or maybe we can let the config.py not use this getLogger method, as the error in CharonConfig is not our target to record in the errors.log.
|
@yma88 Seems this pr needs to do rebase on new code base. Can you help do it? |
| formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s') | ||
| handler.setFormatter(formatter) | ||
| handler.setLevel(logging.ERROR) | ||
| handler.setLevel(logging.WARN) |
There was a problem hiding this comment.
@ligangty Removed the duplicated unuseful level setting.
c3778b0 to
94742db
Compare
|
@yma88 I just double checked the code. Seems we still need some changes. |
|
@ligangty here are the updates:
|
There was a problem hiding this comment.
Little curious. Can we just do all handler stuff once in command level? As the set_logging also did handler related stuff, we can add a new optional param like set_logging(name="charon", level=logging.DEBUG, handler=None, error_log_file=None), and then pass the error log file in during the command init. In this way we don't need any changes in other files(or just little change), and don't need that ProductVersion class. Are there any runtime problems to block all changes in this single method?
@ligangty I'm afraid we can't pass the error_log stuff through set_logging, it's triggered during init but we need to have the product&version when the command executes. For the ProductVersion, it's using the thread-safe static, it's necessary, and I've thought about it should be the harmless and safe way to do so, if we wanna have this info widely used within a single process. |
|
@yma88 For the init triggering, do yo mean set_logging() called in init.py? If so, maybe we can consider to move it out to command.py too. |
No description provided.