victorialogs-handler 0.1.0a1__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.
@@ -0,0 +1,15 @@
1
+ [run]
2
+ branch = True
3
+ source = vlogs_handler
4
+
5
+ [report]
6
+ exclude_lines =
7
+ if self.debug:
8
+ pragma: no cover
9
+ raise NotImplementedError
10
+ if __name__ == .__main__.:
11
+ ignore_errors = True
12
+ omit =
13
+ */test*.py
14
+ tests/*
15
+ examples/*
@@ -0,0 +1,4 @@
1
+ [flake8]
2
+ exclude = .git
3
+ ignore = E124, W503, W291, W293
4
+ max-line-length = 88
@@ -0,0 +1,72 @@
1
+ name: CI/CD
2
+
3
+ on: push
4
+
5
+ jobs:
6
+ lint:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - name: Checkout code
10
+ uses: actions/checkout@v4
11
+
12
+ - name: Set up Python
13
+ uses: actions/setup-python@v5
14
+ with:
15
+ python-version: "3.12"
16
+
17
+ - name: Run pre-commit
18
+ uses: pre-commit/action@v3.0.1
19
+
20
+ test:
21
+ needs: lint
22
+ runs-on: ubuntu-latest
23
+ strategy:
24
+ fail-fast: false
25
+ matrix:
26
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
27
+
28
+ steps:
29
+ - name: Checkout code
30
+ uses: actions/checkout@v4
31
+
32
+ - name: Set up Python ${{ matrix.python-version }}
33
+ uses: actions/setup-python@v5
34
+ with:
35
+ python-version: ${{ matrix.python-version }}
36
+
37
+ - name: Install package and dependencies
38
+ run: |
39
+ python -m pip install --upgrade pip
40
+ pip install ".[test]"
41
+
42
+ - name: Run tests
43
+ run: |
44
+ coverage run -m unittest discover tests/
45
+ coverage report -m
46
+ coverage xml
47
+
48
+ - name: Upload coverage reports to Codecov
49
+ uses: codecov/codecov-action@v5
50
+ with:
51
+ token: ${{ secrets.CODECOV_TOKEN }}
52
+
53
+ publish:
54
+ needs: test
55
+ if: startsWith(github.ref, 'refs/tags/')
56
+ runs-on: ubuntu-latest
57
+
58
+ steps:
59
+ - uses: actions/checkout@v4
60
+ - name: Set up Python
61
+ uses: actions/setup-python@v5
62
+ with:
63
+ python-version: "3.11"
64
+
65
+ - name: Install Flit
66
+ run: pip install flit
67
+
68
+ - name: Build and Publish
69
+ run: flit publish
70
+ env:
71
+ FLIT_USERNAME: ${{ secrets.FLIT_USERNAME }}
72
+ FLIT_PASSWORD: ${{ secrets.FLIT_PASSWORD }}
@@ -0,0 +1,48 @@
1
+ name: website
2
+
3
+ # build the documentation whenever there are new commits on main
4
+ on:
5
+ push:
6
+ branches:
7
+ - main
8
+ # Alternative: only build for tags.
9
+ # tags:
10
+ # - '*'
11
+
12
+ # security: restrict permissions for CI jobs.
13
+ permissions:
14
+ contents: read
15
+
16
+ jobs:
17
+ # Build the documentation and upload the static HTML files as an artifact.
18
+ build:
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: actions/checkout@v6
22
+ with:
23
+ persist-credentials: false
24
+ - uses: actions/setup-python@v6
25
+ with:
26
+ python-version: "3.14"
27
+
28
+ - run: pip install -e ".[docs]"
29
+ - run: pdoc -o docs/ -d="google" vlogs_handler
30
+
31
+ - uses: actions/upload-pages-artifact@v4
32
+ with:
33
+ path: docs/
34
+
35
+ # Deploy the artifact to GitHub pages.
36
+ # This is a separate job so that only actions/deploy-pages has the necessary permissions.
37
+ deploy:
38
+ needs: build
39
+ runs-on: ubuntu-latest
40
+ permissions:
41
+ pages: write
42
+ id-token: write
43
+ environment:
44
+ name: github-pages
45
+ url: ${{ steps.deployment.outputs.page_url }}
46
+ steps:
47
+ - id: deployment
48
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,213 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ #.idea/
177
+
178
+ # Abstra
179
+ # Abstra is an AI-powered process automation framework.
180
+ # Ignore directories containing user credentials, local state, and settings.
181
+ # Learn more at https://abstra.io/docs
182
+ .abstra/
183
+
184
+ # Visual Studio Code
185
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
188
+ # you could uncomment the following to ignore the entire vscode folder
189
+ # .vscode/
190
+
191
+ # Ruff stuff:
192
+ .ruff_cache/
193
+
194
+ # PyPI configuration file
195
+ .pypirc
196
+
197
+ # Cursor
198
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200
+ # refer to https://docs.cursor.com/context/ignore-files
201
+ .cursorignore
202
+ .cursorindexingignore
203
+
204
+ # Marimo
205
+ marimo/_static/
206
+ marimo/_lsp/
207
+ __marimo__/
208
+
209
+ # VS Code
210
+ .vscode/
211
+
212
+ # Misc
213
+ .temp/
@@ -0,0 +1,19 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v6.0.0
4
+ hooks:
5
+ - id: trailing-whitespace
6
+ - id: end-of-file-fixer
7
+ exclude: \.min\.css$
8
+ - repo: https://github.com/pre-commit/mirrors-isort
9
+ rev: "v5.10.1"
10
+ hooks:
11
+ - id: isort
12
+ - repo: https://github.com/psf/black
13
+ rev: 25.12.0
14
+ hooks:
15
+ - id: black
16
+ - repo: https://github.com/pycqa/flake8
17
+ rev: "7.3.0"
18
+ hooks:
19
+ - id: flake8
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Erik Kalkoken
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ coverage:
2
+ coverage run -m unittest discover tests/
3
+ coverage report -m
@@ -0,0 +1,90 @@
1
+ Metadata-Version: 2.4
2
+ Name: victorialogs-handler
3
+ Version: 0.1.0a1
4
+ Summary: A log handler for VictoriaLogs.
5
+ Author-email: Erik Kalkoken <kalkoken87@gmail.com>
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ License-Expression: MIT
9
+ Classifier: Environment :: Web Environment
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: System :: Logging
19
+ License-File: LICENSE
20
+ Requires-Dist: orjson>3.10
21
+ Requires-Dist: pdoc ; extra == "docs"
22
+ Requires-Dist: coverage ; extra == "test"
23
+ Project-URL: documentation, https://erikkalkoken.github.io/python-victorialogs-handler
24
+ Project-URL: source, https://github.com/ErikKalkoken/python-victorialogs-handler
25
+ Provides-Extra: docs
26
+ Provides-Extra: test
27
+
28
+ # victorialogs-handler
29
+
30
+ A high-performance Python log handler for VictoriaLogs.
31
+
32
+ [![release](https://img.shields.io/pypi/v/python-victorialogs-handler?label=release)](https://pypi.org/project/python-victorialogs-handler/)
33
+ [![python](https://img.shields.io/pypi/pyversions/python-victorialogs-handler)](https://pypi.org/project/python-victorialogs-handler/)
34
+ [![CI/CD](https://github.com/ErikKalkoken/python-victorialogs-handler/actions/workflows/cicd.yaml/badge.svg)](https://github.com/ErikKalkoken/python-victorialogs-handler/actions/workflows/cicd.yaml)
35
+ [![codecov](https://codecov.io/gh/ErikKalkoken/python-victorialogs-handler/graph/badge.svg?token=2pPb3lid2k)](https://codecov.io/gh/ErikKalkoken/python-victorialogs-handler)
36
+ [![license](https://img.shields.io/badge/license-MIT-green)](https://gitlab.com/ErikKalkoken/python-victorialogs-handler/-/blob/master/LICENSE)
37
+
38
+ > [!IMPORTANT]
39
+ > STATUS: In development. The API may still change.
40
+
41
+ ## Description
42
+
43
+ **victorialogs-handler** is a high-performance Python log handler tailored for [VictoriaLogs](https://victoriametrics.com/products/victorialogs/). It integrates seamlessly with Python’s native logging module, allowing you to stream log events to a VictoriaLogs instance with minimal configuration.
44
+
45
+ - Non-blocking: Logs are stored in a buffer and later processed in a background thread.
46
+ - Hybrid trigger: Log processing is triggered by a ticker and/or when a size threshold is reached.
47
+ - Batching: Multiple logs are combined into one request to the log server to minimize the amount of requests.
48
+ - Complete logs: All fields of a log record are transmitted including exceptions and `extra` fields.
49
+ - Highly customizable: The handler's behavior is highly customizable (see also [Documentation](#documentation))
50
+
51
+ ## Installation
52
+
53
+ The handler can be installed with PIP from PyPI:
54
+
55
+ ```sh
56
+ pip install victorialogs-handler
57
+ ```
58
+
59
+ ## Quick start
60
+
61
+ > [!NOTE]
62
+ > The script assumes that there is a VictoriaLogs server running
63
+ > on the same system at the default URL: `http://localhost:9428`
64
+
65
+ Here is a quick example on how to use the handler in your Python script:
66
+
67
+ ```python
68
+ import logging
69
+
70
+ from vlogs_handler import VictoriaLogsHandler
71
+
72
+ # Create a custom logger with INFO level
73
+ logger = logging.getLogger(__name__)
74
+ logger.setLevel(logging.INFO)
75
+
76
+ # Add a handler for VictoriaLogs
77
+ vlogs_handler = VictoriaLogsHandler()
78
+ vlogs_handler.setLevel(logging.DEBUG)
79
+ logger.addHandler(vlogs_handler)
80
+
81
+ # Log example
82
+ logger.info("This is an info message")
83
+ ```
84
+
85
+ Please see the directory `/examples` for additional examples on how to use the handler.
86
+
87
+ ## Documentation
88
+
89
+ The full documentation can be found here: [Documentation](https://erikkalkoken.github.io/python-victorialogs-handler/).
90
+
@@ -0,0 +1,62 @@
1
+ # victorialogs-handler
2
+
3
+ A high-performance Python log handler for VictoriaLogs.
4
+
5
+ [![release](https://img.shields.io/pypi/v/python-victorialogs-handler?label=release)](https://pypi.org/project/python-victorialogs-handler/)
6
+ [![python](https://img.shields.io/pypi/pyversions/python-victorialogs-handler)](https://pypi.org/project/python-victorialogs-handler/)
7
+ [![CI/CD](https://github.com/ErikKalkoken/python-victorialogs-handler/actions/workflows/cicd.yaml/badge.svg)](https://github.com/ErikKalkoken/python-victorialogs-handler/actions/workflows/cicd.yaml)
8
+ [![codecov](https://codecov.io/gh/ErikKalkoken/python-victorialogs-handler/graph/badge.svg?token=2pPb3lid2k)](https://codecov.io/gh/ErikKalkoken/python-victorialogs-handler)
9
+ [![license](https://img.shields.io/badge/license-MIT-green)](https://gitlab.com/ErikKalkoken/python-victorialogs-handler/-/blob/master/LICENSE)
10
+
11
+ > [!IMPORTANT]
12
+ > STATUS: In development. The API may still change.
13
+
14
+ ## Description
15
+
16
+ **victorialogs-handler** is a high-performance Python log handler tailored for [VictoriaLogs](https://victoriametrics.com/products/victorialogs/). It integrates seamlessly with Python’s native logging module, allowing you to stream log events to a VictoriaLogs instance with minimal configuration.
17
+
18
+ - Non-blocking: Logs are stored in a buffer and later processed in a background thread.
19
+ - Hybrid trigger: Log processing is triggered by a ticker and/or when a size threshold is reached.
20
+ - Batching: Multiple logs are combined into one request to the log server to minimize the amount of requests.
21
+ - Complete logs: All fields of a log record are transmitted including exceptions and `extra` fields.
22
+ - Highly customizable: The handler's behavior is highly customizable (see also [Documentation](#documentation))
23
+
24
+ ## Installation
25
+
26
+ The handler can be installed with PIP from PyPI:
27
+
28
+ ```sh
29
+ pip install victorialogs-handler
30
+ ```
31
+
32
+ ## Quick start
33
+
34
+ > [!NOTE]
35
+ > The script assumes that there is a VictoriaLogs server running
36
+ > on the same system at the default URL: `http://localhost:9428`
37
+
38
+ Here is a quick example on how to use the handler in your Python script:
39
+
40
+ ```python
41
+ import logging
42
+
43
+ from vlogs_handler import VictoriaLogsHandler
44
+
45
+ # Create a custom logger with INFO level
46
+ logger = logging.getLogger(__name__)
47
+ logger.setLevel(logging.INFO)
48
+
49
+ # Add a handler for VictoriaLogs
50
+ vlogs_handler = VictoriaLogsHandler()
51
+ vlogs_handler.setLevel(logging.DEBUG)
52
+ logger.addHandler(vlogs_handler)
53
+
54
+ # Log example
55
+ logger.info("This is an info message")
56
+ ```
57
+
58
+ Please see the directory `/examples` for additional examples on how to use the handler.
59
+
60
+ ## Documentation
61
+
62
+ The full documentation can be found here: [Documentation](https://erikkalkoken.github.io/python-victorialogs-handler/).
File without changes
@@ -0,0 +1,23 @@
1
+ """
2
+ This script demonstrates the basics on how to setup
3
+ and use a logger with the vlogs handler.
4
+
5
+ Note that this script assumes that there is a vlogs server running
6
+ on the same system at the default URL.
7
+ """
8
+
9
+ import logging
10
+
11
+ from vlogs_handler import VictoriaLogsHandler
12
+
13
+ # Create a custom logger with INFO level
14
+ logger = logging.getLogger(__name__)
15
+ logger.setLevel(logging.INFO)
16
+
17
+ # Add a handler for VictoriaLogs
18
+ vlogs_handler = VictoriaLogsHandler()
19
+ vlogs_handler.setLevel(logging.DEBUG)
20
+ logger.addHandler(vlogs_handler)
21
+
22
+ # Log example
23
+ logger.info("This is an info message")
@@ -0,0 +1,50 @@
1
+ """
2
+ This script demonstrates how to setup and use a logger with the vlogs handler
3
+ with the dict config method.
4
+
5
+ Note that this script assumes that there is a vlogs server running
6
+ on the same system at the default URL.
7
+ """
8
+
9
+ import logging
10
+ import logging.config
11
+
12
+ # Define the configuration dictionary
13
+ LOGGING_CONFIG = {
14
+ "version": 1,
15
+ "disable_existing_loggers": False,
16
+ "formatters": {
17
+ "standard": {"format": "%(asctime)s [%(levelname)s] %(name)s: %(message)s"},
18
+ },
19
+ "handlers": {
20
+ "console": {
21
+ "class": "logging.StreamHandler",
22
+ "level": "DEBUG",
23
+ "formatter": "standard",
24
+ "stream": "ext://sys.stdout",
25
+ },
26
+ "vlogs": {
27
+ "class": "vlogs_handler.VictoriaLogsHandler",
28
+ "level": "DEBUG",
29
+ "flush_interval": 0.5,
30
+ },
31
+ },
32
+ "loggers": {
33
+ "": { # Root logger
34
+ "handlers": ["console", "vlogs"],
35
+ "level": "DEBUG",
36
+ },
37
+ },
38
+ }
39
+
40
+ # Apply the configuration
41
+ logging.config.dictConfig(LOGGING_CONFIG)
42
+
43
+
44
+ # Create and use the logger
45
+ logger = logging.getLogger(__name__)
46
+
47
+ # Record log events
48
+ logger.debug("dict_example: This is a debug message")
49
+ logger.info("dict_example: This is an info message")
50
+ logger.error("dict_example: This is an error message")
@@ -0,0 +1,45 @@
1
+ """
2
+ This script can be used to explore the behavior of the vlogs handler
3
+ during execution of a longer running script or application.
4
+
5
+ It sets up a logger with output to console and vlogs
6
+ and configures the vlogs logger to output to the console as well.
7
+
8
+ Note that this script assumes that there is a vlogs server running
9
+ on the same system at the default URL.
10
+ """
11
+
12
+ import datetime as dt
13
+ import logging
14
+ import time
15
+
16
+ from vlogs_handler import VictoriaLogsHandler
17
+
18
+ # Create a custom logger
19
+ logger = logging.getLogger(__name__)
20
+ logger.setLevel(logging.DEBUG) # Set the lowest level to capture
21
+
22
+ # Add a handler for console logging
23
+ console_handler = logging.StreamHandler()
24
+ console_handler.setLevel(logging.DEBUG)
25
+ log_format = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
26
+ console_handler.setFormatter(log_format)
27
+ logger.addHandler(console_handler)
28
+
29
+ # Configure the vlogs logger to output to console
30
+ vlogs_logger = logging.getLogger("vlogs_handler")
31
+ vlogs_logger.setLevel(logging.DEBUG)
32
+ vlogs_logger.addHandler(console_handler)
33
+
34
+ # Add a vlogs handler
35
+ stream = dt.datetime.now(tz=dt.UTC).strftime("%Y%m%dT%H%M%S") # Unique ID for grouping
36
+ vlogs_handler = VictoriaLogsHandler(batch_size=30, record_to_stream=lambda _: stream)
37
+ vlogs_handler.setLevel(logging.DEBUG)
38
+ logger.addHandler(vlogs_handler)
39
+
40
+
41
+ i = 0
42
+ while True:
43
+ i += 1
44
+ logger.info("%d: This is an info message", i)
45
+ time.sleep(0.1)