SystemLogger


NameSystemLogger JSON
Version 0.2.2 PyPI version JSON
download
home_pagehttps://github.com/d9pouces/SystemLogger
SummaryCreate and configure a logger using a global configuration file.
upload_time2025-02-22 17:30:29
maintainerMatthieu Gallet
docs_urlNone
authorMatthieu Gallet
requires_python<4.0,>=3.8
licenseCECILL-B
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            SystemLogger
============


..image:: https://pyup.io/repos/github/d9pouces/SystemLogger/shield.svg
:target: https://pyup.io/repos/github/d9pouces/SystemLogger/
:alt: Updates

Create and configure a logger using a global configuration file.
This module is intended for logging my Python system scripts, without redeclaring a lot of boilerplate.
This module is not meant to be highly customizable, but to have the same logging configuration in scripts with a
minimal effort.

The default configuration file is `/etc/python_logging.ini`.

Usage
-----

```bash
python3 -m pip install systemlogger
cat << EOF | sudo tee /etc/python_logging.ini
[logging]
sentry_dsn = https://username@sentry.example.com/1
loki_url = https://username:password@localhost:3100/loki/api/v1/push
syslog_url = tcp://127.0.0.1:514
# only udp:// and tcp:// protocols can be used for syslog
logfile_directory = /tmp
# the filename will be /tmp/{application}.log
logfile_max_size = 1000000
# if max_size is not set (or is 0), the file will never be rotated
logfile_backup_count = 3
# number of backup files (for example, only /tmp/{application}.log.1 is created if logfile_backup_count == 1)
console = true
# errors and above are sent to stderr, infos and below are sent to stdout
level = info
# minimal level of transmitted log records
source = python
# added as "log_source" tag in sentry and loki
hostname = $(hostname)
# added as "hostname" tag in sentry and loki
requests_ca_bundle = /etc/ssl/certs/ca-certificates.crt
# path to the CA bundle for requests
EOF
python3 -c 'from systemlogger import getLogger ; logger = getLogger(name="demo") ; logger.warning("log warning test") ; logger.error("log error test")'
```

In Grafana/Loki and in Sentry, you can now select all Python scripts with the `log_source` tag and a specific script
with
the `application` tag.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/d9pouces/SystemLogger",
    "name": "SystemLogger",
    "maintainer": "Matthieu Gallet",
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": "github@19pouces.net",
    "keywords": null,
    "author": "Matthieu Gallet",
    "author_email": "github@19pouces.net",
    "download_url": "https://files.pythonhosted.org/packages/57/47/467673982e7169e0d6991c436366afe092e6eb0d7ee07ddcd0e4777803ae/systemlogger-0.2.2.tar.gz",
    "platform": null,
    "description": "SystemLogger\n============\n\n\n..image:: https://pyup.io/repos/github/d9pouces/SystemLogger/shield.svg\n:target: https://pyup.io/repos/github/d9pouces/SystemLogger/\n:alt: Updates\n\nCreate and configure a logger using a global configuration file.\nThis module is intended for logging my Python system scripts, without redeclaring a lot of boilerplate.\nThis module is not meant to be highly customizable, but to have the same logging configuration in scripts with a\nminimal effort.\n\nThe default configuration file is `/etc/python_logging.ini`.\n\nUsage\n-----\n\n```bash\npython3 -m pip install systemlogger\ncat << EOF | sudo tee /etc/python_logging.ini\n[logging]\nsentry_dsn = https://username@sentry.example.com/1\nloki_url = https://username:password@localhost:3100/loki/api/v1/push\nsyslog_url = tcp://127.0.0.1:514\n# only udp:// and tcp:// protocols can be used for syslog\nlogfile_directory = /tmp\n# the filename will be /tmp/{application}.log\nlogfile_max_size = 1000000\n# if max_size is not set (or is 0), the file will never be rotated\nlogfile_backup_count = 3\n# number of backup files (for example, only /tmp/{application}.log.1 is created if logfile_backup_count == 1)\nconsole = true\n# errors and above are sent to stderr, infos and below are sent to stdout\nlevel = info\n# minimal level of transmitted log records\nsource = python\n# added as \"log_source\" tag in sentry and loki\nhostname = $(hostname)\n# added as \"hostname\" tag in sentry and loki\nrequests_ca_bundle = /etc/ssl/certs/ca-certificates.crt\n# path to the CA bundle for requests\nEOF\npython3 -c 'from systemlogger import getLogger ; logger = getLogger(name=\"demo\") ; logger.warning(\"log warning test\") ; logger.error(\"log error test\")'\n```\n\nIn Grafana/Loki and in Sentry, you can now select all Python scripts with the `log_source` tag and a specific script\nwith\nthe `application` tag.\n",
    "bugtrack_url": null,
    "license": "CECILL-B",
    "summary": "Create and configure a logger using a global configuration file.",
    "version": "0.2.2",
    "project_urls": {
        "Documentation": "https://github.com/d9pouces/SystemLogger",
        "Homepage": "https://github.com/d9pouces/SystemLogger",
        "Repository": "https://github.com/d9pouces/SystemLogger"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dbf894a9658ab1264274a60baa6d198060de574418610e3d8d88c2dc594a4b65",
                "md5": "a2a0b2a86a82692ff77acd72d5526709",
                "sha256": "863daf6944cc2276907f7f479a43e87d484650a7343e958817229f029b69904a"
            },
            "downloads": -1,
            "filename": "systemlogger-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a2a0b2a86a82692ff77acd72d5526709",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 12591,
            "upload_time": "2025-02-22T17:30:27",
            "upload_time_iso_8601": "2025-02-22T17:30:27.684378Z",
            "url": "https://files.pythonhosted.org/packages/db/f8/94a9658ab1264274a60baa6d198060de574418610e3d8d88c2dc594a4b65/systemlogger-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5747467673982e7169e0d6991c436366afe092e6eb0d7ee07ddcd0e4777803ae",
                "md5": "1d30c4a8af4ce45f2303be32886e3d57",
                "sha256": "42ec571ea7c514d92ceae064d164018bdd7f24aa2a24d06a9b79b3188e910508"
            },
            "downloads": -1,
            "filename": "systemlogger-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "1d30c4a8af4ce45f2303be32886e3d57",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 11974,
            "upload_time": "2025-02-22T17:30:29",
            "upload_time_iso_8601": "2025-02-22T17:30:29.439741Z",
            "url": "https://files.pythonhosted.org/packages/57/47/467673982e7169e0d6991c436366afe092e6eb0d7ee07ddcd0e4777803ae/systemlogger-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-22 17:30:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "d9pouces",
    "github_project": "SystemLogger",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "systemlogger"
}
        
Elapsed time: 0.45248s