-
Notifications
You must be signed in to change notification settings - Fork 0
Log Manager
The built-in logger provides leveled, colored console output with automatic file writes and memory storage.
from nautica import LoggerEach method corresponds to a log level, which controls the color and severity of the output
| Method | Level | Use for |
|---|---|---|
Logger.info(msg) |
INFO | General information |
Logger.ok(msg) |
OK | Successful operations |
Logger.warn(msg) |
WARN | Non-critical issues |
Logger.error(msg) |
ERROR | Errors that need attention |
Logger.critical(msg) |
CRITICAL | Severe errors |
Logger.debug(msg) |
DEBUG | Debug info, only shown when nautica.debug is True
|
Logger.info("Server is starting...")
Logger.ok("Connected to database")
Logger.warn("Config value missing, using default")
Logger.error("Failed to load plugin")
Logger.critical("Service failed to initialize")
Logger.debug("Raw response: " + str(data))Logs are automatically written to .logs/ in your project directory.
A new file is created each time the project starts, named by timestamp:
.logs/nautica_01_01_25__12_00_00.log
This directory is excluded from git by default in .gitignore.
Nautica keeps the last 100 log entries in memory, accessible via LogMemory:
from nautica import Logger
from nautica.manager import LogMemory
entries = LogMemory.Recall() # all entries
entries = LogMemory.Recall(10) # last 10 entriesEach entry is a dict:
{
"moduleName": {
"full": "myproject.services.myservice",
"short": "myserv"
},
"timestamp": {
"formatted": "12:00:00",
"raw": 1234567890.0
},
"message": "Connected to database",
"level": "OK"
}Use Logger.table() to display structured data in a table format:
Logger.table() \
.labels(["Name", "Status", "Port"]) \
.row(["HTTPServer", "Running", "8100"]) \
.row(["WebSocket", "Disabled", "-"]) \
.display().display() accepts an optional log level, defaulting to INFO:
.display(LogLevel.DEBUG) # only shown when debug mode is onUse Logger.trace() to log a full exception stacktrace:
try:
do_something()
except Exception as e:
Logger.trace(e)This logs the exception type, message, file, line number, and full traceback.
If you need to log at a specific level directly, use Logger.log():
from nautica.manager import LogLevel
Logger.log("Something happened", LogLevel.INFO)Available levels:
| Level | Value |
|---|---|
LogLevel.DEBUG |
10 |
LogLevel.TRACE |
11 |
LogLevel.INFO |
20 |
LogLevel.OK |
21 |
LogLevel.WARN |
30 |
LogLevel.ERROR |
40 |
LogLevel.CRITICAL |
41 |
LogLevel.SILENT |
-999 |
- Home
- CLI Reference
- Service Registry
- Built-in Services
- Managers
- Requirement Validators