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:
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.
ewogICJ0eXBlIiA6ICJvYmplY3QiLAogICJwcm9wZXJ0aWVzIiA6IHsKICAgICJ0ZW54IiA6IHsKICAgICAgInR5cGUiIDogInN0cmluZyIKICAgIH0sCiAgICAibG9nIiA6IHsKICAgICAgInR5cGUiIDogIm9iamVjdCIsCiAgICAgICJhZGRpdGlvbmFsUHJvcGVydGllcyIgOiBmYWxzZSwKICAgICAgInByb3BlcnRpZXMiIDogewogICAgICAgICJtZXRob2RzIiA6IHsKICAgICAgICAgICJ0eXBlIiA6IFsKICAgICAgICAgICAgImFycmF5IiwKICAgICAgICAgICAgIm51bGwiCiAgICAgICAgICBdLAogICAgICAgICAgIm1hcmtkb3duRGVzY3JpcHRpb24iIDogIk5hbWVzIG9mIHNvdXJjZSBjb2RlIG1ldGhvZHMgdG8gbWFyayBhcyAnbG9nZ2luZydcblxuTGlzdHMgJ2xvZ2dpbmcnIG1ldGhvZCBuYW1lcyB3aG9zZSBpbnZvY2F0aW9ucyB0byBtYXJrICdsb2dnaW5nJy4gTG9nZ2luZyBmcmFtZXdvcmtzIGNvbW1vbmx5IGRlZmluZSBzdGFuZGFyZCBtZXRob2RzIHRvIGVtaXQgZXZlbnQgaW5mb3JtYXRpb24gdG8gcHJvZ3JhbSBvdXRwdXQgKGUuZy4sICd3YXJuJywgJ2Vycm9yJykuIiwKICAgICAgICAgICJpdGVtcyIgOiB7CiAgICAgICAgICAgICJ0eXBlIiA6ICJzdHJpbmciCiAgICAgICAgICB9CiAgICAgICAgfSwKICAgICAgICAibWV0aG9kUmVnZXgiIDogewogICAgICAgICAgInR5cGUiIDogWwogICAgICAgICAgICAic3RyaW5nIiwKICAgICAgICAgICAgIm51bGwiCiAgICAgICAgICBdLAogICAgICAgICAgIm1hcmtkb3duRGVzY3JpcHRpb24iIDogIkEgcGF0dGVybiB0aGF0IHNvdXJjZSBjb2RlIG1ldGhvZHMgbmFtZXMgbXVzdCBtYXRjaCB0byBxdWFsaWZ5IGFzICdsb2dnaW5nJyBtZXRob2RzXG5cblNwZWNpZmllcyBhIHBhdHRlcm4gZm9yIHN5bWJvbCBzY2FubmVycyB0byBhcHBseSB0byBzb3VyY2UgY29kZSBtZXRob2QvZnVuY3Rpb24gbmFtZXMgdG8gZGV0ZXJtaW5lIHdoZXRoZXIgdG8gbWFyayB0aGVtIGFzICdsb2dnaW5nJy4gRm9yIGV4YW1wbGU6IF4obG9nfExvZyl8KExvZ3xsb2cpJCIKICAgICAgICB9LAogICAgICAgICJzdHJlYW1zIiA6IHsKICAgICAgICAgICJ0eXBlIiA6IFsKICAgICAgICAgICAgImFycmF5IiwKICAgICAgICAgICAgIm51bGwiCiAgICAgICAgICBdLAogICAgICAgICAgIm1hcmtkb3duRGVzY3JpcHRpb24iIDogIk5hbWVzIG9mIHNvdXJjZSBjb2RlIHZhcmlhYmxlcyB0byBtYXJrIGFzICdsb2dnaW5nJ1xuXG5MaXN0cyAnbG9nZ2luZycgbWVtYmVyIG5hbWVzIHdob3NlIGFzc2lnbm1lbnRzIHRvIG1hcmsgJ2xvZ2dpbmcnLiBQcm9ncmFtbWluZyBsYW5ndWFnZXMgY29tbW9ubHkgZGVmaW5lIHN0YW5kYXJkIG1lbWJlcnMgdG8gZW1pdCBldmVudHMgdG8gb3V0cHV0IChlLmcuLCAnb3V0JywgJ2NlcnInKS4iLAogICAgICAgICAgIml0ZW1zIiA6IHsKICAgICAgICAgICAgInR5cGUiIDogInN0cmluZyIKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgIH0KICB9LAogICJhZGRpdGlvbmFsUHJvcGVydGllcyIgOiBmYWxzZQp9
# 🔟❎ '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.