Small Logging Library
Project description
Installation
Install timelogging in your shell with the Python Package Installer:
pip3 install timelogging
Usage
Logging functionalities
Time Log
The log function is designed to be a drop-in replacement for print:
from timelogging.timeLog import log
log('This is a log entry.')
And this outputs the current time before the printout:
16:20:00 INFO This is a log entry.
Day Log
You can also add the current day within the timestamp:
from timelogging.dayLog import log
log('This is a log entry.')
And this outputs the current time with the day before the printout:
31 16:20:00 INFO This is a log entry.
Cutom Log
Additionally, you can also create a custom timestamp formatting of the log function according to the Python time formatting directives and a custom start log level according to the Python logging level values:
from timelogging import configLog, log
configLog(timeFmt='%Y-%m-%d %H:%M:%S', startLevel=20)
log('This is a log entry.')
And this outputs your custom timestamp before the printout:
2020-12-31 16:20:00 INFO This is a log entry.
Changing the log level
Setting the log level globally
The functions above set the log level immediately to logging.INFO. When this is not wanted, you can also import timeLogLater, dayLogLater to keep the log level at logging.WARN at start or set the startLevel parameter of the configLog function as you want.
Then you can import the functions startLogging and endLogging to change the log level on the fly.
from timelogging.timeLogLater import log, startLogging, endLogging
log('not seeable')
startLogging()
log('seeable')
endLogging()
log('not seeable')
This example logs this output only:
16:20:00 INFO seeable
Changing the log level to INFO for one log entry
This is possible with the function logOnce. It changes the log level to INFO just for this log entry and after that it switches back to WARN (the default level). Simply use it as you would use log.
from timelogging.timeLogLater import log, logOnce
log('not seeable')
logOnce('seeable')
log('not seeable')
This example logs the output of logOnce only, because otherwise the log level is set to WARN. This helps avoiding unwanted INFO logs:
16:20:00 INFO seeable
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 timelogging-2.3.0.tar.gz.
File metadata
- Download URL: timelogging-2.3.0.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.8.0 tqdm/4.47.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb0cce6e98f628d30f0e914e94e18404e4a6bb3d385b09ad97bd9cfcf5916d69
|
|
| MD5 |
fc8ec795e1a727c94e6ad539600d6ea7
|
|
| BLAKE2b-256 |
71ff44e1a97a5cfd7d6a8519f9527dfdefbd71a62181df8ab03cf1295a19683d
|
File details
Details for the file timelogging-2.3.0-py3-none-any.whl.
File metadata
- Download URL: timelogging-2.3.0-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.8.0 tqdm/4.47.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
892c0dca6a1626d967facc7e1019b39ddb6fdb2412d06c4b00ec5d6af4f6eaf6
|
|
| MD5 |
750c79fb29bfd711062e288568e7f79c
|
|
| BLAKE2b-256 |
75f9d7c2c7bb1d4ab0e881316e54bbd322bd9a088e68cd26f50e020a28f832a1
|