Installation
Setting up Logging
By default, the moonshot library uses a logger to write logs with its severity to moonshot.log
.
There are multiple severity levels that we are currently using:
Logging Severity | Description |
---|---|
debug | Used for detailed debugging information, helpful during development. |
info | General information about system operation, useful for system monitoring. |
warning | Indicates a potential issue that should be looked into but is not immediately critical. |
error | Reports a failure within the system, requiring immediate attention. |
Additionally, you can customize the logging behavior through environment variables:
Environment Variable | Description | Default Value |
---|---|---|
MS_LOG_NAME | The name of the log file. | moonshot.log |
MS_LOG_LEVEL | The minimum logging severity to capture. Can be one of debug , info , warning , or error . |
info |
MS_LOG_TO_FILE | Whether to write logs to a file (true ) or to standard output (false ). |
false |
To customize the logging behavior of Moonshot through environment variables, you can export them in your terminal.
This allows you to override the default logging configurations. Here's how you can set them:
The logging format is designed to provide a clear and concise overview of each log entry, structured as follows:
This format includes:- timestamp (
%(asctime)s
) - severity level (
%(levelname)s
) - filename (
%(filename)s
) - function name (
%(funcName)s
) - line number (
%(lineno)d
) - log message (
%(message)s
)
For example:
This detailed format ensures that logs are not only easily readable but also provide in-depth information for debugging and monitoring purposes.Specifying Custom Environment File
If you have a custom '.env' file, specify the path to the file as follows: