Back to all reviewers

structure contextual log messages

llvm/llvm-project
Based on 2 comments
Other

Log messages should include sufficient contextual information and structured formatting to enable effective debugging and filtering. This means including relevant metadata, level information, and clear prefixes that help developers understand the source and severity of logged events.

Logging Other

Reviewer Prompt

Log messages should include sufficient contextual information and structured formatting to enable effective debugging and filtering. This means including relevant metadata, level information, and clear prefixes that help developers understand the source and severity of logged events.

For error logging, include references to relevant objects or metadata that can provide additional context:

void log(raw_ostream &OS) const override {
  OS << Message;
  if (MD)
    MD->printTree(OS);
}

For debug logging, include level information in prefixes to enable easy filtering:

if (DebugType) {
  if (Level == 0)
    Level = 1;
  OsPrefix << "[" << DebugType << ":" << Level << "] ";
}

This approach allows developers to filter verbose output by level and provides rich context when debugging issues. Well-structured log messages reduce debugging time and improve the overall development experience.

2
Comments Analyzed
Other
Primary Language
Logging
Category

Source Discussions