systemd-logging 1.0.1__tar.gz → 1.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- systemd_logging-1.0.2/.gitignore +11 -0
- {systemd-logging-1.0.1 → systemd_logging-1.0.2}/LICENSE +1 -1
- systemd_logging-1.0.2/PKG-INFO +72 -0
- systemd_logging-1.0.2/README.md +48 -0
- systemd_logging-1.0.2/pyproject.toml +76 -0
- systemd_logging-1.0.2/src/systemdlogging/__init__.py +1 -0
- {systemd-logging-1.0.1 → systemd_logging-1.0.2/src}/systemdlogging/toolbox.py +16 -4
- systemd-logging-1.0.1/AUTHORS +0 -18
- systemd-logging-1.0.1/CHANGELOG +0 -34
- systemd-logging-1.0.1/INSTALL +0 -31
- systemd-logging-1.0.1/MANIFEST.in +0 -15
- systemd-logging-1.0.1/PKG-INFO +0 -103
- systemd-logging-1.0.1/README.rst +0 -83
- systemd-logging-1.0.1/docs/Makefile +0 -131
- systemd-logging-1.0.1/docs/source/api.rst +0 -5
- systemd-logging-1.0.1/docs/source/conf.py +0 -262
- systemd-logging-1.0.1/docs/source/index.rst +0 -32
- systemd-logging-1.0.1/docs/source/quickstart.rst +0 -33
- systemd-logging-1.0.1/docs/source/rst_guide.rst +0 -104
- systemd-logging-1.0.1/setup.cfg +0 -11
- systemd-logging-1.0.1/setup.py +0 -68
- systemd-logging-1.0.1/systemd_logging.egg-info/PKG-INFO +0 -103
- systemd-logging-1.0.1/systemd_logging.egg-info/SOURCES.txt +0 -24
- systemd-logging-1.0.1/systemd_logging.egg-info/dependency_links.txt +0 -1
- systemd-logging-1.0.1/systemd_logging.egg-info/not-zip-safe +0 -1
- systemd-logging-1.0.1/systemd_logging.egg-info/requires.txt +0 -1
- systemd-logging-1.0.1/systemd_logging.egg-info/top_level.txt +0 -1
- systemd-logging-1.0.1/systemdlogging/__init__.py +0 -7
- systemd-logging-1.0.1/tests/test_module.py +0 -77
- {systemd-logging-1.0.1 → systemd_logging-1.0.2/src}/systemdlogging/backend_ctyped.py +0 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: systemd-logging
|
|
3
|
+
Version: 1.0.2
|
|
4
|
+
Summary: Simplifies logging for systemd
|
|
5
|
+
Project-URL: Homepage, https://github.com/idlesign/systemd-logging
|
|
6
|
+
Author-email: Igor Starikov <idlesign@yandex.ru>
|
|
7
|
+
License-Expression: BSD-3-Clause
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Keywords: journal,logging,systemd
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Requires-Dist: ctyped>=0.7.1
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# systemd-logging
|
|
26
|
+
|
|
27
|
+
<https://github.com/idlesign/systemd-logging>
|
|
28
|
+
|
|
29
|
+
[](https://pypi.python.org/pypi/systemd-logging)
|
|
30
|
+
[](https://pypi.python.org/pypi/systemd-logging)
|
|
31
|
+
[](https://coveralls.io/r/idlesign/systemd-logging)
|
|
32
|
+
|
|
33
|
+
## Description
|
|
34
|
+
|
|
35
|
+
*Simplifies logging for systemd*
|
|
36
|
+
|
|
37
|
+
**Requires Python 3.10+**
|
|
38
|
+
|
|
39
|
+
* No need to compile (pure Python), uses `libsystemd.so`.
|
|
40
|
+
* Simplified configuration.
|
|
41
|
+
* Just logging. Nothing more.
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
import logging
|
|
47
|
+
|
|
48
|
+
from systemdlogging.toolbox import init_systemd_logging
|
|
49
|
+
|
|
50
|
+
# This one line in most cases would be enough.
|
|
51
|
+
# By default it attaches systemd logging handler to a root Python logger.
|
|
52
|
+
init_systemd_logging() # Returns True if initialization went fine.
|
|
53
|
+
|
|
54
|
+
# Now you can use logging as usual.
|
|
55
|
+
logger = logging.getLogger(__name__)
|
|
56
|
+
logger.setLevel(logging.DEBUG)
|
|
57
|
+
|
|
58
|
+
logger.debug('My debug message')
|
|
59
|
+
|
|
60
|
+
try:
|
|
61
|
+
raise ValueError('Log me please')
|
|
62
|
+
|
|
63
|
+
except ValueError:
|
|
64
|
+
# Additional context can be passed in extra.context.
|
|
65
|
+
logger.exception('Something terrible just happened', extra={
|
|
66
|
+
'message_id': True, # Generate message ID automatically.
|
|
67
|
+
'context': {
|
|
68
|
+
'FIELD1': 'one',
|
|
69
|
+
'FIELD2': 'two',
|
|
70
|
+
}
|
|
71
|
+
}, stack_info=True)
|
|
72
|
+
```
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# systemd-logging
|
|
2
|
+
|
|
3
|
+
<https://github.com/idlesign/systemd-logging>
|
|
4
|
+
|
|
5
|
+
[](https://pypi.python.org/pypi/systemd-logging)
|
|
6
|
+
[](https://pypi.python.org/pypi/systemd-logging)
|
|
7
|
+
[](https://coveralls.io/r/idlesign/systemd-logging)
|
|
8
|
+
|
|
9
|
+
## Description
|
|
10
|
+
|
|
11
|
+
*Simplifies logging for systemd*
|
|
12
|
+
|
|
13
|
+
**Requires Python 3.10+**
|
|
14
|
+
|
|
15
|
+
* No need to compile (pure Python), uses `libsystemd.so`.
|
|
16
|
+
* Simplified configuration.
|
|
17
|
+
* Just logging. Nothing more.
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
import logging
|
|
23
|
+
|
|
24
|
+
from systemdlogging.toolbox import init_systemd_logging
|
|
25
|
+
|
|
26
|
+
# This one line in most cases would be enough.
|
|
27
|
+
# By default it attaches systemd logging handler to a root Python logger.
|
|
28
|
+
init_systemd_logging() # Returns True if initialization went fine.
|
|
29
|
+
|
|
30
|
+
# Now you can use logging as usual.
|
|
31
|
+
logger = logging.getLogger(__name__)
|
|
32
|
+
logger.setLevel(logging.DEBUG)
|
|
33
|
+
|
|
34
|
+
logger.debug('My debug message')
|
|
35
|
+
|
|
36
|
+
try:
|
|
37
|
+
raise ValueError('Log me please')
|
|
38
|
+
|
|
39
|
+
except ValueError:
|
|
40
|
+
# Additional context can be passed in extra.context.
|
|
41
|
+
logger.exception('Something terrible just happened', extra={
|
|
42
|
+
'message_id': True, # Generate message ID automatically.
|
|
43
|
+
'context': {
|
|
44
|
+
'FIELD1': 'one',
|
|
45
|
+
'FIELD2': 'two',
|
|
46
|
+
}
|
|
47
|
+
}, stack_info=True)
|
|
48
|
+
```
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "systemd-logging"
|
|
3
|
+
dynamic = ["version"]
|
|
4
|
+
description = "Simplifies logging for systemd"
|
|
5
|
+
authors = [
|
|
6
|
+
{ name = "Igor Starikov", email = "idlesign@yandex.ru" },
|
|
7
|
+
]
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
license = "BSD-3-Clause"
|
|
10
|
+
license-files = ["LICENSE"]
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
keywords = ["systemd", "journal", "logging"]
|
|
13
|
+
dependencies = [
|
|
14
|
+
"ctyped>=0.7.1",
|
|
15
|
+
]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 5 - Production/Stable",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Programming Language :: Python",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Programming Language :: Python :: 3.13",
|
|
26
|
+
"Programming Language :: Python :: 3.14",
|
|
27
|
+
"License :: OSI Approved :: BSD License",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Homepage = "https://github.com/idlesign/systemd-logging"
|
|
32
|
+
|
|
33
|
+
[dependency-groups]
|
|
34
|
+
dev = [
|
|
35
|
+
{ include-group = "docs" },
|
|
36
|
+
{ include-group = "linters" },
|
|
37
|
+
{ include-group = "tests" },
|
|
38
|
+
]
|
|
39
|
+
docs = [
|
|
40
|
+
"mkdocs-apidescribed-plugin",
|
|
41
|
+
"mkdocs-material",
|
|
42
|
+
"mkdocs-navsorted-plugin",
|
|
43
|
+
]
|
|
44
|
+
linters = [
|
|
45
|
+
"ruff==0.13.1",
|
|
46
|
+
]
|
|
47
|
+
tests = [
|
|
48
|
+
"coverage",
|
|
49
|
+
"pytest",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
[build-system]
|
|
53
|
+
requires = ["hatchling"]
|
|
54
|
+
build-backend = "hatchling.build"
|
|
55
|
+
|
|
56
|
+
[tool.hatch.version]
|
|
57
|
+
path = "src/systemdlogging/__init__.py"
|
|
58
|
+
|
|
59
|
+
[tool.hatch.build.targets.wheel]
|
|
60
|
+
packages = ["src/systemdlogging"]
|
|
61
|
+
|
|
62
|
+
[tool.hatch.build.targets.sdist]
|
|
63
|
+
packages = ["src/"]
|
|
64
|
+
|
|
65
|
+
[tool.pytest.ini_options]
|
|
66
|
+
testpaths = [
|
|
67
|
+
"tests",
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
[tool.coverage.run]
|
|
71
|
+
source = [
|
|
72
|
+
"src/systemdlogging",
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
[tool.makeapp.tests]
|
|
76
|
+
deps = []
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VERSION = '1.0.2'
|
|
@@ -2,7 +2,6 @@ import logging
|
|
|
2
2
|
import os
|
|
3
3
|
import syslog
|
|
4
4
|
import uuid
|
|
5
|
-
from typing import Optional
|
|
6
5
|
|
|
7
6
|
from .backend_ctyped import send, send_stub
|
|
8
7
|
|
|
@@ -15,7 +14,7 @@ PRIORITY_MAP = {
|
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
|
|
18
|
-
def log_message(*, level: int, msg: str, context:
|
|
17
|
+
def log_message(*, level: int, msg: str, context: dict | None = None) -> bool:
|
|
19
18
|
"""Sends a message to systemd.
|
|
20
19
|
|
|
21
20
|
.. warning:: Low level function. You may want to
|
|
@@ -151,10 +150,23 @@ def check_for_systemd() -> bool:
|
|
|
151
150
|
is connected to journald).
|
|
152
151
|
|
|
153
152
|
"""
|
|
154
|
-
|
|
153
|
+
if send is send_stub:
|
|
154
|
+
return False
|
|
155
155
|
|
|
156
|
+
journal_stream = os.environ.get("JOURNAL_STREAM") # systemd v231+
|
|
156
157
|
|
|
157
|
-
|
|
158
|
+
if journal_stream:
|
|
159
|
+
# Output streams might have been replaced by a wrapping process,
|
|
160
|
+
# so verify that stdout/stderr are still connected to the journal.
|
|
161
|
+
return any(
|
|
162
|
+
f"{stat.st_dev}:{stat.st_ino}" == journal_stream
|
|
163
|
+
for stat in (os.fstat(fd) for fd in (1, 2))
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
return bool(os.environ.get("INVOCATION_ID")) # Works with systemd v232+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def init_systemd_logging(*, logger: logging.Logger | None = None, syslog_id: str = '') -> bool:
|
|
158
170
|
"""Initializes logging to send log messages to systemd.
|
|
159
171
|
|
|
160
172
|
Returns boolean indicating initialization went fine (see also `check_for_systemd()`).
|
systemd-logging-1.0.1/AUTHORS
DELETED
systemd-logging-1.0.1/CHANGELOG
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
systemd-logging changelog
|
|
2
|
-
=========================
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
v1.0.1 [2022-01-28]
|
|
6
|
-
-------------------
|
|
7
|
-
* Prevent segfaults for values having format placeholders like %s (see #6).
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
v1.0.0 [2021-07-14]
|
|
11
|
-
-------------------
|
|
12
|
-
* Celebrating 1.0.0.
|
|
13
|
-
* CtypedException is now hidden to improve plugability (see #5).
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
v0.3.1 [2021-01-25]
|
|
17
|
-
-------------------
|
|
18
|
-
* Proper % handling in messages (see #3).
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
v0.3.0 [2020-01-28]
|
|
22
|
-
-------------------
|
|
23
|
-
+ init_systemd_logging() now tries to detect systemd and returns boolean.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
v0.2.0 [2019-10-15]
|
|
27
|
-
-------------------
|
|
28
|
-
+ Added an option to set SYSLOG_IDENTIFIER.
|
|
29
|
-
* Removed PROCESS_ID field in favor of _PID.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
v0.1.0 [2019-10-14]
|
|
33
|
-
-------------------
|
|
34
|
-
+ Basic functionality.
|
systemd-logging-1.0.1/INSTALL
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
systemd-logging installation
|
|
2
|
-
============================
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Python ``pip`` package is required to install ``systemd-logging``.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
From sources
|
|
9
|
-
------------
|
|
10
|
-
|
|
11
|
-
Use the following command line to install ``systemd-logging`` from sources directory (containing setup.py):
|
|
12
|
-
|
|
13
|
-
pip install .
|
|
14
|
-
|
|
15
|
-
or
|
|
16
|
-
|
|
17
|
-
python setup.py install
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
From PyPI
|
|
21
|
-
---------
|
|
22
|
-
|
|
23
|
-
Alternatively you can install ``systemd-logging`` from PyPI:
|
|
24
|
-
|
|
25
|
-
pip install systemd-logging
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
Use `-U` flag for upgrade:
|
|
29
|
-
|
|
30
|
-
pip install -U systemd-logging
|
|
31
|
-
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
include AUTHORS
|
|
2
|
-
include CHANGELOG
|
|
3
|
-
include INSTALL
|
|
4
|
-
include LICENSE
|
|
5
|
-
include README.rst
|
|
6
|
-
|
|
7
|
-
include docs/Makefile
|
|
8
|
-
recursive-include docs *.rst
|
|
9
|
-
recursive-include docs *.py
|
|
10
|
-
recursive-include tests *
|
|
11
|
-
|
|
12
|
-
recursive-exclude * __pycache__
|
|
13
|
-
recursive-exclude * *.py[co]
|
|
14
|
-
recursive-exclude * empty
|
|
15
|
-
|
systemd-logging-1.0.1/PKG-INFO
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 1.1
|
|
2
|
-
Name: systemd-logging
|
|
3
|
-
Version: 1.0.1
|
|
4
|
-
Summary: Simplifies logging for systemd
|
|
5
|
-
Home-page: https://github.com/idlesign/systemd-logging
|
|
6
|
-
Author: Igor `idle sign` Starikov
|
|
7
|
-
Author-email: idlesign@yandex.ru
|
|
8
|
-
License: BSD 3-Clause License
|
|
9
|
-
Description: systemd-logging
|
|
10
|
-
===============
|
|
11
|
-
https://github.com/idlesign/systemd-logging
|
|
12
|
-
|
|
13
|
-
|release| |lic| |coverage|
|
|
14
|
-
|
|
15
|
-
.. |release| image:: https://img.shields.io/pypi/v/systemd-logging.svg
|
|
16
|
-
:target: https://pypi.python.org/pypi/systemd-logging
|
|
17
|
-
|
|
18
|
-
.. |lic| image:: https://img.shields.io/pypi/l/systemd-logging.svg
|
|
19
|
-
:target: https://pypi.python.org/pypi/systemd-logging
|
|
20
|
-
|
|
21
|
-
.. |coverage| image:: https://img.shields.io/coveralls/idlesign/systemd-logging/master.svg
|
|
22
|
-
:target: https://coveralls.io/r/idlesign/systemd-logging
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Description
|
|
26
|
-
-----------
|
|
27
|
-
|
|
28
|
-
*Simplifies logging for systemd*
|
|
29
|
-
|
|
30
|
-
**Requires Python 3.6+**
|
|
31
|
-
|
|
32
|
-
* No need to compile (pure Python), uses ``libsystemd.so``.
|
|
33
|
-
* Simplified configuration.
|
|
34
|
-
* Just logging. Nothing more.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
Usage
|
|
38
|
-
-----
|
|
39
|
-
|
|
40
|
-
.. code-block:: python
|
|
41
|
-
|
|
42
|
-
import logging
|
|
43
|
-
|
|
44
|
-
from systemdlogging.toolbox import init_systemd_logging
|
|
45
|
-
|
|
46
|
-
# This one line in most cases would be enough.
|
|
47
|
-
# By default it attaches systemd logging handler to a root Python logger.
|
|
48
|
-
init_systemd_logging() # Returns True if initialization went fine.
|
|
49
|
-
|
|
50
|
-
# Now you can use logging as usual.
|
|
51
|
-
logger = logging.getLogger(__name__)
|
|
52
|
-
logger.setLevel(logging.DEBUG)
|
|
53
|
-
|
|
54
|
-
logger.debug('My debug message')
|
|
55
|
-
|
|
56
|
-
try:
|
|
57
|
-
raise ValueError('Log me please')
|
|
58
|
-
|
|
59
|
-
except ValueError:
|
|
60
|
-
# Additional context can be passed in extra.context.
|
|
61
|
-
logger.exception('Something terrible just happened', extra={
|
|
62
|
-
'message_id': True, # Generate message ID automatically.
|
|
63
|
-
'context': {
|
|
64
|
-
'FIELD1': 'one',
|
|
65
|
-
'FIELD2': 'two',
|
|
66
|
-
}
|
|
67
|
-
}, stack_info=True)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
Read the docs to find out more.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
Documentation
|
|
74
|
-
-------------
|
|
75
|
-
|
|
76
|
-
https://systemd-logging.readthedocs.org/
|
|
77
|
-
|
|
78
|
-
Debug runs
|
|
79
|
-
~~~~~~~~~~
|
|
80
|
-
|
|
81
|
-
1. Run your script with:
|
|
82
|
-
|
|
83
|
-
.. code-block::
|
|
84
|
-
|
|
85
|
-
$ sudo systemd-run -u debugme -t /usr/bin/python /home/my/testme.py
|
|
86
|
-
|
|
87
|
-
2. Watch its journal with:
|
|
88
|
-
|
|
89
|
-
.. code-block::
|
|
90
|
-
|
|
91
|
-
$ journalctl -u debugme -f -o verbose
|
|
92
|
-
|
|
93
|
-
Platform: UNKNOWN
|
|
94
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
95
|
-
Classifier: Operating System :: OS Independent
|
|
96
|
-
Classifier: Programming Language :: Python
|
|
97
|
-
Classifier: Programming Language :: Python :: 3
|
|
98
|
-
Classifier: Programming Language :: Python :: 3.6
|
|
99
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
100
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
101
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
102
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
103
|
-
Classifier: License :: OSI Approved :: BSD License
|
systemd-logging-1.0.1/README.rst
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
systemd-logging
|
|
2
|
-
===============
|
|
3
|
-
https://github.com/idlesign/systemd-logging
|
|
4
|
-
|
|
5
|
-
|release| |lic| |coverage|
|
|
6
|
-
|
|
7
|
-
.. |release| image:: https://img.shields.io/pypi/v/systemd-logging.svg
|
|
8
|
-
:target: https://pypi.python.org/pypi/systemd-logging
|
|
9
|
-
|
|
10
|
-
.. |lic| image:: https://img.shields.io/pypi/l/systemd-logging.svg
|
|
11
|
-
:target: https://pypi.python.org/pypi/systemd-logging
|
|
12
|
-
|
|
13
|
-
.. |coverage| image:: https://img.shields.io/coveralls/idlesign/systemd-logging/master.svg
|
|
14
|
-
:target: https://coveralls.io/r/idlesign/systemd-logging
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
Description
|
|
18
|
-
-----------
|
|
19
|
-
|
|
20
|
-
*Simplifies logging for systemd*
|
|
21
|
-
|
|
22
|
-
**Requires Python 3.6+**
|
|
23
|
-
|
|
24
|
-
* No need to compile (pure Python), uses ``libsystemd.so``.
|
|
25
|
-
* Simplified configuration.
|
|
26
|
-
* Just logging. Nothing more.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Usage
|
|
30
|
-
-----
|
|
31
|
-
|
|
32
|
-
.. code-block:: python
|
|
33
|
-
|
|
34
|
-
import logging
|
|
35
|
-
|
|
36
|
-
from systemdlogging.toolbox import init_systemd_logging
|
|
37
|
-
|
|
38
|
-
# This one line in most cases would be enough.
|
|
39
|
-
# By default it attaches systemd logging handler to a root Python logger.
|
|
40
|
-
init_systemd_logging() # Returns True if initialization went fine.
|
|
41
|
-
|
|
42
|
-
# Now you can use logging as usual.
|
|
43
|
-
logger = logging.getLogger(__name__)
|
|
44
|
-
logger.setLevel(logging.DEBUG)
|
|
45
|
-
|
|
46
|
-
logger.debug('My debug message')
|
|
47
|
-
|
|
48
|
-
try:
|
|
49
|
-
raise ValueError('Log me please')
|
|
50
|
-
|
|
51
|
-
except ValueError:
|
|
52
|
-
# Additional context can be passed in extra.context.
|
|
53
|
-
logger.exception('Something terrible just happened', extra={
|
|
54
|
-
'message_id': True, # Generate message ID automatically.
|
|
55
|
-
'context': {
|
|
56
|
-
'FIELD1': 'one',
|
|
57
|
-
'FIELD2': 'two',
|
|
58
|
-
}
|
|
59
|
-
}, stack_info=True)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
Read the docs to find out more.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
Documentation
|
|
66
|
-
-------------
|
|
67
|
-
|
|
68
|
-
https://systemd-logging.readthedocs.org/
|
|
69
|
-
|
|
70
|
-
Debug runs
|
|
71
|
-
~~~~~~~~~~
|
|
72
|
-
|
|
73
|
-
1. Run your script with:
|
|
74
|
-
|
|
75
|
-
.. code-block::
|
|
76
|
-
|
|
77
|
-
$ sudo systemd-run -u debugme -t /usr/bin/python /home/my/testme.py
|
|
78
|
-
|
|
79
|
-
2. Watch its journal with:
|
|
80
|
-
|
|
81
|
-
.. code-block::
|
|
82
|
-
|
|
83
|
-
$ journalctl -u debugme -f -o verbose
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
# Makefile for Sphinx documentation
|
|
2
|
-
#
|
|
3
|
-
|
|
4
|
-
# You can set these variables from the command line.
|
|
5
|
-
SPHINXOPTS =
|
|
6
|
-
SPHINXBUILD = sphinx-build
|
|
7
|
-
PAPER =
|
|
8
|
-
BUILDDIR = build
|
|
9
|
-
|
|
10
|
-
# Internal variables.
|
|
11
|
-
PAPEROPT_a4 = -D latex_paper_size=a4
|
|
12
|
-
PAPEROPT_letter = -D latex_paper_size=letter
|
|
13
|
-
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
|
|
14
|
-
|
|
15
|
-
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest
|
|
16
|
-
|
|
17
|
-
help:
|
|
18
|
-
@echo "Please use \`make <target>' where <target> is one of"
|
|
19
|
-
@echo " html to make standalone HTML files"
|
|
20
|
-
@echo " dirhtml to make HTML files named index.html in directories"
|
|
21
|
-
@echo " singlehtml to make a single large HTML file"
|
|
22
|
-
@echo " pickle to make pickle files"
|
|
23
|
-
@echo " json to make JSON files"
|
|
24
|
-
@echo " htmlhelp to make HTML files and a HTML help project"
|
|
25
|
-
@echo " qthelp to make HTML files and a qthelp project"
|
|
26
|
-
@echo " devhelp to make HTML files and a Devhelp project"
|
|
27
|
-
@echo " epub to make an epub"
|
|
28
|
-
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
|
|
29
|
-
@echo " latexpdf to make LaTeX files and run them through pdflatex"
|
|
30
|
-
@echo " text to make text files"
|
|
31
|
-
@echo " man to make manual pages"
|
|
32
|
-
@echo " changes to make an overview of all changed/added/deprecated items"
|
|
33
|
-
@echo " linkcheck to check all external links for integrity"
|
|
34
|
-
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
|
|
35
|
-
|
|
36
|
-
clean:
|
|
37
|
-
-rm -rf $(BUILDDIR)/*
|
|
38
|
-
|
|
39
|
-
html:
|
|
40
|
-
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
|
|
41
|
-
@echo
|
|
42
|
-
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
|
|
43
|
-
|
|
44
|
-
dirhtml:
|
|
45
|
-
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
|
|
46
|
-
@echo
|
|
47
|
-
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
|
|
48
|
-
|
|
49
|
-
singlehtml:
|
|
50
|
-
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
|
|
51
|
-
@echo
|
|
52
|
-
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
|
|
53
|
-
|
|
54
|
-
pickle:
|
|
55
|
-
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
|
|
56
|
-
@echo
|
|
57
|
-
@echo "Build finished; now you can process the pickle files."
|
|
58
|
-
|
|
59
|
-
json:
|
|
60
|
-
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
|
|
61
|
-
@echo
|
|
62
|
-
@echo "Build finished; now you can process the JSON files."
|
|
63
|
-
|
|
64
|
-
htmlhelp:
|
|
65
|
-
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
|
|
66
|
-
@echo
|
|
67
|
-
@echo "Build finished; now you can run HTML Help Workshop with the" \
|
|
68
|
-
".hhp project file in $(BUILDDIR)/htmlhelp."
|
|
69
|
-
|
|
70
|
-
qthelp:
|
|
71
|
-
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
|
|
72
|
-
@echo
|
|
73
|
-
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
|
74
|
-
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
|
|
75
|
-
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/systemd-logging.qhcp"
|
|
76
|
-
@echo "To view the help file:"
|
|
77
|
-
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/systemd-logging.qhc"
|
|
78
|
-
|
|
79
|
-
devhelp:
|
|
80
|
-
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
|
|
81
|
-
@echo
|
|
82
|
-
@echo "Build finished."
|
|
83
|
-
@echo "To view the help file:"
|
|
84
|
-
@echo "# mkdir -p $$HOME/.local/share/devhelp/systemd-logging"
|
|
85
|
-
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/systemd-logging"
|
|
86
|
-
@echo "# devhelp"
|
|
87
|
-
|
|
88
|
-
epub:
|
|
89
|
-
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
|
|
90
|
-
@echo
|
|
91
|
-
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
|
|
92
|
-
|
|
93
|
-
latex:
|
|
94
|
-
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
|
95
|
-
@echo
|
|
96
|
-
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
|
|
97
|
-
@echo "Run \`make' in that directory to run these through (pdf)latex" \
|
|
98
|
-
"(use \`make latexpdf' here to do that automatically)."
|
|
99
|
-
|
|
100
|
-
latexpdf:
|
|
101
|
-
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
|
102
|
-
@echo "Running LaTeX files through pdflatex..."
|
|
103
|
-
make -C $(BUILDDIR)/latex all-pdf
|
|
104
|
-
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
|
105
|
-
|
|
106
|
-
text:
|
|
107
|
-
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
|
|
108
|
-
@echo
|
|
109
|
-
@echo "Build finished. The text files are in $(BUILDDIR)/text."
|
|
110
|
-
|
|
111
|
-
man:
|
|
112
|
-
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
|
|
113
|
-
@echo
|
|
114
|
-
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
|
|
115
|
-
|
|
116
|
-
changes:
|
|
117
|
-
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
|
|
118
|
-
@echo
|
|
119
|
-
@echo "The overview file is in $(BUILDDIR)/changes."
|
|
120
|
-
|
|
121
|
-
linkcheck:
|
|
122
|
-
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
|
|
123
|
-
@echo
|
|
124
|
-
@echo "Link check complete; look for any errors in the above output " \
|
|
125
|
-
"or in $(BUILDDIR)/linkcheck/output.txt."
|
|
126
|
-
|
|
127
|
-
doctest:
|
|
128
|
-
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
|
|
129
|
-
@echo "Testing of doctests in the sources finished, look at the " \
|
|
130
|
-
"results in $(BUILDDIR)/doctest/output.txt."
|
|
131
|
-
|