Name | pylogg JSON |
Version |
0.3.1
JSON |
| download |
home_page | None |
Summary | Logging and YAML-based configuration modules in Python. |
upload_time | 2024-04-17 17:35:23 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | None |
keywords |
logging
development
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# PyLogg
Logging and YAML-based configuration modules in Python.
## Installation
You can install this package from PyPI with `pip`.
```sh
pip install -U pylogg
```
## Usage
Set up the logger in the main script.
```python
import pylogg
pylogg.init(pylogg.Level.TRACE, colored=False)
pylogg.info("Hello world.")
```
Update individual settings if needed. These settings will override the settings set using `pylogg.get()` instances.
```python
import pylogg as log
# Set output file
log.setFile(open("test.log", "w+"))
# Show date and times on console
log.setConsoleTimes(show=True)
# Save date and times to file
log.setFileTimes(show=True)
# Set global logging level
log.setLevel(log.DEBUG)
# Override the level of a named sub-logger
log.setLoggerLevel('module', log.INFO)
# Use
log.info("Hello world")
# Close the log file
log.close()
```
Use sub-logger from the modules.
```python
import time
import pylogg
# Create or get a named sub-logger.
log = pylogg.get(__name__)
# Use
def run():
log.Trace("Running module ...")
# Support for f strings.
log.Debug("2 + 2 = {} ({answer})", 2 + 2, answer=True)
def timing():
# Get the timer instance
t1 = log.Info("Started process ...")
# long process
time.sleep(2)
# Call timer.done() to log elapsed time.
t1.done("Process completed.")
```
**Note:** Full logg package must be imported. Use `import pylogg`,
do not use `from pylogg import get`.
See the [examples](https://github.com/akhlakm/python-logg/tree/main/examples)
for more details.
## Development
```sh
# Create a fork and clone the git repo.
git clone https://github.com/akhlakm/python-logg.git
cd python-logg
# Install dev requirements.
pip install -e .[dev]
# Install pre-commit git hooks.
pre-commit install
# Make changes and commit.
# Bump the version
./make.sh bump
# Publish new tag.
./make.sh publish
```
## About
LICENSE MIT Copyright 2024 Akhlak Mahmood
Raw data
{
"_id": null,
"home_page": null,
"name": "pylogg",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "logging, development",
"author": null,
"author_email": "Akhlak Mahmood <akhlakm@gatech.edu>",
"download_url": "https://files.pythonhosted.org/packages/70/23/18bac1dbd74550140f46c7d5059ffbf529024db88381417dc907763ca964/pylogg-0.3.1.tar.gz",
"platform": null,
"description": "# PyLogg\nLogging and YAML-based configuration modules in Python.\n\n## Installation\nYou can install this package from PyPI with `pip`.\n\n```sh\npip install -U pylogg\n```\n\n## Usage\nSet up the logger in the main script.\n\n```python\nimport pylogg\n\npylogg.init(pylogg.Level.TRACE, colored=False)\npylogg.info(\"Hello world.\")\n```\n\nUpdate individual settings if needed. These settings will override the settings set using `pylogg.get()` instances.\n\n```python\nimport pylogg as log\n\n# Set output file\nlog.setFile(open(\"test.log\", \"w+\"))\n\n# Show date and times on console\nlog.setConsoleTimes(show=True)\n\n# Save date and times to file\nlog.setFileTimes(show=True)\n\n# Set global logging level\nlog.setLevel(log.DEBUG)\n\n# Override the level of a named sub-logger\nlog.setLoggerLevel('module', log.INFO)\n\n# Use\nlog.info(\"Hello world\")\n\n# Close the log file\nlog.close()\n```\n\nUse sub-logger from the modules.\n```python\nimport time\nimport pylogg\n\n# Create or get a named sub-logger.\nlog = pylogg.get(__name__)\n\n# Use\ndef run():\n log.Trace(\"Running module ...\")\n\n # Support for f strings.\n log.Debug(\"2 + 2 = {} ({answer})\", 2 + 2, answer=True)\n\n\ndef timing():\n # Get the timer instance\n t1 = log.Info(\"Started process ...\")\n\n # long process\n time.sleep(2)\n\n # Call timer.done() to log elapsed time.\n t1.done(\"Process completed.\")\n\n```\n\n**Note:** Full logg package must be imported. Use `import pylogg`,\ndo not use `from pylogg import get`.\n\nSee the [examples](https://github.com/akhlakm/python-logg/tree/main/examples)\nfor more details.\n\n## Development\n```sh\n# Create a fork and clone the git repo.\ngit clone https://github.com/akhlakm/python-logg.git\ncd python-logg\n\n# Install dev requirements.\npip install -e .[dev]\n\n# Install pre-commit git hooks.\npre-commit install\n\n# Make changes and commit.\n\n# Bump the version\n./make.sh bump\n\n# Publish new tag.\n./make.sh publish\n```\n\n## About\nLICENSE MIT Copyright 2024 Akhlak Mahmood\n",
"bugtrack_url": null,
"license": null,
"summary": "Logging and YAML-based configuration modules in Python.",
"version": "0.3.1",
"project_urls": {
"Bug Tracker": "https://github.com/akhlakm/python-logg/issues",
"Homepage": "https://github.com/akhlakm/python-logg"
},
"split_keywords": [
"logging",
" development"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7a992dea7ea7067355ef3995fb5d264c61c5381aa0904ec7ed35c5e40f6e8df5",
"md5": "bf60b269f4be7fee56dd81d5fe9e90db",
"sha256": "f3c905533631614defdce8e8e7da504af64ac3f60db69cefa713927fd207f4f4"
},
"downloads": -1,
"filename": "pylogg-0.3.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "bf60b269f4be7fee56dd81d5fe9e90db",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 14637,
"upload_time": "2024-04-17T17:35:21",
"upload_time_iso_8601": "2024-04-17T17:35:21.779416Z",
"url": "https://files.pythonhosted.org/packages/7a/99/2dea7ea7067355ef3995fb5d264c61c5381aa0904ec7ed35c5e40f6e8df5/pylogg-0.3.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "702318bac1dbd74550140f46c7d5059ffbf529024db88381417dc907763ca964",
"md5": "6e149ce69e5ae2d9d9dae6b9172f24f1",
"sha256": "c714e08567c22f3a37786b2b65d18fa962e652f9aebfe0ebd9b7edabb4ab930b"
},
"downloads": -1,
"filename": "pylogg-0.3.1.tar.gz",
"has_sig": false,
"md5_digest": "6e149ce69e5ae2d9d9dae6b9172f24f1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 15377,
"upload_time": "2024-04-17T17:35:23",
"upload_time_iso_8601": "2024-04-17T17:35:23.434354Z",
"url": "https://files.pythonhosted.org/packages/70/23/18bac1dbd74550140f46c7d5059ffbf529024db88381417dc907763ca964/pylogg-0.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-17 17:35:23",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "akhlakm",
"github_project": "python-logg",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pylogg"
}