pylogg


Namepylogg JSON
Version 0.4.1 PyPI version JSON
download
home_pageNone
SummaryLogging and YAML-based configuration modules in Python.
upload_time2024-09-10 19:02:58
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/a4/a6/cae7cf4b3e2b57e8f986937b3b320de999af234049645febdb7979ad7459/pylogg-0.4.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.4.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": "3e0d40e65ffb1e7c2ec6eb900ed7cfe4ab654fe5ca22d5d07c846126e8945f06",
                "md5": "1c0ae24a07eeb70630ae123d8792acce",
                "sha256": "380aa683120ab7488fa231d40472ba747bfcfe7d9fe8ef035681b3586b0a1b9d"
            },
            "downloads": -1,
            "filename": "pylogg-0.4.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1c0ae24a07eeb70630ae123d8792acce",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 14791,
            "upload_time": "2024-09-10T19:02:57",
            "upload_time_iso_8601": "2024-09-10T19:02:57.440940Z",
            "url": "https://files.pythonhosted.org/packages/3e/0d/40e65ffb1e7c2ec6eb900ed7cfe4ab654fe5ca22d5d07c846126e8945f06/pylogg-0.4.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a4a6cae7cf4b3e2b57e8f986937b3b320de999af234049645febdb7979ad7459",
                "md5": "a601a58c9b9ffa22fd727d29599bec99",
                "sha256": "162daaebb5b9d5633eb0b8b7fe3d677dacc3da523f49f015ed05d2cd8206074f"
            },
            "downloads": -1,
            "filename": "pylogg-0.4.1.tar.gz",
            "has_sig": false,
            "md5_digest": "a601a58c9b9ffa22fd727d29599bec99",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 15513,
            "upload_time": "2024-09-10T19:02:58",
            "upload_time_iso_8601": "2024-09-10T19:02:58.823131Z",
            "url": "https://files.pythonhosted.org/packages/a4/a6/cae7cf4b3e2b57e8f986937b3b320de999af234049645febdb7979ad7459/pylogg-0.4.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-10 19:02:58",
    "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.32473s