Skip to content

Commit

Permalink
Logging library: better API documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ryzhyk committed Jul 8, 2019
1 parent d5d1694 commit e41832a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/ddlog_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
* `module` - Opaque module identifier. Can represent module, subsystem, log
* stream, etc.
* `cb` - Callback to be invoked for each log message with the given module
* id and log level `<= max_level`.
* id and log level `<= max_level`. Passing `NULL` disables
* logging for the given module.
* `max_level` - Don't invoke the callback for messages whoe log level is
* `> max_level`.
*/
Expand Down
3 changes: 2 additions & 1 deletion lib/log.dl
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ typedef log_level_t = signed<32>
* `level` - log level
* `msg` - error message (UTF-8)
*
* Always returns `true`.
* This function returns a `bool` so that it can be used as a filter inside
* DDlog rules. It always returns `true`.
*/
extern function log(module: module_t, level: log_level_t, msg: string): bool
6 changes: 5 additions & 1 deletion lib/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ lazy_static! {

/*
* Logging API exposed to the DDlog program.
* (see detailed documentation in `log.dl`)
*/
pub fn log_log(module: &log_module_t, level: &log_log_level_t, msg: &String) -> bool
{
Expand All @@ -27,7 +28,10 @@ pub fn log_log(module: &log_module_t, level: &log_log_level_t, msg: &String) ->
}

/*
* Configuration API.
* Configuration API
* (detailed documentation in `ddlog_log.h`)
*
* `cb = None` - disables logging for the given module.
*
* NOTE: we set callback and log level simultaneously. A more flexible API
* would allow changing log level without changing the callback.
Expand Down

0 comments on commit e41832a

Please sign in to comment.