Skip to content

Log Method/stream Definitions

Defines function names that mark string constants as having a log context.

When parsing these invocations:

logger.error("could not connect to {}", host);
cerr << "could not connect to" << host << << std::endl;

The string constants receive a 'log' context, unlike non-logging calls:

foo("could not connect to " + host);

Use the symbolTypes argument to filter non-logging symbols and reduce library file size.

Configuration

To configure the Log method/stream definitions module, Edit these settings.

Below is the default configuration from: logMethods/default.yaml.

Edit Online

Edit default.yaml Locally

# 🔟❎ 'compile' log methods configuration

# Set the 10x pipeline to 'compile'
tenx: compile

# ============================ Log Options =============================

log:

  # 'methods' lists known method names collected from common logging
  #  frameworks used to indicate source code logging events to stream at runtime.

  #  Identifying those points in source code that perform logging operations
  #  and marking them within an output symbol unit file (*.json)
  #  allows the 'run' pipeline to correlate each TenXObject structured from the event
  #  data back to its origin in the codebase.

  #  To learn more about symbol contexts and their use, see https://doc.log10x.com/run/transform/symbol/#contexts
  methods:

    # Assertions are not enabled by default as they are less likely to appear in prod logs
    # - Assert
    # - assert
    # - assertEquals
    # - assertEqual

    - exception

    - Log
    - LOG
    - log
    - BOOST_LOG_TRIVIAL

    - trace
    - Trace
    - log_trace
    - logTrace
    - TRACE
    - LOG_TRACE

    - debug
    - Debug
    - logDebug
    - log_debug
    - DEBUG
    - LOG_DEBUG
    - Debugf

    - info
    - Info
    - log_info
    - logInfo
    - INFO
    - LOG_INFO
    - information
    - LogInformation
    - InfoF

    - warn
    - Warn
    - log_warn
    - logWarn
    - WARN
    - LOG_WARN
    - WarnF

    - warning
    - logWarning
    - LOG_WARNING

    - error
    - Error
    - logError
    - log_error
    - ERROR
    - LOG_ERROR
    - ErrorF

    - err

    - fatal
    - Fatal
    - log_fatal
    - logFatal
    - FATAL
    - LOG_FATAL
    - FatalF

    - critical
    - Panic

  # 'methodRegex' specifies an optional regex that will be applied
  #  to a scanned source code method/function name. If matched, the method
  #  will be considered to be a 'logging method' (see above).
  #  For example: ^(log|Log)|(Log|log)$
  methodRegex: null

  # 'streams' defines which source code variables within
  #  this ANTLR syntax are treated as output streams (e.g. stdout, stderr, cerr).
  #  Literal constants (e.g. "error connecting to {}") passed to a variable
  #  listed below (e.g. 'cout') will be assigned a 'logger_method_invoke'
  #  symbol source context.
  streams:

  # - assert
    - cout
    - cerr
    - Error
    - Debug
    - err
    - out
    - Console

Options

Specify the options below to configure the Log method/stream definitions:

Name Description
logMethods Names of source code methods to mark as 'logging'
logMethodRegex A pattern that source code methods names must match to qualify as 'logging' methods
logStreams Names of source code variables to mark as 'logging'

logMethods

Names of source code methods to mark as 'logging'.

Type Default
List []

Lists 'logging' method names whose invocations to mark 'logging'. Logging frameworks commonly define standard methods to emit event information to program output (e.g., 'warn', 'error').

logMethodRegex

A pattern that source code methods names must match to qualify as 'logging' methods.

Type Default
String ""

Specifies a pattern for symbol scanners to apply to source code method/function names to determine whether to mark them as 'logging'. For example: ^(log|Log)|(Log|log)$.

logStreams

Names of source code variables to mark as 'logging'.

Type Default
List []

Lists 'logging' member names whose assignments to mark 'logging'. Programming languages commonly define standard members to emit events to output (e.g., 'out', 'cerr').


This module is defined in logMethods/module.yaml.