Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow log levels to be configured per-source. #171

Merged
merged 2 commits into from Nov 8, 2021

Conversation

jsthomas
Copy link
Contributor

@jsthomas jsthomas commented Nov 3, 2021

This change updates the logging API to allow log levels for sub-logs to be customized. This is a revision of #159, rebased on the latest in master for easier review. The change is motivated by issue #90; configurable log levels would assist with debug and warning logs for flash messages.

The change adds an optional argument to set the level of a sub-log at creation:

Dream.sub_log : ?level:[< log_level ] -> string -> sub_log

as well as a new function to set the log level afterward:

Dream.set_log_level : string -> [< log_level ] -> unit

Example Usage

let () =
  Dream.initialize_log ~level:`Warning ();
  Dream.set_log_level "dream.flash" `Info;
  let app_log = Dream.sub_log ~level:`Info "my_app" in 
  Dream.run
  ...
  (* Now log messages on my_app and dream.flash will show if they are of info-level or higher.
     Other messages must be warning-level or higher to be displayed.*)

@aantron aantron merged commit 440fa71 into aantron:master Nov 8, 2021
@aantron
Copy link
Owner

aantron commented Nov 8, 2021

Thank you!

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.

None yet

2 participants