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)

...

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.

...