4 Structured logging library with Mapped Diagnostic Context
6 * Outputs the log entries to standard out in structured format, json currently.
7 * Severity based filtering.
8 * Supports Mapped Diagnostic Context (MDC).
9 Set MDC pairs are automatically added to log entries by the library.
15 Each log entry written with mdclog_write() function contains
20 * All existing MDC pairs
23 Currently the library only supports JSON formatted output written to standard
28 `{"ts": 1559285893047, "crit": "INFO", "id": "myprog", "mdc": {"second key":"other value","mykey":"keyval"}, "msg": "Hello world!"}`
36 python3 -m pip install mdclogpy
39 Install using the source
42 python3 setup.py install
48 The library can be used in two ways shown below.
50 1) Use the root logger
54 mdclogpy.error("This is an error log")
57 2) Create a logger instance
60 from mdclogpy import Logger
62 my_logger.error("This is an error log")
65 A program can create several logger instances.
68 Mapped Diagnostics Context
69 --------------------------
71 The MDCs are logger instance specific key-value pairs, which are included to
72 all log entries written via the logger instance.
74 By default, the library implements a root logger instance.
75 MDCs added to the root logger instance are added only to the log entries
76 written via the root logger instance.
82 Copyright (c) 2019 AT&T Intellectual Property.
83 Copyright (c) 2018-2019 Nokia.
85 Licensed under the Apache License, Version 2.0 (the "License");
86 you may not use this file except in compliance with the License.
87 You may obtain a copy of the License at
89 http://www.apache.org/licenses/LICENSE-2.0
91 Unless required by applicable law or agreed to in writing, software
92 distributed under the License is distributed on an "AS IS" BASIS,
93 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
94 See the License for the specific language governing permissions and
95 limitations under the License.
101 To run the unit tests run the following command in the package directory::
103 python3 -m unittest discover