Simple, colorful terminal logs and logfiles.
# Installation
```bash
pip install agentlogger
```
## Quickstart
Here is a quick overview of how you can use Agent Logger in your project:
```python
from agentlogger import log, print_header, write_to_file
# Print a styled log message to the console
log('Test message', type='info')
# ╭─ (info) agentlogger ─╮
# │ Test message │
# ╰──────────────────────╯
# Display a big styled header in the console
print_header('Test header', font='slant', color='blue')
# ______ __ __ __
# /_ __/__ _____/ /_ / /_ ___ ____ _____/ /__ _____
# / / / _ \/ ___/ __/ / __ \/ _ \/ __ `/ __ / _ \/ ___/
# / / / __(__ ) /_ / / / / __/ /_/ / /_/ / __/ /
# /_/ \___/____/\__/ /_/ /_/\___/\__,_/\__,_/\___/_/
# Write a log message to a file
write_to_file('More log content', source='tests.py', type='test_write_to_file')
# ======================== tests.py: test_write_to_file ========================
# More log content
# ================================================================================
```
## Documentation
Here is an overview of the available functions:
### `log(content, source=None, title="agentlogger", type="info", color="blue", type_colors=DEFAULT_TYPE_COLORS, expand=True, panel=True, log=True)`
This function is used to create an event with provided metadata and saves it to the event log file.
#### Colors
The available log color options are: black, red, green, yellow, blue, magenta, cyan and white. The color of your log will be determined by the type of the log, if the type log is in the dictionary. If the type is not in the log, it will look at the "color" argument. You can also provide your own type dictionary.
#### Arguments:
- `content`: Content of the event.
- `source`: Source of the event, e.g. a function name. Defaults to None.
- `title`: Title of the event. Defaults to "agentlogger".
- `type`: Type of the event. Defaults to "info".
- `type_colors`: Dictionary with event types as keys and colors as values. Defaults to a predefined dictionary.
- `expand`: Determines if the output should be within a Panel. Defaults to True.
- `panel`: Determines if the output should be displayed inside a bordered box panel. Defaults to True.
- `log`: Determines if the output should be logged. Defaults to True.
### `print_header(text="agentlogger", font="slant", color="yellow", width=console.width, justify="left")`
This function displays a header with the provided text and color.
#### Header Fonts
The header fonts come from the FIGlet library. You can find a list of available fonts [here](http://www.figlet.org/fontdb.cgi).
#### Colors
The color options are the same as the ones used in the `log` function: black, red, green, yellow, blue, magenta, cyan and white.
#### Arguments:
- `text`: Text to be displayed in the header. Defaults to "agentlogger".
- `font`: Font to be used in the header. Defaults to "slant".
- `color`: Color to be used in the header. Defaults to "yellow".
- `width`: Width of the console. Defaults to the console width.
- `justify`: Justification of the text in the header. Defaults to "left".
### `write_to_file(content, source=None, type=None, filename="events.log", separator_width=80)`
This function writes content to the event log file.
#### Arguments:
- `content`: Content to be written in the log file.
- `source`: Source of the event, e.g. a function name. Defaults to None.
- `type`: Type of the event. Defaults to None.
- `filename`: Name of the file where the content will be written. Defaults to "events.log".
- `separator_width`: Width of the separator. Defaults to 80.
#### Default Type Colors
Some log types are mapped to colors by default. You can also create your own dictionary and pass it to the `log` function. The default dictionary is:
```
unknown: white
system: magenta
info: blue
warning: yellow
success: green
error: red
start: green
stop: red
pause: yellow
epoch: white
summary: cyan
reasoning: cyan
action: green
prompt: cyan
```
## Examples
Here are a few examples of how you can use this library:
```python
# Log an info message to the console
log('Application started', type='info')
# Log a warning message to the console
log('Low on disk space', type='warning')
# Log an error message to the console without a panel
log('Failed to connect to the database', type='error', panel=False)
# Display a big styled header
print_header('Welcome to My Application')
# Write a log message to a file
write_to_file('User logged in', source='auth.py', type='info')
```
## Tests
You can run tests using pytest:
```bash
pytest test.py
```
# Contributions Welcome
If you like this library and want to contribute in any way, please feel free to submit a PR and it will be reviewed. The goal of this project is simplicity and accessibility using plain language and sane defaults, so please keep that in mind when submitting a PR.
Raw data
{
"_id": null,
"home_page": "https://github.com/AutonomousResearchGroup/agentlogger",
"name": "agentlogger",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Moon",
"author_email": "shawmakesmagic@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/fa/36/3626ce002c0f7dc0d9a7e94fd744307bd4e96204794006f86e72777c1468/agentlogger-0.1.2.tar.gz",
"platform": null,
"description": "\nSimple, colorful terminal logs and logfiles.\n\n\n# Installation\n\n```bash\npip install agentlogger\n```\n\n## Quickstart\n\nHere is a quick overview of how you can use Agent Logger in your project:\n\n```python\nfrom agentlogger import log, print_header, write_to_file\n\n# Print a styled log message to the console\nlog('Test message', type='info')\n# \u256d\u2500 (info) agentlogger \u2500\u256e\n# \u2502 Test message \u2502\n# \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n\n# Display a big styled header in the console\nprint_header('Test header', font='slant', color='blue')\n# ______ __ __ __\n# /_ __/__ _____/ /_ / /_ ___ ____ _____/ /__ _____\n# / / / _ \\/ ___/ __/ / __ \\/ _ \\/ __ `/ __ / _ \\/ ___/\n# / / / __(__ ) /_ / / / / __/ /_/ / /_/ / __/ /\n# /_/ \\___/____/\\__/ /_/ /_/\\___/\\__,_/\\__,_/\\___/_/\n\n\n# Write a log message to a file\nwrite_to_file('More log content', source='tests.py', type='test_write_to_file')\n# ======================== tests.py: test_write_to_file ========================\n\n# More log content\n\n# ================================================================================\n\n```\n\n## Documentation\n\nHere is an overview of the available functions:\n\n### `log(content, source=None, title=\"agentlogger\", type=\"info\", color=\"blue\", type_colors=DEFAULT_TYPE_COLORS, expand=True, panel=True, log=True)`\n\nThis function is used to create an event with provided metadata and saves it to the event log file.\n\n#### Colors\n\nThe available log color options are: black, red, green, yellow, blue, magenta, cyan and white. The color of your log will be determined by the type of the log, if the type log is in the dictionary. If the type is not in the log, it will look at the \"color\" argument. You can also provide your own type dictionary.\n\n#### Arguments:\n\n- `content`: Content of the event.\n- `source`: Source of the event, e.g. a function name. Defaults to None.\n- `title`: Title of the event. Defaults to \"agentlogger\".\n- `type`: Type of the event. Defaults to \"info\".\n- `type_colors`: Dictionary with event types as keys and colors as values. Defaults to a predefined dictionary.\n- `expand`: Determines if the output should be within a Panel. Defaults to True.\n- `panel`: Determines if the output should be displayed inside a bordered box panel. Defaults to True.\n- `log`: Determines if the output should be logged. Defaults to True.\n\n### `print_header(text=\"agentlogger\", font=\"slant\", color=\"yellow\", width=console.width, justify=\"left\")`\n\nThis function displays a header with the provided text and color.\n\n#### Header Fonts\n\nThe header fonts come from the FIGlet library. You can find a list of available fonts [here](http://www.figlet.org/fontdb.cgi).\n\n#### Colors\n\nThe color options are the same as the ones used in the `log` function: black, red, green, yellow, blue, magenta, cyan and white.\n\n#### Arguments:\n\n- `text`: Text to be displayed in the header. Defaults to \"agentlogger\".\n- `font`: Font to be used in the header. Defaults to \"slant\".\n- `color`: Color to be used in the header. Defaults to \"yellow\".\n- `width`: Width of the console. Defaults to the console width.\n- `justify`: Justification of the text in the header. Defaults to \"left\".\n\n### `write_to_file(content, source=None, type=None, filename=\"events.log\", separator_width=80)`\n\nThis function writes content to the event log file.\n\n#### Arguments:\n\n- `content`: Content to be written in the log file.\n- `source`: Source of the event, e.g. a function name. Defaults to None.\n- `type`: Type of the event. Defaults to None.\n- `filename`: Name of the file where the content will be written. Defaults to \"events.log\".\n- `separator_width`: Width of the separator. Defaults to 80.\n\n#### Default Type Colors\n\nSome log types are mapped to colors by default. You can also create your own dictionary and pass it to the `log` function. The default dictionary is:\n\n```\nunknown: white\nsystem: magenta\ninfo: blue\nwarning: yellow\nsuccess: green\nerror: red\nstart: green\nstop: red\npause: yellow\nepoch: white\nsummary: cyan\nreasoning: cyan\naction: green\nprompt: cyan\n```\n\n## Examples\n\nHere are a few examples of how you can use this library:\n\n```python\n# Log an info message to the console\nlog('Application started', type='info')\n\n# Log a warning message to the console\nlog('Low on disk space', type='warning')\n\n# Log an error message to the console without a panel\nlog('Failed to connect to the database', type='error', panel=False)\n\n# Display a big styled header\nprint_header('Welcome to My Application')\n\n# Write a log message to a file\nwrite_to_file('User logged in', source='auth.py', type='info')\n```\n\n## Tests\n\nYou can run tests using pytest:\n\n```bash\npytest test.py\n```\n\n# Contributions Welcome\n\nIf you like this library and want to contribute in any way, please feel free to submit a PR and it will be reviewed. The goal of this project is simplicity and accessibility using plain language and sane defaults, so please keep that in mind when submitting a PR.\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Simple, colorful debug logs and logfiles.",
"version": "0.1.2",
"project_urls": {
"Homepage": "https://github.com/AutonomousResearchGroup/agentlogger"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "931aa1e80755cc9ef3aedfcec4a624635f5912424769a81b4647c6d59a77a9ef",
"md5": "daa38d934f0dfbf74cd919ea69837d03",
"sha256": "11603262b11c97a0d61b134cda7aedef9299e0f86e573af1fdce5be88f598515"
},
"downloads": -1,
"filename": "agentlogger-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "daa38d934f0dfbf74cd919ea69837d03",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 6150,
"upload_time": "2023-07-22T06:58:58",
"upload_time_iso_8601": "2023-07-22T06:58:58.859600Z",
"url": "https://files.pythonhosted.org/packages/93/1a/a1e80755cc9ef3aedfcec4a624635f5912424769a81b4647c6d59a77a9ef/agentlogger-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fa363626ce002c0f7dc0d9a7e94fd744307bd4e96204794006f86e72777c1468",
"md5": "d3be5b327aa5f1e51935e4a7069dd89d",
"sha256": "5457dde6a7c3d75521cefa27c88967a4fc926ca1ce0e616a2ecbd06d4a874f13"
},
"downloads": -1,
"filename": "agentlogger-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "d3be5b327aa5f1e51935e4a7069dd89d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5650,
"upload_time": "2023-07-22T06:59:00",
"upload_time_iso_8601": "2023-07-22T06:59:00.415335Z",
"url": "https://files.pythonhosted.org/packages/fa/36/3626ce002c0f7dc0d9a7e94fd744307bd4e96204794006f86e72777c1468/agentlogger-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-22 06:59:00",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "AutonomousResearchGroup",
"github_project": "agentlogger",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "agentlogger"
}