-
Notifications
You must be signed in to change notification settings - Fork 174
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
Add ?fail_on_error argument to Lwt_log_core.load_rules, also expose new level_of_string function in the interface #306
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,9 +86,30 @@ type section | |
|
||
val string_of_level : level -> string | ||
|
||
val load_rules : string -> unit | ||
val level_of_string : string -> level option | ||
|
||
val load_rules : ?fail_on_error:bool -> string -> unit | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should probably document There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree. I'll add a docstring. |
||
(** Reset the rules set when parsing the [LWT_LOG] environment variable using this | ||
string. *) | ||
string. | ||
|
||
@param fail_on_error defines if the function will raise Failure if | ||
it encounters a malformed rule | ||
@raise Failure if an invalid rule is found and [fail_on_error] is true | ||
|
||
[load_rules] parses the rules string and validates the rules before loading them. | ||
If [fail_on_error] is [true], invalid rules will cause this function to | ||
raise [Failure] and leave existing rules unchanged. | ||
If [fail_on_error] is [false] (this is the default), it tries to load as | ||
many rules as possible and ignore invalid ones. | ||
If the rules string itself cannot be parsed, existing rules are always left | ||
unchanged. | ||
|
||
Example: | ||
{[ | ||
Lwt_log_core.load_rules ~fail_on_error:true "* -> nosuchlevel" (* Raises Failure *) | ||
Lwt_log_core.load_rules "* -> info" | ||
]} | ||
*) | ||
|
||
val add_rule : string -> level -> unit | ||
(** [add_rule pattern level] adds a rule for sections logging | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right to worry about this, but we can't use
lowercase_ascii
because Lwt still supports 4.02.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, good I kept it intact then.