2 .. Copyright (c) 2019 AT&T Intellectual Property.
4 .. Copyright (c) 2019 Nokia.
7 .. Licensed under the Creative Commons Attribution 4.0 International
9 .. Public License (the "License"); you may not use this file except
11 .. in compliance with the License. You may obtain a copy of the License at
14 .. https://creativecommons.org/licenses/by/4.0/
17 .. Unless required by applicable law or agreed to in writing, documentation
19 .. distributed under the License is distributed on an "AS IS" BASIS,
21 .. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 .. See the License for the specific language governing permissions and
25 .. limitations under the License.
27 .. This source code is part of the near-RT RIC (RAN Intelligent Controller)
29 .. platform project (RICP).
36 Clone the pylog git repository
37 ------------------------------
40 git clone "https://gerrit.o-ran-sc.org/r/com/pylog"
43 Mapped Diagnostics Context
44 --------------------------
46 The MDCs are logger instance specific key-value pairs, which are included to
47 all log entries written via the logger instance.
49 By default, the library implements a root logger instance.
50 MDCs added to the root logger instance are added only to the log entries
51 written via the root logger instance.
56 Each log entry written with mdclog_write() function contains
61 * All existing MDC pairs
64 Currently the library only supports JSON formatted output written to standard
69 `{"ts": 1559285893047, "crit": "INFO", "id": "myprog", "mdc": {"second key":"other value","mykey":"keyval"}, "msg": "Hello world!"}`
77 python3 -m pip install mdclogpy
79 Install using the source
83 python3 setup.py install
88 The library can be used in two ways shown below.
90 1) Use the root logger
96 mdclogpy.error("This is an error log")
99 2) Create a logger instance
104 from mdclogpy import Logger
106 my_logger.error("This is an error log")
109 A program can create several logger instances.
115 """Severity levels of the log messages."""
124 1. Set current logging level
128 def set_level(self, level: Level):
131 level -- logging level. Log messages with lower severity will be filtered.
133 2. Return the current logging level
137 def get_level(self) -> Level:
139 3. Add a logger specific MDC
143 def add_mdc(self, key: str, value: Value):
149 4. Return logger's MDC value with the given key or None
153 def get_mdc(self, key: str) -> Value:
155 5. Remove logger's MDC with the given key
159 def remove_mdc(self, key: str):
161 6. Remove all MDCs of the logger instance.
171 Copyright (c) 2019 AT&T Intellectual Property.
172 Copyright (c) 2018-2019 Nokia.
174 Licensed under the Apache License, Version 2.0 (the "License");
175 you may not use this file except in compliance with the License.
176 You may obtain a copy of the License at
178 http://www.apache.org/licenses/LICENSE-2.0
180 Unless required by applicable law or agreed to in writing, software
181 distributed under the License is distributed on an "AS IS" BASIS,
182 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
183 See the License for the specific language governing permissions and
184 limitations under the License.
186 This source code is part of the near-RT RIC (RAN Intelligent Controller)
187 platform project (RICP).
192 To run the unit tests run the following command in the package directory
196 python3 -m unittest discover