Module liblog
Lua API for liblog control
Support library for controlling liblog using Lua
See also (project home-sites)
Info:
- Copyright: © Michael Ambrus 2024
- License: MIT
- Author: Michael Ambrus michael@ambrus.se
Functions
| version () | version string |
| level () | Get current log-level |
| setlevel (new) | Set log-level |
| setslevel (new) | Set log-level string |
| settings () | Get liblog settings into a "json"-like table |
| setsyslog (Enable, stderrdup) | Set usage of syslog (mode)
Enable syslog or close it (if opened) and go back to file-operation mode. |
| setlogfile (filename, Sync) | Set File-IO mode filename
Enable File-IO mode with file-name Disable syslog or close it (if opened) Which is determined by the first argument. |
| decorate (Decorate, Decorate) | Set decorators |
| setname (Any) | Set/unset process/marker decorator
This is a special decorator as it can be any string. |
| send (V, Message) | Send log
Test-API to send a liblog log-message of certain type Disable syslog or close it (if opened) Which type determined by the first argument. |
| log (Type, Message) | Send log message |
Functions
- version ()
-
version string
Returns:
-
string
version
- level ()
-
Get current log-level
Returns:
- integer log-level
- string log-level
- setlevel (new)
-
Set log-level
Parameters:
- new integer log-level
Returns:
- integer previous log-level
- integer current log-level
- setslevel (new)
-
Set log-level string Set log-level as human readable string
Parameters:
- new integer log-level
Returns:
- settings ()
-
Get liblog settings into a "json"-like table Each table index is a tuple:
["name" : value]
Returns:
- integer number settings
- table tuple-table with settings
Usage:
Return table --[[ 1. (char *) fname Write to file-name 2. (enum) ts Time-stamp decoration type NO_TIME, Don't decorate with time stamp SHORT_TIME, Numerical epoc timestamp VERBOSE_TIME, HH:MM:SS.ms DATE_TIME Date format 3. (enum) pidtid Decorate with process- thread-id NO_PIDTID_DECO, Don't decorate with pid/tid TID_DECO, Thread only (suitable when syslog as only pid is shown) PID_DECO, PID only (quite useless) PIDTID_DECO Both pid/tid 4. (bool) tosyslog Send to syslog without decoration 5. (bool) sys2err If syslog, also stderr (syslogs decoration) 6. (char *) proc_name Name of process 7. (int) nsync Flush output after each write in File-IO mode 0 : buffered <0 : Flush file after each write (warning: decreases performance) >0 : Flush file after each nsync write --]]
-- Example of usage: n,s = liblog.settings() for i=1,n do print(s[i][1], s[i][2]) end
- setsyslog (Enable, stderrdup)
-
Set usage of syslog (mode)
Enable syslog or close it (if opened) and go back to file-operation mode.
Which is determined my the first argument. Second argument enables copy syslog to stderr. It's ignored if not enabling syslog operation.
Parameters:
- Enable boolean 1=Enable 0=Disable
- stderrdup boolean 1=Enable 0=Disable
Returns:
- boolean previous mode-state
- boolean previous sys2err
- boolean current state-state
- boolean previous sys2err
- setlogfile (filename, Sync)
-
Set File-IO mode filename
Enable File-IO mode with file-name Disable syslog or close it (if opened)
Which is determined by the first argument. Second argument enables copy syslog to stderr. It's ignored if not enabling syslog operation.
Parameters:
- filename string
- Sync nsync counter. 0=Buffered, -1=Fully sync, >0 sync each n'th
Returns:
- decorate (Decorate, Decorate)
-
Set decorators For values:
Parameters:
- Decorate integer pid/tid mode. 0=off, 1=tid...
- Decorate integer pid/tid mode. 0=off, 1=tid...
Returns:
- integer previous ts
- integer previous pidtid
- integer current ts
- integer current pidtid
See also:
- setname (Any)
-
Set/unset process/marker decorator
This is a special decorator as it can be any string. Usually it contains application or process name but user can but anything here.
Parameters:
- Any string string (marker)
Returns:
- send (V, Message)
-
Send log
Test-API to send a liblog log-message of certain type Disable syslog or close it (if opened)
Which type determined by the first argument. Second argument enables copy syslog to stderr. It's ignored if not enabling syslog operation.
Parameters:
- V integer =0, D=1, I=2, W=3, E=4, C=5
- Message string
Returns:
-
boolean
OK
- log (Type, Message)
-
Send log message Test-API to send a liblog log-message of certain type
Which type to send is determined by the first argument.
Parameters:
Returns:
-
boolean
OK