setup logger bb
Project description
BB LOGGER
Description
-
Remove all logger handlers and reformat log record ( can be extended )
-
Provide some other logging method than default (info, error..)
How
call setup_logging() one time at begin of program
1. Remove all logger handlers and reformat log record
sample code
import logging
from bb_logger import setup_logging
logging.error('before setup, using old handler format')
# setup log with default
setup_logging()
logging.error('after setup, using new default format')
# setup logger with extend format
setup_logging(extend_format="%(asctime)s - %(message)s")
logging.error('after setup with custom format, using extended format')
output
ERROR:root:before setup, using old handler format
[ERROR] after setup, using new default format
[ERROR] 2021-01-10 18:18:46,202 - after setup with custom format, using extended format
logging format details can be here
(*) extend_format logic
- BASE_FORMAT = '[%(levelname)s]'
- DEFAULT_FORMAT = BASE_FORMAT + ' %(message)s'
- if extend_format is specified, FORMAT will be : BASE_FORMAT + '\t'+ extend_format
- else DEFAULT_FORMAT wil be used
2. Provide some other logging method than default(info, error..)
NOW SUPPORTED CUSTOM LEVEL (will be filtered and notify to slack, telegram, etc):
- NOTI
EXAMPLE
must be used with logger, default logging will raise Error
import logging
from bb_logger import setup_logging
setup_logging()
logger = logging.getLogger()
logger.noti('noti level')
output
[NOTI] noti level
NOTE
CloudWatch now accept following pattern:
- [ERROR]
- [CRITICAL]
- [NOTI]
Example:
-
"[ERROR] error log" will be matched
-
"some thing before [ERROR] error log" will be matched
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
bb_logger-0.1.2.tar.gz
(2.9 kB
view hashes)
Built Distributions
Close
Hashes for bb_logger-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e43e2e76c8672db9f64cea3b68e4b5991bb245b354daa0a9cedcda6b588194fa |
|
MD5 | f997ece217cb619338a1401211fad322 |
|
BLAKE2b-256 | 5369b28902084afeb53f842c75b73050bea4a0c5eaed2ace8471a1f4f1846026 |
Close
Hashes for bb_logger-0.1.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 333546455954440d6cb0c3bcb67d4433e20b4e41eaa8df5b7eb8ccc47940f2dd |
|
MD5 | 539b7a1eb3ed334c496a30d681d01846 |
|
BLAKE2b-256 | 5104e899c8c5519022c45975892c39573f5cd63b71c194a2b2a580b33abf5936 |