Use go modules and include CI support
[com/golog.git] / README.md
1 Logging library with MDC support
2 ================================
3
4 A Golang implementation of a structured logging library with Mapped Diagnostics Context (MDC) support.
5
6 Overview
7 --------
8
9 ### Initialization
10
11 A new logger instance is created with InitLogger function. Process identity is given as a parameter.
12
13 ### Mapped Diagnostics Context 
14
15 The MDCs are key-value pairs, which are included to all log entries by the library.
16 The MDC pairs are logger instance specific.
17
18 ### Log entry format 
19
20 Each log entry written the library contains
21
22  * Timestamp
23  * Logger identity
24  * Log entry severity
25  * MDC pairs of the logger instance
26  * Log message text
27
28 Currently the library only supports JSON formatted output written to standard out of the process
29
30 *Example log output*
31
32 `{"ts":1551183682974,"crit":"INFO","id":"myprog","mdc":{"second key":"other value","mykey":"keyval"},"msg":"hello world!"}`
33
34 Example
35 -------
36
37 ```go
38 package main
39
40 import (
41         mdcloggo "gerrit.o-ran-sc.org/r/com/golog"
42 )
43
44 func main() {
45         logger, _ := mdcloggo.InitLogger("myname")
46         logger.MdcAdd("mykey", "keyval")
47     logger.Info("Some test logs")
48 }
49 ```
50
51 License
52 -------
53  Copyright (c) 2019 AT&T Intellectual Property.
54  Copyright (c) 2018-2019 Nokia.
55
56  Licensed under the Apache License, Version 2.0 (the "License");
57  you may not use this file except in compliance with the License.
58  You may obtain a copy of the License at
59
60      http://www.apache.org/licenses/LICENSE-2.0
61
62  Unless required by applicable law or agreed to in writing, software
63  distributed under the License is distributed on an "AS IS" BASIS,
64  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
65  See the License for the specific language governing permissions and
66  limitations under the License.
67
68 CI
69 --
70
71 The Dockerfile in the `ci` directory _only_ runs, when build, the unit tests for the repository.
72