Module tplog
Lua API for tplog based log-probes
tplog stands for "Trace-point logs" and is a way to extend log-entries to become "probes" that can be found using human readable symbolic reference like "file-name", "function-name" and "kind", and thereby have it's behaviour or properties modified in runtime.
See also (project home-sites)
Info:
- Copyright: © Michael Ambrus 2024
- License: MIT
- Author: Michael Ambrus michael@ambrus.se
Functions
| version () | version string |
| isinit () | is module initialized |
| listall () | print all the LOG unconditionally |
| all () | Get all probes into a table
Same as "listall" but instead of dumping to stdout, "all" returns a table and the number of elements in it. |
| total () | total number of probes |
| enable (probe_id, control) | enable log
Puts a log-point under our control and forces it to either log, silence or leave supervision-mode. |
Functions
- version ()
-
version string
Returns:
-
string
version
- isinit ()
-
is module initialized
Returns:
-
integer
Balance, 0 if un-initialized.
- listall ()
- print all the LOG unconditionally
- all ()
-
Get all probes into a table
Same as "listall" but instead of dumping to stdout, "all" returns a table and the number of elements in it. This makes furter processing in Lua possible.
Returns:
- integer number of probes
- table uprobe-table
Usage:
Each element in uprobe-table: --[[ 1. (intp) ID i.e. address of probe 2. (char) kind V-E ie. VERBOSE to ERROR, or L=Not yet passed (unknown) 3. (char*) file-name 4. (char*) function-name 5. (size_t) line-number --]]
-- Example. Print a list similar to probe.listall() n,up = log.all() for i=1,n do print(up[i][1], up[i][2], up[i][3], up[i][4], up[i][5]) end
- total ()
-
total number of probes
Returns:
-
integer
number of probes
- enable (probe_id, control)
-
enable log
Puts a log-point under our control and forces it to either log, silence or leave supervision-mode. A probe_id is checked for magic markers before it's state is made. Return-value reflects success or failure. On failure reason is output on stderr
Parameters:
- probe_id integer
- control integer 0=disable, 1=enable, 2=abandon (back to normal)
Returns:
-
bool
success