Skip to content

Extend debug message logging / debug output - #37

Closed
fonic wants to merge 1 commit into
jech:masterfrom
fonic:debug-output
Closed

Extend debug message logging / debug output#37
fonic wants to merge 1 commit into
jech:masterfrom
fonic:debug-output

Conversation

@fonic

@fonic fonic commented Apr 22, 2018

Copy link
Copy Markdown
Contributor

This extends debug message logging / debug output generated by the library.

Additions/changes:

  • adds support for message types (debug, info, warning, error)
  • adds macros to easily log messages (debugf, infof, warnf, errorf)
  • messages are sent to user-defined callback instead of file, so that the user (i.e. the application) may decide how to handle debug output (write to file, add to application logger, add to GUI element etc.)
  • adds string conversion functions that may be used in printf-like function calls (for address family, IP protocol version, bucket/node ID, socket address, byte array to hex/printable string, etc.)
  • migrates all former debugf calls to debugf, infof, warnf and errorf calls
  • adds additional debug output (e.g. initialization, search) and extends existing debug output (added node addresses, IDs etc.) -> see screenshot
  • adds function dht_stats() to retrieve current statistics (number of buckets, good/dubious/total nodes)
  • modifies dht-example to demonstrate the new capabilities by generating colorful log output and printing statistics when dumping/exiting

NOTE:
There are certain limitations regarding the string conversion functions:

  • byte array to hex/printable string will truncate at 1024 bytes
  • byte array to hex/printable string, id to hex string and socket address to string can only be used once within a single printf-like call

These limitations are the result of using static buffers to return the strings. Since all of this is only about debug output, I figured one can live with the limitations.

Screenshot:
screenshot_20180523_130755

This was referenced May 4, 2018
@fonic fonic changed the title Extend debug message logging Extend debug message logging / debug output May 15, 2018
Extend debug message logging / debug output:
- add support for message types (debug, info, warning, error)
- introduce logging macros to easily log messages (debugf, infof,
  warnf, errorf)
- log messages to user-defined callback instead of file so that
  application may be decide how to handle debug output
- add string conversion functions that may be used in printf-style
  function calls (address family, IP protocol version, bucket/node
  ID, socket address, etc.)
- add DHT_LOG_ defines to control certain features
- add function to retrieve statistics (buckets, good nodes,
  dubious nodes, total nodes)
- modify dump_bucket() and dht_dump_tables() to output tables
- migrate all debugf calls to make use of the new capabilities
- add additional debug output
- modify dht-example to make use of the new capabilities
@jech

jech commented Jun 30, 2018

Copy link
Copy Markdown
Owner

Rejected. We don't need this complexity.

@jech jech closed this Jun 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants