logging-handler


Namelogging-handler JSON
Version 1.0.7 PyPI version JSON
download
home_page
SummaryPython Library to quickly create logging handlers
upload_time2023-07-26 21:16:51
maintainer
docs_urlNone
author
requires_python>=3.6
license
keywords logging syslog
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python Logging Helper
Python library to quickly create logging handlers.  Supports logging to the console as well as to file using a syslog style output format.

## Installation
The package is available on PyPi or can be installed manually using the why/tar.gz file attached to the release.

    pip3 install logging_helper

## Introduction
This library provides a function called "create_logger" that will create and return a logging handler that can be used in your application.  The "create_logger" function can be passed a series of different settings to manipulate the default Python logging handler.

## Examples

    >>> from logging_helper import create_logger
    >>> logger = create_logger(console=True)
    >>> logger.warning('test')
    2022-11-09 16:09:21,210 - root - WARNING - test
    >>>
    >>> logger.debug('test debug')
    >>> ### Note no output! Default is set to WARNING and above
    >>>
    >>> logger = create_logger(console=True, console_level='DEBUG')
    >>> logger.debug('test debug')
    2022-11-09 16:11:13,268 - root - DEBUG - test debug
    >>> 
    >>> logger2 = create_logger(console=True, console_level='DEBUG', name='log2')
    >>> logger2.info('logger2 info!')
    2022-11-09 16:12:23,358 - log2 - INFO - logger2 info!
    >>> logger.info('logger1 info!')
    2022-11-09 16:12:35,510 - root - INFO - logger1 info!

In the examples above, you can create multiple loggers with different names.  If a name is not provided, the logger takes on the 'root' logger for Python.  Replacing the 'root' logger will replace the default logging in python and affects other modules.  If you set your logger to debug and start seeing messages from other modules you weren't expecting, provide a name value to your logger.

## Parameters
| Parameter | Default | Description |
| --------- | ------- | ----------- |
| console_level | 'INFO' (str) | Set the logging level for the console
| console | True (bool) | Enable / Disable logging to the console
| log_file | '' (str) | Set the file to log to (blank means none)
| file_level | 'WARNING' (str) | Set the logging level for the file
| file_mode | 'a' (str) | Feeds into the file mode 'a' for append, 'w' for overwrite
| name | '' (str) | Name for the logger. Blank will replace the root logging handler
| syslog | False (bool) | Send messages to the local system logger
| syslog_script_name | '' (str) | Name to include when using the local system logger
| log_file_vars | [] (list) | list of variables that can be used to create the log file names
| log_file_retention_days | 0 (int) | Specify the max number of days to retain the log files
| propagate | False (bool) | If set to true, the named loggers will also be processed by the root logger.  Generally leave false

## Release Notes

v1.0.2  
        - Moved console level to the 1st parameter.  Make it quicker and easier to create a console logger
        - Chaned default console level to INFO from WARNING.  This is what I typically end up using anyway
        - Updated the home page to our new logging_handler page:  https://www.learningtopi.com/python-modules-applications/python_logging_handler/
        - Allow passing static values DEBUG, INFO, WARNING, ERROR and CRITICAL from the logging module (or you may import from this library)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "logging-handler",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "logging,syslog",
    "author": "",
    "author_email": "Thomas Dunteman <git@learningtopi.com>",
    "download_url": "https://files.pythonhosted.org/packages/5e/96/864d2fca6395e73c7acd818cf0385992ab726d1c5e8b234a3b6e818d6c8f/logging_handler-1.0.7.tar.gz",
    "platform": null,
    "description": "# Python Logging Helper\nPython library to quickly create logging handlers.  Supports logging to the console as well as to file using a syslog style output format.\n\n## Installation\nThe package is available on PyPi or can be installed manually using the why/tar.gz file attached to the release.\n\n    pip3 install logging_helper\n\n## Introduction\nThis library provides a function called \"create_logger\" that will create and return a logging handler that can be used in your application.  The \"create_logger\" function can be passed a series of different settings to manipulate the default Python logging handler.\n\n## Examples\n\n    >>> from logging_helper import create_logger\n    >>> logger = create_logger(console=True)\n    >>> logger.warning('test')\n    2022-11-09 16:09:21,210 - root - WARNING - test\n    >>>\n    >>> logger.debug('test debug')\n    >>> ### Note no output! Default is set to WARNING and above\n    >>>\n    >>> logger = create_logger(console=True, console_level='DEBUG')\n    >>> logger.debug('test debug')\n    2022-11-09 16:11:13,268 - root - DEBUG - test debug\n    >>> \n    >>> logger2 = create_logger(console=True, console_level='DEBUG', name='log2')\n    >>> logger2.info('logger2 info!')\n    2022-11-09 16:12:23,358 - log2 - INFO - logger2 info!\n    >>> logger.info('logger1 info!')\n    2022-11-09 16:12:35,510 - root - INFO - logger1 info!\n\nIn the examples above, you can create multiple loggers with different names.  If a name is not provided, the logger takes on the 'root' logger for Python.  Replacing the 'root' logger will replace the default logging in python and affects other modules.  If you set your logger to debug and start seeing messages from other modules you weren't expecting, provide a name value to your logger.\n\n## Parameters\n| Parameter | Default | Description |\n| --------- | ------- | ----------- |\n| console_level | 'INFO' (str) | Set the logging level for the console\n| console | True (bool) | Enable / Disable logging to the console\n| log_file | '' (str) | Set the file to log to (blank means none)\n| file_level | 'WARNING' (str) | Set the logging level for the file\n| file_mode | 'a' (str) | Feeds into the file mode 'a' for append, 'w' for overwrite\n| name | '' (str) | Name for the logger. Blank will replace the root logging handler\n| syslog | False (bool) | Send messages to the local system logger\n| syslog_script_name | '' (str) | Name to include when using the local system logger\n| log_file_vars | [] (list) | list of variables that can be used to create the log file names\n| log_file_retention_days | 0 (int) | Specify the max number of days to retain the log files\n| propagate | False (bool) | If set to true, the named loggers will also be processed by the root logger.  Generally leave false\n\n## Release Notes\n\nv1.0.2  \n        - Moved console level to the 1st parameter.  Make it quicker and easier to create a console logger\n        - Chaned default console level to INFO from WARNING.  This is what I typically end up using anyway\n        - Updated the home page to our new logging_handler page:  https://www.learningtopi.com/python-modules-applications/python_logging_handler/\n        - Allow passing static values DEBUG, INFO, WARNING, ERROR and CRITICAL from the logging module (or you may import from this library)\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Python Library to quickly create logging handlers",
    "version": "1.0.7",
    "project_urls": {
        "Bug Tracker": "https://github.com/LearningToPi/logging_handler/issues",
        "Homepage": "https://www.learningtopi.com/python-modules-applications/python_logging_handler/",
        "Source Code": "https://github.com/LearningToPi/logging_handler"
    },
    "split_keywords": [
        "logging",
        "syslog"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bc7eea926777d0f02132e43013befc9597cc6b12007409a8ad1baa426e246c74",
                "md5": "604c0592d0cd6fddbd29fe054a3ff955",
                "sha256": "f185264a59dd51d9bc188f64ecf956e28892b562264adf50e64e538b390770f8"
            },
            "downloads": -1,
            "filename": "logging_handler-1.0.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "604c0592d0cd6fddbd29fe054a3ff955",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 5485,
            "upload_time": "2023-07-26T21:16:49",
            "upload_time_iso_8601": "2023-07-26T21:16:49.634792Z",
            "url": "https://files.pythonhosted.org/packages/bc/7e/ea926777d0f02132e43013befc9597cc6b12007409a8ad1baa426e246c74/logging_handler-1.0.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5e96864d2fca6395e73c7acd818cf0385992ab726d1c5e8b234a3b6e818d6c8f",
                "md5": "83e4e3befaa7c40d91bb54827e12e120",
                "sha256": "f6f7d4cdeb46f00621b387af71278566b88ff647bb07ded6702898bf8d2429c8"
            },
            "downloads": -1,
            "filename": "logging_handler-1.0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "83e4e3befaa7c40d91bb54827e12e120",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 4620,
            "upload_time": "2023-07-26T21:16:51",
            "upload_time_iso_8601": "2023-07-26T21:16:51.007391Z",
            "url": "https://files.pythonhosted.org/packages/5e/96/864d2fca6395e73c7acd818cf0385992ab726d1c5e8b234a3b6e818d6c8f/logging_handler-1.0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-26 21:16:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "LearningToPi",
    "github_project": "logging_handler",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "logging-handler"
}
        
Elapsed time: 0.09876s