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.
Release files for myoperator 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| myoperator-0.1.0.tar.gz | 17.1 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| myoperator-0.1.0-py3.7.egg | Legacy Egg format | - | - | Details |
| myoperator-0.1.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 25.1 kB
Release files / myoperator-0.1.0.tar.gz
| Download URL | myoperator-0.1.0.tar.gz |
|---|---|
| Size | 17.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7321510cb426610771624fa243cb21e19cf2d777398da1e161044c11cff506d4
|
|
BLAKE2b-256 checksum How to use checksums |
38cedf7bd004cbe39eed2dfef4383749f75ba3900d8867cf16fb3c9988485a00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/42.0.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.4
|
Release files / myoperator-0.1.0-py3.7.egg
| Download URL | myoperator-0.1.0-py3.7.egg |
|---|---|
| Size | 2.8 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
713fc59a8c9fe4303e979cd8920be9f94a9fa9488fd5068dbaab269c05493cf0
|
|
BLAKE2b-256 checksum How to use checksums |
65ffec09876bc6e89a759f96309cfa701a310ec23af29d639587d602731eebee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/42.0.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.4
|
Release files / myoperator-0.1.0-py2.py3-none-any.whl
| Download URL | myoperator-0.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
77a6527f28ab8b001ea0e5de330efbefb9da4ad41418eedb4707b7d23ba3ad9f
|
|
BLAKE2b-256 checksum How to use checksums |
9b87da8681b81051d25c601cfcd230a6d47d58b44e052342baf86084b8a3e5f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/42.0.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.4
|