LoggerService that collects log messages during program execution. In project mode, all collected logs are written to .ocat/logs.txt when the process exits. You can control which log levels are active and how messages are transformed by creating a logcfg.json file.
Log levels
TheLogLevel enum defines four levels:
| Level | Value |
|---|---|
| Debug | "DEBUG" |
| Info | "INFO" |
| Warning | "WARNING" |
| Error | "ERROR" |
DEBUG and INFO. Messages at other levels are collected but not enabled unless you override the configuration.
Log persistence
Log persistence depends on whether code is running inside a project:- Project mode (
ocm run): on process exit, all collected logs are written to.ocat/logs.txtin the format[LEVEL] message. - Single-file mode (
ocat run): logs are printed to the console but are not persisted to disk.
The log file is written at process exit, not line by line. If the process is killed abruptly, partial logs may not be saved.
LoggerConfig
The logger is configured through aLoggerConfig object. When running in project mode, this is loaded from .ocat/logcfg.json if that file exists. Otherwise the default configuration is used.
Array of log level string values that are enabled. Messages at levels not listed here are still collected internally but excluded from output.Valid values:
"DEBUG", "INFO", "WARNING", "ERROR".Array of interceptor objects. Each interceptor transforms log messages at a specific level before they are processed.Each interceptor object has:
level(string) — theLogLevelvalue this interceptor applies toonLog(function) — a function that receives the original message string and returns a transformed message string
logcfg.json
Place alogcfg.json file at .ocat/logcfg.json to override the default logger configuration. OCM reads this file before executing your program.
The file must be valid JSON and match the LoggerConfig shape.
Enable all log levels
.ocat/logcfg.json
Enable only warnings and errors
.ocat/logcfg.json
Log file format
Each line in.ocat/logs.txt follows this format:
Related pages
Projects overview
Understand project types, directory structure, and the project lifecycle.
Project configuration
Full reference for
.ocat/config.json and the optional logcfg.json field.