CentralLog helps recording the logs by MyOperator standards
Project description
centrallog
CentralLog helps recording the logs by MyOperator standards.
The format of the log message is
{ "time":<unix-epoch>, "mc_time":<unix-epoch in microseconds>, "ip":"<host-ip-address>", "service": <application/service name>, "class":"<source class name logging this>", "data":{ "uid":"<unique log identifier>", "msg":"<actual message>", "acl":<acl numeric representation> }, "title": <logging context provider> }
For description please refer to Documentation.
Features
Auto-format log message to desired form by simply configuring the logger.
Installation
To install the centrallog package run the following commands:
$ git clone https://github.com/myoperator/centrallog-py.git $ pip install -e centrallog-py
Quickstart
For the impatient:
from myoperator.centrallog import centrallog
FORMAT = '%(name)s: (%(asctime)s) [%(levelname)s] - %(message)s'
centrallog.basicConfig(format=FORMAT)
logger = centrallog.getLogger('testlogger')
logger.error("Log message")
Configurations
The basic configuration of logger is same as the python’s builtin logging library.
For customizing message-format use the following class methods.
basicConfig(**kwargs)
This method is same as the logging’s basicConfig(**kwargs).
configure(servicename, hostname=’’, uid=’’)
This method is used to configure the servicename, the hostname, the uuid of the logger throughout the program.
TIP: Use this method once throughout the program before logging any message.
is_configured()
Check if a logger is configured and return true if it is configured, else false.
get_configuration()
Returns the configuration tuple(servicename, hostname, uid).
Logging Methods
centrallog supports all the log methods of the logging library with an additional optional keyword-argument acl which shows the relevancy of the log.
The value of acl(Access Control List) can only be one of the following:
1 - developer (default) 2 - support 4 - customer
Example: To log an error message relevant to the customer(acl = 4).
logger.error('message', acl=4)
centrallog also provide some additional methods with default acl behaviour.
dlog(level, message, *args, **kwargs)
developer specific log(acl=1).
slog(level, message, *args, **kwargs)
support specific log(acl=2).
clog(level, message, *args, **kwargs)
customer specific log(acl=4).
Loggin with title
To add a title to the log message centrallog provide one of the two ways.
Using title keyword argument in every log message.
And using title(text) method.
Example:
logger.title('title here').dlog('message here') logger.warning('message...', title='Title here')Tip: On using both method and keyword, keyword will get higher precedence.
For further technical documentation please visit here.
History
0.1.0 (2020-01-04)
First release on PyPI.
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
File details
Details for the file myoperator_py-1.0.1.tar.gz
.
File metadata
- Download URL: myoperator_py-1.0.1.tar.gz
- Upload date:
- Size: 18.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a65fda56aa99639398c7c436e5189ce195c0721fd3ce9f19171e395823e12a6 |
|
MD5 | 49c55519a1f4923d6988f25aa3915f15 |
|
BLAKE2b-256 | 06a1776580b67e471e7504ff5f327c226f2fe1ee2cd5f782b0b09eff5a7a5c3a |
File details
Details for the file myoperator_py-1.0.1-py2.py3-none-any.whl
.
File metadata
- Download URL: myoperator_py-1.0.1-py2.py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73b684c2692dec48932f0fba681767630d175582abeee9de7b6b3d6f39ca1202 |
|
MD5 | c2b3a2847155fc58950b417a6168ca75 |
|
BLAKE2b-256 | 0f57961596b2ba3fc5d88a8f8a0e1cd07388a19f5a2293309f247baf8a0b9389 |