The DTN2 implementation uses the logging facility from oasys. It supports multiple log paths and different log levels for each log path.
The logging in DTN is organized into hierarchical paths. The basic idea is that a logf command contains an arbitrary log path, a level, and a printf-style body. For example:
logf("/some/path", LOG_INFO, "something happened %d times", count);
For instance, this .dtndebug file makes the default level for /dtn/* to be info, but causes debug info to be printed for all link operations other than for tcp0.
# example .dtndebug file /dtn/link/tcp0 info /dtn/link debug /dtn info
Note that the order is important. If /dtn info was place first in the list the entries this would have the effect of overriding entries after to log level info.
# example .dtndebug file /dtn info /dtn/link/tcp0 info /dtn/link debug
In dtnd, the log messages go out to standard out, by default. You can change that using the "-o filename" option to dtnd.
Here is the list of the logging levels:
There are several options that can be used to customize the display of debug output, and these options are specified on a line in the .dtndebug file prefixed with '%'
A detailed example of a .dtndebug file with options (incomplete!) is provided here.
no_path | Don't display log path |
no_time | Don't display time stamp |
no_level | Don't display log level |
brief | Truncate log name to a fixed length and use brief error codes |
color | Use terminal escape code to colorize output |
object | When possible, display the address of the object that generated the log. |
classname | When possible, display the class that generated the log message. |
See comments in oasys/debug/{Log,Logger}.h for a more in-depth explanation.
Below is an incomplete list of logging targets used by the DTN2 implementation. You can find others by observing output with logging turned up to the maximum ("/ debug" || dtnd -l debug) or by searching for logpath in the source code.
/command | Singleton tcl command interpreter |
/command/<command_name> | Specific command "command_name" |
/log | Internal logging system |
/timer | Timer system |
/thread | Threading system |
/dtnd | DTN daemon wrapper |
/dtn/bundle/actions | BundleActions interface |
/dtn/bundle/daemon | BundleDaemon forwarder and basic logic |
/dtn/bundle/fragmentation | Fragmentation related code |
/dtn/bundle/list/<name> | BundleList data structure |
/dtn/bundle/protocol | Bundle wire protocol |
/dtn/bundle/refs | Reference counting for in-memory bundle objs |
/dtn/cl/<name> | Convergence layer |
/dtn/cl/tcp | TCP Convergence Layer |
/dtn/cl/udp | UDP Convergence Laye |
/dtn/cl/tcp/conn | TCP convergence layer connection |
/dtn/contact/manager | Contact Managment |
/dtn/interface/table | Local Interface table |
/dtn/link/<name> | Links to next-hop peers |
/dtn/link/<name>/contact | Open contact on links |
/dtn/route/<name> | BundleRouter <name> |
/dtn/registration/<regid> | Registration |
/dtn/registration/table | Table of registrations |
/dtn/storage/bundles | Storage backend for bundles |
/dtn/storage/global | Storage backend for global data |
/dtn/interface | interface management |
/dtn/tclcmd | Errors from TCL commands |
/dtn/apiserver | API Server |
/dtn/apiclient | API Client |
/dtn/discovery$name | discovery |
/dtn/discovery/ip | IP discovery |
/dtn/discovery/bt | Bluetooth discovery |
/dtn/bundle | Bundle |
/dtn/bundle/actions | BundleActions interface |
/dtn/bundle/daemon | BundleDaemon forwarder and basic logic |
/dtn/bundle/fragmentation | Fragmentation related code |
/dtn/bundle/list/$name | BundleList data structure |
/dtn/bundle/protocol | Bundle wire protocol |
/dtn/bundle/refs | Reference counting for in-memory bundle objs |
/dtn/contact/manager | Contact manager |
You can force the daemon to reread the .dtndebug file while it is running by sending it a HUP signal. You can also use the log reparse_debug_file TCL command.
You can send the daemon the USR1 signal to make it reopen the log file. You could use a shell script like this to roll the log file and start a new one:
mv log.txt log-`date +%Y-%m-%d`.txt pkill -USR1 dtnd
You can also rotate the log file from inside the TCL interpreter using the log rotate TCL command.