Make the log system easier to use
Project description
Aim
Make the log system easier to use, by simply:
import log
log.info("Hello handy-log!")
Features
- While the builtin
logging.info(msg)
uses theroot
logger to record message,log.info(msg)
can use current module's logger. - A bunch of predefined formats, handlers, loggers.
- Easy to config, and easy to invoke.
Mechanism
- This is a wrapper for python builtin
logging
system. - Load yaml to dict, then use the
logging.config.dictConfig(config_dict)
to configure the logging system. - When you invoke
log.info(msg)
,handy-log
will first findcurrent module
's logger, and then use thislogger
to log the message. Herecurrent module
means the module inside which you invoke thelog.info(msg)
.
Configuration/How to use
- Option 1:
Do nothing, use the default configuration. Justimport log
and use it. - Option 2:
- Create your own
handy-log.yaml
in yourcurrent work directory
. - Then just
import log
and use it.
- Create your own
- Option 3:
-
Create your own yaml configuration file.
-
Invoke
log.init(your_config_file)
to configure the logger.This will merge
your_config_file
's content with the builtinhandy-log.yaml
first, then apply the merged configuration to the builtin logging system. -
Then
import log
and use it.
-
Notes:
- Since the root logger can only be initialized once,
you should invoke
log.init()
before any other logger configuration takes effect. - In the configuration file, loggers and handlers have their independent
logging level
, The message needs to pass through all theselevel
to be recorded.
References
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
handy-log-2022.5.5a1.tar.gz
(20.5 kB
view hashes)
Built Distribution
Close
Hashes for handy_log-2022.5.5a1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00ef06563d01bb67f91cc3219050415d6daf2de5c030cfc424924235fd871b74 |
|
MD5 | 50c5a98cc6d7adc6c301be52a5b42df5 |
|
BLAKE2b-256 | bc091c4cdc6ebed772bc5daf84f153eade5ffed3034a9c00f54fea4419932566 |