pylogg


Namepylogg JSON
Version 0.3.3 PyPI version JSON
download
home_pageNone
SummaryLogging and YAML-based configuration modules in Python.
upload_time2024-05-11 17:18:14
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
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/8e/38/23e4f050b0f2814aeb3032661020abcda9b10afeb528c097c67a2f2d855a/pylogg-0.3.3.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.3",
    "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": "93761dc95d497f8f72c1b98b08e4ffe203936d4b2e887d2169cac0510beb9e3c",
                "md5": "6201c1a7199385f5e038429bfe4ca371",
                "sha256": "452f86c8ab1033bb7cd966354b9402378c13044274369cac4dbabe2c0c4f1f8a"
            },
            "downloads": -1,
            "filename": "pylogg-0.3.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6201c1a7199385f5e038429bfe4ca371",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 14670,
            "upload_time": "2024-05-11T17:18:12",
            "upload_time_iso_8601": "2024-05-11T17:18:12.590462Z",
            "url": "https://files.pythonhosted.org/packages/93/76/1dc95d497f8f72c1b98b08e4ffe203936d4b2e887d2169cac0510beb9e3c/pylogg-0.3.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8e3823e4f050b0f2814aeb3032661020abcda9b10afeb528c097c67a2f2d855a",
                "md5": "60f87c5f066c1a2871ef00fdb49345ea",
                "sha256": "eb380af5e40032eb120c9906eee4622b410d5ed9ebe5f493c527849c35e82ef2"
            },
            "downloads": -1,
            "filename": "pylogg-0.3.3.tar.gz",
            "has_sig": false,
            "md5_digest": "60f87c5f066c1a2871ef00fdb49345ea",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 15403,
            "upload_time": "2024-05-11T17:18:14",
            "upload_time_iso_8601": "2024-05-11T17:18:14.483373Z",
            "url": "https://files.pythonhosted.org/packages/8e/38/23e4f050b0f2814aeb3032661020abcda9b10afeb528c097c67a2f2d855a/pylogg-0.3.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-11 17:18:14",
    "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"
}
        
Elapsed time: 0.33613s