Back to all reviewers

Use appropriate log levels

semgrep/semgrep
Based on 4 comments
Other

Choose log levels based on the intended audience to prevent user-visible noise. Most logging should use `Logs.debug` rather than `Logs.info` or `Logs.err`, since info-level and above messages are visible to end users with `--verbose` or by default.

Logging Other

Reviewer Prompt

Choose log levels based on the intended audience to prevent user-visible noise. Most logging should use Logs.debug rather than Logs.info or Logs.err, since info-level and above messages are visible to end users with --verbose or by default.

Guidelines:

  • Use Logs.debug for development/troubleshooting information (parser errors, internal state, performance details)
  • Use Logs.info only for information that end users should see with --verbose
  • Use Logs.err only for errors that end users need to act upon
  • Tagged messages (with ~tags) should generally be debug-level unless specifically intended for users

Example:

(* Bad - creates noise for users *)
Logs.err (fun m -> m ~tags "BUG PARSING LOCAL DECL PROBABLY");
Logs.info (fun m -> m "skipping: %s" (Tok.content_of_tok tok));

(* Good - appropriate for debugging *)  
Logs.debug (fun m -> m ~tags "BUG PARSING LOCAL DECL PROBABLY");
Logs.debug (fun m -> m "skipping: %s" (Tok.content_of_tok tok));

The principle is that no log message should appear to command-line users unless they explicitly enable debugging or the message requires user action.

4
Comments Analyzed
Other
Primary Language
Logging
Category

Source Discussions