splogging
Ever had that feeling like quickly wanting to activate logging for your script, but were slightly overwhelmed by the plethora of settings and commands, so you are now running with no logging at all?
Enter splogging!
Just run pip install, do a from ... import ... and finally initialise your logger with my_logger=logger.setup_logging().
That's all it takes to get your logging up and running.
Of course, you can customise your new logger with the parameters shown below.
Happy logging!
Install splogging
$ pip install splogging
Use splogging
Create one logger
Use this "one logger" setup, if you want same config for output to screen (terminal) and log file.
from splogging import logger
if __name__ == "__main__":
logger = logger.setup_logging(
filename="my.log", when="W0", file_level="info", console_level="info",
)
logger.info("Log message to console and in file.")
Create multiple loggers
Use this "multiple logger" setup, if you want to configure (and use) multiple loggers separately.
Specify a unique name for each logger.
from splogging import logger
if __name__ == "__main__":
logger_file = logger.setup_logging(
name="A",
filename="steven.log",
when="W0",
file_level="info",
console_level=None,
)
logger_console = logger.setup_logging(
name="B",
filename="steven.log",
when="W0",
file_level=None,
console_level="info",
)
logger_file.warning("In File!")
logger_console.warning("In console!!!")
Parameters
- name
Can be left empty.
Useful only when creating multiple, separate loggers. - filename
Path and name of logfile. - when
Defines when to rotate the log file.
Check TimedRotatingFileHandler for more info. - backup_count
Number of backups to keep (set to 0 to keep all rotated logs). - file_level
Save log messages that have this or a higher level.
Set to None to disable logging to file. - file_format
Format of message saved to file.
Check docs.python.org for more info. - file_log_datefmt
Format of timestamp in the log message, saved to file.
See strftime for details. - console_level
Display log messages that have this or a higher level.
Set to None to disable logging to console. - console_format
Format of message, displayed in the console.
Check Formatter Objects for more info. - console_log_datefmt
Format of timestamp in the message, displayed in the console.
References
Release files for splogging 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| splogging-0.0.5.tar.gz | 3.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| splogging-0.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.7 kB
Release files / splogging-0.0.5.tar.gz
| Download URL | splogging-0.0.5.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
04be5eafe4d6f82224c9df599e9d13328dfb7cb9c2bc2338bc7e93e8cdab12f7
|
|
BLAKE2b-256 checksum How to use checksums |
a481277974f2c2a555f5e49e457948c085cd4a457c288cfffba9c4e753d9de16
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.6
|
Release files / splogging-0.0.5-py3-none-any.whl
| Download URL | splogging-0.0.5-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f8658cac638a32f8dd009ce09a0f5d160bf8d06a9aaf04fb7ccfbc9bddd6bab2
|
|
BLAKE2b-256 checksum How to use checksums |
8700e9dad8077e7ab17086a639e4493151af16f83cd46805e29e8f67e9cc5772
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.6
|