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 therootlogger to record message,log.info(msg)can usecurrent module's logger. Here,current modulemeans 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
loggingsystem. - Load yaml to dict, then use the
logging.config.dictConfig(config_dict)to configure the logging system. - When you invoke
log.info(msg),handy-logwill first findcurrent module's logger, and then use thisloggerto log the message.
Configuration/How to use
- Option 1:
Do nothing, use the default configuration. Justimport logand use it. - Option 2:
- Create your own
handy-log.yamlin yourcurrent work directory. - Then just
import logand 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.yamlfirst, then apply the merged configuration to the builtin logging system. -
Then
import logand 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 theselevelto 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file handy-log-2022.5.5a2.tar.gz.
File metadata
- Download URL: handy-log-2022.5.5a2.tar.gz
- Upload date:
- Size: 20.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0b95dd46cced188716d58534ea78a90431a75928ab049a2cdf847afe29bc7de
|
|
| MD5 |
d7fbad218682d3a9581c3320ffa95604
|
|
| BLAKE2b-256 |
30ddf0172539b7c430094a9ef6b4454b62a501bea42b3f0d322d9d249fc287da
|
File details
Details for the file handy_log-2022.5.5a2-py3-none-any.whl.
File metadata
- Download URL: handy_log-2022.5.5a2-py3-none-any.whl
- Upload date:
- Size: 22.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83cbb3485a1a17adf6eae6921a419b791d721ad557201662561b46b8a2be7c9b
|
|
| MD5 |
9cb4558362c748e7ce63a153d3492ca0
|
|
| BLAKE2b-256 |
c2becc8e836f5d8ce078dbf3409c14dc8a8c2f34e0e34728c138f4a43b29023a
|