<div align="center">
# Sawdust
An even cuter little logger.
[![Build Status](https://github.com/nwithan8/sawdust/workflows/build/badge.svg)](https://github.com/nwithan8/sawdust/actions)
[![Coverage Status](https://coveralls.io/repos/github/nwithan8/sawdust/badge.svg?branch=main)](https://coveralls.io/github/nwithan8/sawdust?branch=main)
[![PyPi](https://img.shields.io/pypi/v/woodchips)](https://pypi.org/project/woodchips)
[![Licence](https://img.shields.io/github/license/nwithan8/sawdust)](LICENSE)
<img src="https://raw.githubusercontent.com/nwithan8/assets/main/src/sawdust/showcase.png" alt="Showcase">
</div>
> > Aren't logs just a bunch of woodchips?
>
> Aren't woodchips just a bunch of sawdust?
Sawdust is a re-implementation (improvement?) of [Woodchips](https://github.com/Justintime50/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
```bash
# Install tool
pip3 install sawdust
# Install locally
make install
```
## Usage
Create a `Logger` instance and start chipping/logging/dusting away!
```python
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.CRITICAL`
- `LogLevel.FATAL` (alias for `LogLevel.CRITICAL`, don't use this)
- `LogLevel.ERROR`
- `LogLevel.WARNING`
- `LogLevel.WARN` (alias for `LogLevel.WARNING`, don't use this)
- `LogLevel.INFO`
- `LogLevel.DEBUG`
- `LogLevel.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 log
- `include_level()` - Include the log level in the log
- `include_calling_function()` - Include the calling function in the log
- `include_logger_name()` - Include the logger name in the log
- `include_process_name()` - Include the process name in the log
Raw data
{
"_id": null,
"home_page": "https://github.com/nwithan8/sawdust",
"name": "sawdust",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7, <4",
"maintainer_email": "",
"keywords": "logging,log,logger,logs,log to file,log to console",
"author": "Nate Harris",
"author_email": "n8gr8gbln@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/ab/f7/e180f8d4b1d13ef23829bf9c06de5c329c57cc9313739d9c2d40d45b6190/sawdust-0.1.0.tar.gz",
"platform": null,
"description": "<div align=\"center\">\n\n# Sawdust\n\nAn even cuter little logger.\n\n[![Build Status](https://github.com/nwithan8/sawdust/workflows/build/badge.svg)](https://github.com/nwithan8/sawdust/actions)\n[![Coverage Status](https://coveralls.io/repos/github/nwithan8/sawdust/badge.svg?branch=main)](https://coveralls.io/github/nwithan8/sawdust?branch=main)\n[![PyPi](https://img.shields.io/pypi/v/woodchips)](https://pypi.org/project/woodchips)\n[![Licence](https://img.shields.io/github/license/nwithan8/sawdust)](LICENSE)\n\n<img src=\"https://raw.githubusercontent.com/nwithan8/assets/main/src/sawdust/showcase.png\" alt=\"Showcase\">\n\n</div>\n\n> > Aren't logs just a bunch of woodchips?\n>\n> Aren't woodchips just a bunch of sawdust?\n\nSawdust is a re-implementation (improvement?) of [Woodchips](https://github.com/Justintime50/woodchips). This is largely\na joke (I know the Woodchips developer), but also a product of my inability to be satisfied with a product that does 90%\nof what I expect, as well as my inability to not needlessly refactor things.\n\n## Install\n\n```bash\n# Install tool\npip3 install sawdust\n\n# Install locally\nmake install\n```\n\n## Usage\n\nCreate a `Logger` instance and start chipping/logging/dusting away!\n\n```python\nimport sawdust\n\n# Setup a new logger instance\nlogger = sawdust.Logger(\n name='my_logger_name', # The name of your logger instance, often will be `__name__`\n level=sawdust.LogLevel.INFO, # The log level you want to use\n)\n\n# Setup console logging\nconsole_log_msg_format = sawdust.LogFormat() # Only include the message in the console log\nlogger.log_to_console(level=sawdust.LogLevel.WARNING, msg_format=console_log_msg_format)\n\n# Setup file logging\nfile_log_msg_format = sawdust.LogFormat().include_time().include_level().include_calling_function() # Include the time, level, and calling function in the file log\nlogger.log_to_file(\n folder_path='path/to/log_files',\n file_name='my_log_file.log',\n level=sawdust.LogLevel.DEBUG,\n msg_format=file_log_msg_format,\n log_size=200000, # Size of a single file in bytes\n num_of_logs=5, # Number of log files to keep in the rotation\n)\n\n# Log a message (will be logged to console and a file based on the example from above)\nlogger.info('This is how to setup Sawdust!')\n\n# Log a message without keeping a reference to the logger\nsawdust.info('This is how to setup Sawdust!', specific_logger='my_logger_name')\n```\n\n### Available Log Levels\n\n- `LogLevel.CRITICAL`\n- `LogLevel.FATAL` (alias for `LogLevel.CRITICAL`, don't use this)\n- `LogLevel.ERROR`\n- `LogLevel.WARNING`\n- `LogLevel.WARN` (alias for `LogLevel.WARNING`, don't use this)\n- `LogLevel.INFO`\n- `LogLevel.DEBUG`\n- `LogLevel.NOTSET`\n\n### Available Log Formats\n\nLog elements will always appear in this order, with elements enabled or disabled accordingly:\n\n`LOGGER_NAME - TIMESTAMP - LOG_LEVEL - PROCESS - FUNCTION: MESSAGE`\n\n- `include_time()` - Include the time in the log\n- `include_level()` - Include the log level in the log\n- `include_calling_function()` - Include the calling function in the log\n- `include_logger_name()` - Include the logger name in the log\n- `include_process_name()` - Include the process name in the log\n",
"bugtrack_url": null,
"license": "GNU General Public License v3 (GPLv3)",
"summary": "A simple logging implementation in Python",
"version": "0.1.0",
"project_urls": {
"Download": "https://github.com/nwithan8/sawdust/archive/refs/tags/0.1.0.tar.gz",
"Homepage": "https://github.com/nwithan8/sawdust"
},
"split_keywords": [
"logging",
"log",
"logger",
"logs",
"log to file",
"log to console"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b8a4c6c694b544512fe4779413adc7d9421dc4ef4251848ae82eca5d75568bb2",
"md5": "6114ef3d18168cc595fdc46fd2dbb77b",
"sha256": "938f30c745f76ce954f8a287a597ddb457cb3e53326b5b0c2f94e7942ef30a60"
},
"downloads": -1,
"filename": "sawdust-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6114ef3d18168cc595fdc46fd2dbb77b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7, <4",
"size": 6350,
"upload_time": "2024-01-08T22:52:22",
"upload_time_iso_8601": "2024-01-08T22:52:22.249362Z",
"url": "https://files.pythonhosted.org/packages/b8/a4/c6c694b544512fe4779413adc7d9421dc4ef4251848ae82eca5d75568bb2/sawdust-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "abf7e180f8d4b1d13ef23829bf9c06de5c329c57cc9313739d9c2d40d45b6190",
"md5": "5e13e31c7172df36cf21683ae4a4672c",
"sha256": "ae154d7602b57a7b88c03b2447ab4232986d87ddaec8740860a8abab7274f9c0"
},
"downloads": -1,
"filename": "sawdust-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "5e13e31c7172df36cf21683ae4a4672c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7, <4",
"size": 8341,
"upload_time": "2024-01-08T22:52:24",
"upload_time_iso_8601": "2024-01-08T22:52:24.109613Z",
"url": "https://files.pythonhosted.org/packages/ab/f7/e180f8d4b1d13ef23829bf9c06de5c329c57cc9313739d9c2d40d45b6190/sawdust-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-08 22:52:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "nwithan8",
"github_project": "sawdust",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"requirements": [],
"lcname": "sawdust"
}