naneos.logger.custom_logger
Logging setup of the naneos package.
The package follows the library convention: every module logs to a logger below "naneos" and the package itself installs only a NullHandler, so nothing is printed unless the application configures logging. Two helpers make the common cases one call: enable_console_logging() and enable_file_logging().
CustomFormatter
Bases: Formatter
The naneos log line, optionally coloured by level for terminals.
Source code in src/naneos/logger/custom_logger.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
enable_console_logging(level=logging.INFO, colored=True)
Print naneos log messages of at least level to stderr.
Calling it again replaces the previous console handler, so the output is never duplicated. Returns the "naneos" logger.
Source code in src/naneos/logger/custom_logger.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
enable_file_logging(path, level=logging.INFO)
Append naneos log messages of at least level to a file.
path may be a directory, in which case naneos-devices.log is created in
it. Calling it again replaces the previous file handler. Returns the
"naneos" logger.
Source code in src/naneos/logger/custom_logger.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
get_naneos_logger(name, level=None)
The logger for a naneos module. Handlers and levels are configured by the application (or the enable_* helpers), not by the module.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Usually name of the calling module. |
required |
level
|
int | None
|
Optional level for this one logger. Library modules leave it unset so that one setting on the "naneos" logger controls them all. |
None
|
Source code in src/naneos/logger/custom_logger.py
54 55 56 57 58 59 60 61 62 63 64 65 66 | |
set_naneos_logger_save_path(path)
Deprecated alias of enable_file_logging(), kept for naneos-devices <= 1.1.x.
Source code in src/naneos/logger/custom_logger.py
114 115 116 | |