FreeBSD Manual Pages
dnsjit.core.log(3) Library Functions Manual dnsjit.core.log(3) NAME dnsjit.core.log - Core logging facility SYNOPSIS Usage to control global log level local log = require("dnsjit.core.log") log.enable("all") log.disable("debug") Usage to control module log level local example = require("example") -- Example as below example.log():enable("all") example.log():disable("debug") Usage to control object instance log level local example = require("example") -- Example as below local obj = example.new() obj:log():enable("all") obj:log():disable("debug") Usage in C module NOTE naming of variables and module only globals are required to ex- actly as described in order for the macros to work; self is the pointer to the object instance, self->_log is the object instance logging con- figuration struct, _log is the module logging configuration struct. Include logging: #include "core/log.h" Add the logging struct to the module struct: typedef struct example { core_log_t _log; ... } example_t; Add a module logging configuration and a struct default: static core_log_t _log = LOG_T_INIT("example"); static example_t _defaults = { LOG_T_INIT_OBJ("example"), ... }; Use new/free and/or init/destroy functions (depends if you create the object in Lua or not): example_t* example_new() { example_t* self = calloc(1, sizeof(example_t)); *self = _defaults; ldebug("new()"); return self; } void example_free(example_t* self) { ldebug("free()"); free(self); } int example_init(example_t* self) { *self = _defaults; ldebug("init()"); return 0; } void example_destroy(example_t* self) { ldebug("destroy()"); ... } In the Lua part of the C module you need to create a function that re- turns either the object instance Log or the modules Log. Add C function to get module only Log: core_log_t* example_log() { return &_log; } For the structures metatable add the following function: local ffi = require("ffi") local C = ffi.C function Example:log() if self == nil then return C.example_log() end return self._log end Usage in pure Lua module local log = require("dnsjit.core.log") local ffi = require("ffi") local C = ffi.C local Example = {} local module_log = log.new("example") function Example.new() local self = setmetatable({ _log = log.new("example", module_log), }, { __index = Example }) self._log:debug("new()") return self end function Example:log() if self == nil then return module_log end return self._log end DESCRIPTION Core logging facility used by all modules. Log levels all Keyword to enable/disable all changeable log levels. debug Used for debug information. info Used for informational processing messages. notice Used for messages of that may have impact on processing. warning Used for messages that has impact on processing. critical Used for messages that have severe impact on processing, this level can not be disabled. fatal Used to display a message before stopping all processing and ex- isting, this level can not be disabled. C macros Object instance macros The following macros uses &self->_log: ldebug(msg...), linfo(msg...), lnotice(msg...), lwarning(msg...), lcriti- cal(msg...), lfatal(msg...). Object pointer instance macros The following macros uses self->_log: lpdebug(msg...), lpinfo(msg...), lpnotice(msg...), lpwarning(msg...), lpcriti- cal(msg...), lpfatal(msg...). Module macros The following macros uses &_log: mldebug(msg...), mlinfo(msg...), mlnotice(msg...), mlwarning(msg...), mlcriti- cal(msg...), mlfatal(msg...). Global macros The following macros uses the global logging configuration: gldebug(msg...), glinfo(msg...), glnotice(msg...), glwarn- ing(msg...), glcritical(msg...), glfatal(msg...). Functions Log.new(name, module) Create a new Log object with the given module name and an op- tional shared module Log object. Log:enable(level) Enable specified log level. Log:disable(level) Disable specified log level. Log:clear(level) Clear specified log level, which means it will revert back to default or inherited settings. Log:display_file_line(bool) Enable or disable the displaying of file and line for messages. Log.errstr(errno) Convert error number to its text representation. Log.debug(self, ...) Generate a debug message. Log.info(self, ...) Generate an info message. Log.notice(self, ...) Generate a notice message. Log.warning(self, ...) Generate a warning message. Log.critical(self, ...) Generate a critical message. Log.fatal(self, ...) Generate a fatal message. AUTHORS and CONTRIBUTORS Jerry Lundstrm (DNS-OARC), Tom Kek (CZ.NIC), Petr paek (ISC) Maintained by DNS-OARC https://www.dns-oarc.net/ BUGS For issues and feature requests please use: https://github.com/DNS-OARC/dnsjit/issues For question and help please use: admin@dns-oarc.net dnsjit 1.4.0 dnsjit.core.log(3)
NAME | SYNOPSIS | DESCRIPTION | AUTHORS and CONTRIBUTORS | BUGS
Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=dnsjit.core.log&sektion=3&manpath=FreeBSD+Ports+14.3.quarterly>