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 usecurrent module
's logger. Here,current module
means the module inside which you invoked thelog.info(msg)
. You don't have to code like this any more:import logging logger = logging.getLogger(you_package_name) logger.info(your_msg)
- 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.
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.
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.5a2.tar.gz
(20.3 kB
view hashes)
Built Distribution
Close
Hashes for handy_log-2022.5.5a2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83cbb3485a1a17adf6eae6921a419b791d721ad557201662561b46b8a2be7c9b |
|
MD5 | 9cb4558362c748e7ce63a153d3492ca0 |
|
BLAKE2b-256 | c2becc8e836f5d8ce078dbf3409c14dc8a8c2f34e0e34728c138f4a43b29023a |