docs/api/log.md
logLogging is a basic requirement for building services. napajs logging API enables developers to integrate their own logging capabilities in both JavaScript and C++ (addon) world.
A log row may contain the following information:
Include header: <napa.h>
Macros:
#include <napa.h>
void MyFunction() {
// ...
LOG_ERROR("init", "error: %s", errorMessage.c_str());
}
It logs a message. Using info level.
log is a shortcut for log.info.*Example:
var napa = require('napajs');
napa.log('program started');
It logs a message with a section. Using info level.
Example:
napa.log('init', 'program started');
It logs a message with a section, associating it with a traceId. Using info level.
Example:
napa.log('request', 'A1B2C3D4', 'request received');
It logs an error message. Three variations of arguments are the same with the log.
It logs a warning message. Three variations of arguments are the same with the log.
It logs an info message. Three variations of arguments are the same with the log.
It logs a debug message. Three combinations of arguments are the same with the log.
Developers can hook up custom logging provider by calling the following before creation of any zones:
napa.runtime.setPlatformSettings({
"loggingProvider": "<custom-logging-provider-module-name>"
}
TBD