Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

Table of Contents

Logging from C

RIC provides a C library for logging: mdclog.

...

Example of how to use the mdclog C library from Go:


package main
 
/*
#cgo CFLAGS: -I/usr/local/include
#cgo LDFLAGS: -lmdclog
#
#include <mdclog/mdclog.h>
void my_log_write(mdclog_severity_t severity, const char *msg) {
     mdclog_write(severity, "%s", msg);
}
*/
import "C"
import "fmt"
 
func mylog(severity C.mdclog_severity_t, msg string) {
        C.my_log_write(severity, C.CString(msg))
}
 
func main() {
 
        C.mdclog_mdc_add(C.CString("Weather"), C.CString("Sunny"))
        C.mdclog_mdc_add(C.CString("Temperature"), C.CString("15.5"))
        mylog(C.MDCLOG_INFO, fmt.Sprintf("Weather report log"))
}

Logging from Python

RIC provides a Python library for logging: mdclogpy.

...

You can also install the python library using pip

python3 -m pip install mdclogpy


MDC (Mapped Diagnostic Context)

...

MDC keyMDC value (type, range, list of values, format, ...)DescriptionComponents using the MDCComments
Weather

Possible values: sunny, cloudy, rainy, snowy

Weather type included in every log made by the Weather Manager.Weather Manager xAppThis is an example.
TemperatureValue range from -100.0 to 100.0 with one decimal. Example: 15.5Temperature (Celsius degrees) included in every log made by the Weather Manager.Weather Manager xAppThis is an example.
timeyyyy-MM-dd HH:mm:ss.SSSHuman readable timestamp. Note that the timezone can be derived from comparing this value against the ts millisecond timestamp in the same log entry.E2 Manager

Example:

{"crit":"INFO","ts":1560266556006,"id":"E2Manager","msg":"#rmrCgoApi.Init - RMR router has been initiated","mdc":{"time":"2019-06-11 15:22:36.006"}}






...

1550045469,
INFO,
applicationABC,
This is an example log,
key1=value1 key2=value with a space

Key-value pairs (proposal for future development)

With a colon as a separator in this example. The separator could be made configurable.

...