Logging library - sonata-nfv/tng-tests GitHub Wiki
5GTANGO logging library
The logging libraries were developed with the intention of standardizing the output of the component in a common format, understandable to our internal logging system (graylogs). The logging output is received from all development and test environments. The JSON format generated by the logging libs is very useful to create custom searchs and found bugs.
Java
In 5GTANGO Logging Java version, we are using Apache Log4j API 2.11.2 API library. It provides simple logging implementation, for the standardized Json Logs in 5GTANGO's components. It's usage is very simple, while you just need to import this library in your java project and start using it as follows:
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Logger logger = LogManager.getLogger();
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
String timestamps = timestamp.toString();
String type = "Example Type";
String operation = "Example Operation";
String message = "Example Message";
String status = "Example Status";
logger.debug("{\"type\":\"{}\",\"timestamp\":\"{}\",\"start_stop\":\"\",\"component\":\"tng-sla-mgmt\",\"operation\":\"{}\",\"message\":\"{}\",\"status\":\"{}\",\"time_elapsed\":\"\"}",type, timestamps, operation, message, status);
Python
In 5GTANGO Logging python version, we are using an internal logging library, you just need to add this lib to your python project, and import them in your files.
from xxxx.logger import TangoLogger as TangoLogger
Initialize the logging:
LOG = TangoLogger.getLogger(__name__, log_level=logging.DEBUG, log_json=True)
TangoLogger.getLogger("your_module:main", logging.DEBUG, log_json=True)
LOG.setLevel(logging.DEBUG)
Use the logging system:
LOG.info("Hello world.")
Ruby
In 5GTANGO Logging ruby version, we are using an internal logging library. The gem is available in rubygems.org, you just need to include it in your Gemfile
:
...
gem 'tng-gtk-utils', '0.4.1'
...
Note: the version might need to be updated.
The, in the file you want to use the logger, just require it:
...
require 'tng/gtk/utils/logger'
...
And use it, like in
...
Tng::Gtk::Utils::Logger.debug(component:'component name', operation:'method name', message:'whatever message')
...
Checklist
SP components
Component | Ready? | Comment |
---|---|---|
tng-sla-mgmt | yes | |
tng-slice-mngr | ||
tng-sec-gtw | no | Felipe: it is an nginx, I have to check; José: not only, you've got the router, written in ruby and with logs |
tng-gtk-usr | yes | |
tng-gtk-sp | yes | |
tng-gtk-common | yes | |
tng-api-gtw | yes | |
tng-sdk-package | yes | |
tng-rep | yes | |
tng-sp-ia-wtapi | yes | |
wim-wrapper-mock | yes | |
wim-wrapper-vtn | yes | |
tng-sp-ia-k8s | yes | |
vim-wrapper-ovs | yes | |
vim-wrapper-mock | yes | |
vim-wrapper-heat | yes | |
ia-nbi | yes | |
son-monitor-spprobe | no | Panos K: These implementations are running outside of SP and they support file logging |
son-monitor-grafana | NA | |
son-monitor-snmpmng | yes | |
son-monitor-manager | yes | |
son-monitor-alertmanager | yes | |
son-monitor-prometheus | yes | |
son-monitor-pushgateway | NA | |
placementplugin | yes | |
placementexecutive | yes | |
specificmanagerregistry | yes | |
functionlifecyclemanagement | yes | |
servicelifecyclemanagement | yes | |
pluginmanager | yes | |
tng-cat | ||
tng-portal | NA | |
tng-policy-mngr |
VnV Components
Component | Ready? | Comment |
---|---|---|
tng-sdk-package | yes | |
tng-api-gtw | yes | |
tng-sec-gtw | no | Felipe: it is an nginx, I have to check |
tng-gtk-usr | yes | |
tng-gtk-vnv | yes | |
tng-gtk-common | yes | |
tng-rep | yes | |
tng-vnv-platform-adapter | yes | |
tng-sdk-analyze-weight | ||
tng-vnv-executor | ||
tng-vnv-planner | ||
tng-vnv-curator | yes | |
tng-vnv-dsm | yes | |
tng-portal | NA | |
tng-cat | ||
son-vnv-monitor-manager | yes | |
son-monitor-grafana | NA | |
son-monitor-prometheus | yes | |
son-monitor-pushgateway | NA |