Aren't logs just a bunch of woodchips?
Aren't woodchips just a bunch of sawdust?
Sawdust is a re-implementation (improvement?) of Woodchips. This is largely a joke (I know the Woodchips developer), but also a product of my inability to be satisfied with a product that does 90% of what I expect, as well as my inability to not needlessly refactor things.
Install
# Install tool
pip3 install sawdust
# Install locally
make install
Usage
Create a Logger instance and start chipping/logging/dusting away!
import sawdust
# Setup a new logger instance
logger = sawdust.Logger(
name='my_logger_name', # The name of your logger instance, often will be `__name__`
level=sawdust.LogLevel.INFO, # The log level you want to use
)
# Setup console logging
console_log_msg_format = sawdust.LogFormat() # Only include the message in the console log
logger.log_to_console(level=sawdust.LogLevel.WARNING, msg_format=console_log_msg_format)
# Setup file logging
file_log_msg_format = sawdust.LogFormat().include_time().include_level().include_calling_function() # Include the time, level, and calling function in the file log
logger.log_to_file(
folder_path='path/to/log_files',
file_name='my_log_file.log',
level=sawdust.LogLevel.DEBUG,
msg_format=file_log_msg_format,
log_size=200000, # Size of a single file in bytes
num_of_logs=5, # Number of log files to keep in the rotation
)
# Log a message (will be logged to console and a file based on the example from above)
logger.info('This is how to setup Sawdust!')
# Log a message without keeping a reference to the logger
sawdust.info('This is how to setup Sawdust!', specific_logger='my_logger_name')
Available Log Levels
LogLevel.CRITICALLogLevel.FATAL(alias forLogLevel.CRITICAL, don't use this)LogLevel.ERRORLogLevel.WARNINGLogLevel.WARN(alias forLogLevel.WARNING, don't use this)LogLevel.INFOLogLevel.DEBUGLogLevel.NOTSET
Available Log Formats
Log elements will always appear in this order, with elements enabled or disabled accordingly:
LOGGER_NAME - TIMESTAMP - LOG_LEVEL - PROCESS - FUNCTION: MESSAGE
include_time()- Include the time in the loginclude_level()- Include the log level in the loginclude_calling_function()- Include the calling function in the loginclude_logger_name()- Include the logger name in the loginclude_process_name()- Include the process name in the log
Metadata
Release files for sawdust 0.1.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 | |
|---|---|---|---|
| sawdust-0.1.0.tar.gz | 8.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sawdust-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.7 kB
Release files / sawdust-0.1.0.tar.gz
| Download URL | sawdust-0.1.0.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ae154d7602b57a7b88c03b2447ab4232986d87ddaec8740860a8abab7274f9c0
|
|
BLAKE2b-256 checksum How to use checksums |
abf7e180f8d4b1d13ef23829bf9c06de5c329c57cc9313739d9c2d40d45b6190
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Release files / sawdust-0.1.0-py3-none-any.whl
| Download URL | sawdust-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
938f30c745f76ce954f8a287a597ddb457cb3e53326b5b0c2f94e7942ef30a60
|
|
BLAKE2b-256 checksum How to use checksums |
b8a4c6c694b544512fe4779413adc7d9421dc4ef4251848ae82eca5d75568bb2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|