Debugging in torero
It is inevitable that any Developer will need to troubleshoot scripts running in torero. As such, torero provides some tools to see what is happening.
tl;dr
To quickly see logs, set TORERO_LOG_LEVEL
= DEBUG
and run all torero commands with --verbose
.
Example
export TORERO_LOG_LEVEL="DEBUG"
torero get services --verbose
>_ ./torero get services
NAME TYPE CREATED
ha2-iap opentofu-plan 2024-08-20T17:45:01Z
ha3 opentofu-plan 2024-08-20T21:00:19Z
>_ export TORERO_LOG_LEVEL="DEBUG"
>_ ./torero get services --verbose
2024-08-29T17:36:17Z INF writing logs to /Users/torero/.torero.d/torero.log
2024-08-29T17:36:17Z INF using configuration file at /Users/torero/.torero.d/torero.conf
2024-08-29T17:36:17Z INF using local store database file at torero.db
2024-08-29T17:36:18Z INF using local resources as application mode is set to local
2024-08-29T17:36:18Z DBG Getting store's values for prefix 'torero/bullpen/services/v1'
2024-08-29T17:36:18Z DBG Getting store's values for prefix 'torero/bullpen/decorator/v1'
NAME TYPE CREATED
ha2-iap opentofu-plan 2024-08-20T17:45:01Z
ha3 opentofu-plan 2024-08-20T21:00:19Z
Logging
This file contains information about how logging is performed in torero as well
as the standards and conventions used when writing logs in code. Logging
functions are available inside of the internal/logger
package.
Log File
Server
When torero is launched in server mode (torero server
), the log file will be
located at TORERO_LOG_SERVER_DIR/torero.log
. If TORERO_LOG_SERVER_DIR
is
not specified, a default location of /var/log/torero/torero.log
will be
used.
Client
When the torero CLI client is used, the log file will be located at
TORERO_APPLICATION_WORKING_DIR/torero.log
. This location is used when users run CLI
commands to accommodate torero CLI users that do not have /var/log
access.
Console Logs
If you wish to have console logs displayed to the terminal when you run torero
you can append --verbose
to whichever command you are running. For example,
running torero server --verbose
will launch the server with console logs.
Format
By default, logs will be displayed in the format shown below:
2024-02-14T09:18:28-06:00 INF grpc server is starting up
.
If you would like to have your logs displayed in JSON, you can set the
environment variables TORERO_LOG_FILE_JSON=true
or
TORERO_LOG_CONSOLE_JSON=true
. Some clients may prefer JSON so that they can
more easily feed their logs into 3rd party software such as log aggregation
programs.
JSON logs will resemble what is shown below:
{"level":"info","time":"2024-02-14T09:18:28-06:00","message":"grpc server is starting up"}
By default, console logs will have some color formatting. To remove the color,
please set the environment variable TORERO_TERMINAL_NO_COLOR=true
.
Logging Levels
torero supports many different logging levels to denote the importance of a log
as well as the severity of an error. The log level that is used by torero will
be set by an environment variable called TORERO_LOG_LEVEL
. The default value
if TORERO_LOG_LEVEL
is unset is INFO
. Both file and console logs will match
the value set by TORERO_LOG_LEVEL
.
Supported logging levels include - TRACE - DEBUG - INFO - WARN - ERROR - FATAL - DISABLED
torero will display logs for the level set in TORERO_LOG_LEVEL
as well as
any logs of higher importance. The list above is ordered from least important
to most important.
For example, if INFO
logs are selected, a user will be
shown logs for INFO
, WARN
, ERROR
, and FATAL
. They will not see DEBUG
and TRACE
logs.