Server monitoring Discord Bot Logger
This is a logger used by the Server Monitoring Discord Bot and every module created for it by me.
Possible log formats:
- [COUNTER] [LEVEL]: DATA{END}
- [COUNTER] [FILE_NAME->METHOD_1->...->CALLER]: DATA{END}
- [COUNTER] [METHOD_1->...->CALLER]: DATA{END}
If the caller name is shown and the caller was the body of the file, a line number will be shown instead.
Available log levels:
- TRACE
- DEBUG
- INFO
- WARNING
- ERROR
- EXCEPTION
- HEADER
Options:
| Variable name | Description | Default value |
|---|---|---|
| log_file_name | The name of the log file | None |
| log_folder | The path of the folder to save the log file | Current Directory |
| clear | Clears the log file every time it's initialized | False |
| level | Sets the minimum level for the logger to show | INFO |
| log_to_console | Sets to log to console too | True |
| storage_life_extender_mode | Limits the writes to the file by caching the data | False |
| max_caller_chain_size | Limits the maximum size of the call chain shown | -1 (No limit) |
| max_logfile_size | Limits the size of one log file in MB | -1 (No limit) |
| max_logfile_lifetime | Limits the time a log file can live (except the currently used one) | -1 (No limit) |
| out | The standard output TextIO. | stdout |
| err | The standard error TextIO. If set to None 'out' will be used | stderr |
| use_caller_name | Use the caller's name in consol logging instead of the level | False |
| use_file_names | Use the file name whe using the caller name or not | True |
| use_log_name | Use the log file name to differenciate between multiple loggers on console | False |
| level_only_valid_for_console | Setting this will log the unwanted levels but will not display them in console | False |
| log_disabled | Disables logging to everywhere, and disables warning about silent logging | False |
| enable_file | Enables log file if a name is provided | True |
| enable_color | Enables coloring of the console log. If NO_COLOR environment variable is set, this will be ignored | True |
Additional info
The consol logging uses colors for the different levels to be more recognizable at a glance. It also supports headers, after which it indents the logs to add some structure.
TRACE
#00E6E5
DEBUG
#E600E5
INFO
#0BFF00
WARNING
#FEFF00
ERROR | EXCEPTION
#FF0000
HEADER
#4182B7
Available methods
get_buffer()
Return sthe buffer's content in a list, if the logger is set to use buffers.
flush_buffer()
Forces a writes of the buffer to the log file.
set_level(level: LEVEL)
Sets the loggers leve to be used from this point onwards.
set_folder(folder: str)
Sets the loggers folder to be used from thi point. It also runs the basic validation on the inputed path.
log(level: LEVEL, data: str, counter: str | None = str(datetime.now()), end: str = "\n", only_console: bool = False)
Creates a log entry with the given level.
The 'only_console' argument will remove the log from logfile, and only display the 'data' with the correct coloring.
header(data: str, counter: str | None = str(datetime.now()), end: str = "\n", only_console: bool = False)
Creates a HEADER level log entry.
heartbeat(self, data: str, counter: str | None = str(datetime.now()), end: str = "\n")
Creates a TRACE level log entry. Will only show up in console.
trace(data: str, counter: str | None = str(datetime.now()), end: str = "\n", only_console: bool = False)
Creates a TRACE level log entry.
debug(data: str, counter: str | None = str(datetime.now()), end: str = "\n", only_console: bool = False)
Creates a DEBUG level log entry.
warning(data: str, counter: str | None = str(datetime.now()), end: str = "\n", only_console: bool = False)
Creates a WARNING level log entry.
info(data: str, counter: str | None = str(datetime.now()), end: str = "\n", only_console: bool = False)
Creates a INFO level log entry.
error(data: str, exception: Exception | None = None counter: str | None = str(datetime.now()), end: str = "\n", only_console: bool = False)
Creates a ERROR level log entry.
exception(exception: Exception)
Creates an EXCEPTION level log entry. This will only print the exception as a traceback.
Metadata
Release files for smdb-logger 1.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| smdb_logger-1.6.0.tar.gz | 11.2 kB | Without provenance | Details for smdb_logger-1.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| smdb_logger-1.6.0-py3-none-any.whl | Python 3 | none | any | Details for smdb_logger-1.6.0-py3-none-any.whl |
Total release size: 21.9 kB
Release files / smdb_logger-1.6.0.tar.gz
| Download URL | smdb_logger-1.6.0.tar.gz |
|---|---|
| Size | 11.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e6e64064b6e6eb87ff9c7773a97770c8f4aaf02f1f834e30131d79238971c19f
|
|
BLAKE2b-256 checksum How to use checksums |
e9b3adcaef8517fe5e01670f45df499cc9ebcd579e95a8b130a810abfce257e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / smdb_logger-1.6.0-py3-none-any.whl
| Download URL | smdb_logger-1.6.0-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0611cd9790f34ba8a70ba226a5d35de269c240ffc4ea8417f8e96e46c0104c46
|
|
BLAKE2b-256 checksum How to use checksums |
5200329f96f2512293208fdd7a2a22c550b4618e58160c1a079ac7d4145d1085
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Security for smdb-logger 1.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.