doc/logging.txt
changeset 0 2b3e5ec03512
equal deleted inserted replaced
-1:000000000000 0:2b3e5ec03512
       
     1 DTN Logging
       
     2 ===========
       
     3 
       
     4 The logging in DTN is organized into hierarchical paths. A partially
       
     5 complete list of the targets is below. In the .dtndebug file, specific
       
     6 targets can be enabled at the various logging levels. In addition,
       
     7 classes that inherit from the oasys::Logger base class also pass the
       
     8 class name to the log system, allowing logging to be enabled for the
       
     9 specific class as well as the hierarchical section. 
       
    10 
       
    11 The basic idea is that a logf command contains an arbitrary log path,
       
    12 a level, and a printf-style body. For example:
       
    13 
       
    14 logf("/some/path", LOG_INFO, "something happened %d times", count);
       
    15 
       
    16 Each application should at intialization call Log::init(level) to
       
    17 prime the default level. All log messages with a level equal or higher
       
    18 than the default are output, others aren't.
       
    19 
       
    20 The code also checks for a ~/.dtndebug file which can optionally
       
    21 contain log paths and other levels. For example:
       
    22 
       
    23 # my ~/.dtndebug file
       
    24 % brief color
       
    25 /some/path debug
       
    26 /other info
       
    27 /other/more/specific debug
       
    28 
       
    29 The paths are interpreted to include everything below them, thus in
       
    30 the example above, all messages to /some/path/... would be output at
       
    31 level debug.
       
    32 
       
    33 In addition to the basic logf interface, there are also a set of
       
    34 macros (log_debug(), log_info(), log_notice(), log_warn(), log_err(),
       
    35 log_crit()) that are more efficient.
       
    36 
       
    37 For example, log_debug expands to
       
    38 
       
    39 #define log_debug(path, ...)                         \
       
    40    if (log_enabled(LOG_DEBUG, path)) {               \
       
    41        logf(LOG_DEBUG, path, ## __VA_ARGS__);        \
       
    42   }                                                  \
       
    43 
       
    44 In this way, the check for whether or not the path is enabled at level
       
    45 debug occurs before the call to logf(). As such, the formatting of the
       
    46 log string, including any inline calls in the arg list are avoided
       
    47 unless the log line will actually be output. Under non-debug builds,
       
    48 all calls to log_debug are completely compiled out.
       
    49 
       
    50 .dtndebug file options
       
    51 ======================
       
    52 
       
    53 There are several options that can be used to customize the display
       
    54 of debug output, and these options are specified on a line in the
       
    55 .debug file prefixed with '%' (see example above):
       
    56 
       
    57 no_path   - Don't display log path
       
    58 no_time - Don't display time stamp
       
    59 no_level  - Don't display log level
       
    60 brief     - Truncate log name to a fixed length and use brief error codes
       
    61 color   - Use terminal escape code to colorize output
       
    62 object  - When possible, display the address of the object that 
       
    63           generated the log.
       
    64 classname - When possible, display the class that generated the log message.
       
    65 See comments in oasys/debug/{Log,Logger}.h for a more in-depth
       
    66 explanation.
       
    67 
       
    68 Logging Targets
       
    69 ===============
       
    70 
       
    71 /command			Singleton tcl command interpreter
       
    72 /command/<command_name>		Specific command "command_name"
       
    73 /log				Internal logging system
       
    74 /timer				Timer system
       
    75 /thread				Threading system
       
    76 
       
    77 /dtnd				DTN daemon wrapper
       
    78 /dtn/bundle/actions		BundleActions interface
       
    79 /dtn/bundle/daemon		BundleDaemon forwarder and basic logic
       
    80 /dtn/bundle/fragmentation	Fragmentation related code
       
    81 /dtn/bundle/list/<name>		BundleList data structure
       
    82 /dtn/bundle/protocol		Bundle wire protocol
       
    83 /dtn/bundle/refs		Reference counting for in-memory bundle objs
       
    84 /dtn/cl/<name>			Convergence layer
       
    85 /dtn/cl/tcp/conn		TCP convergence layer connection
       
    86 /dtn/contact/manager		Contact Managment
       
    87 /dtn/interface/table		Local Interface table
       
    88 /dtn/link/<name>		Links to next-hop peers
       
    89 /dtn/link/<name>/contact	Open contact on links
       
    90 /dtn/route/<name>		BundleRouter <name>
       
    91 /dtn/registration/<regid>	Registration
       
    92 /dtn/registration/table		Table of registrations
       
    93 /dtn/storage/bundles		Storage backend for bundles
       
    94 /dtn/storage/global		Storage backend for global data
       
    95 /dtn/storage/registration	Storage backend for registrations
       
    96