gpclog 0.2.0__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.
- gpclog-0.2.0/.github/workflows/python-publish.yml +71 -0
- gpclog-0.2.0/.gitignore +197 -0
- gpclog-0.2.0/LICENSE +21 -0
- gpclog-0.2.0/PKG-INFO +114 -0
- gpclog-0.2.0/README.md +79 -0
- gpclog-0.2.0/README.zh-CN.md +79 -0
- gpclog-0.2.0/docs/config.md +357 -0
- gpclog-0.2.0/docs/gpclog.md +280 -0
- gpclog-0.2.0/docs/index.md +307 -0
- gpclog-0.2.0/docs/logger.md +338 -0
- gpclog-0.2.0/docs/zh/config.md +357 -0
- gpclog-0.2.0/docs/zh/gpclog.md +280 -0
- gpclog-0.2.0/docs/zh/index.md +307 -0
- gpclog-0.2.0/docs/zh/logger.md +338 -0
- gpclog-0.2.0/mkdocs.yml +54 -0
- gpclog-0.2.0/pyproject.toml +61 -0
- gpclog-0.2.0/src/gpclog/__init__.py +91 -0
- gpclog-0.2.0/src/gpclog/config.py +55 -0
- gpclog-0.2.0/src/gpclog/logger.py +149 -0
- gpclog-0.2.0/src/gpclog/manager.py +201 -0
- gpclog-0.2.0/src/gpclog/utils.py +60 -0
- gpclog-0.2.0/tests/__init__.py +1 -0
- gpclog-0.2.0/tests/mocks/config/global_env.yaml +3 -0
- gpclog-0.2.0/tests/mocks/config/logs/database.yaml +15 -0
- gpclog-0.2.0/tests/mocks/config/logs/event_bus.yaml +15 -0
- gpclog-0.2.0/tests/mocks/config/logs/ui.yaml +15 -0
- gpclog-0.2.0/tests/test_api.py +79 -0
- gpclog-0.2.0/tests/test_config.py +64 -0
- gpclog-0.2.0/tests/test_integration.py +341 -0
- gpclog-0.2.0/tests/test_logger.py +119 -0
- gpclog-0.2.0/tests/test_manager.py +133 -0
- gpclog-0.2.0/tests/test_utils.py +84 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# This workflow will upload a Python Package to PyPI when a release is created
|
|
2
|
+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
|
|
3
|
+
|
|
4
|
+
# This workflow uses actions that are not certified by GitHub.
|
|
5
|
+
# They are provided by a third-party and are governed by
|
|
6
|
+
# separate terms of service, privacy policy, and support
|
|
7
|
+
# documentation.
|
|
8
|
+
|
|
9
|
+
name: Upload Python Package
|
|
10
|
+
|
|
11
|
+
on:
|
|
12
|
+
release:
|
|
13
|
+
types: [published]
|
|
14
|
+
workflow_dispatch:
|
|
15
|
+
|
|
16
|
+
permissions:
|
|
17
|
+
contents: read
|
|
18
|
+
|
|
19
|
+
jobs:
|
|
20
|
+
release-build:
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v5
|
|
25
|
+
|
|
26
|
+
- uses: actions/setup-python@v6
|
|
27
|
+
with:
|
|
28
|
+
python-version: "3.x"
|
|
29
|
+
|
|
30
|
+
- name: Build release distributions
|
|
31
|
+
run: |
|
|
32
|
+
# NOTE: put your own distribution build steps here.
|
|
33
|
+
python -m pip install build
|
|
34
|
+
python -m build
|
|
35
|
+
|
|
36
|
+
- name: Upload distributions
|
|
37
|
+
uses: actions/upload-artifact@v5
|
|
38
|
+
with:
|
|
39
|
+
name: release-dists
|
|
40
|
+
path: dist/
|
|
41
|
+
|
|
42
|
+
pypi-publish:
|
|
43
|
+
runs-on: ubuntu-latest
|
|
44
|
+
needs:
|
|
45
|
+
- release-build
|
|
46
|
+
permissions:
|
|
47
|
+
# IMPORTANT: this permission is mandatory for trusted publishing
|
|
48
|
+
id-token: write
|
|
49
|
+
|
|
50
|
+
# Dedicated environments with protections for publishing are strongly recommended.
|
|
51
|
+
# For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
|
|
52
|
+
environment:
|
|
53
|
+
name: pypi
|
|
54
|
+
# OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status:
|
|
55
|
+
url: https://pypi.org/project/gpclog
|
|
56
|
+
#
|
|
57
|
+
# ALTERNATIVE: if your GitHub Release name is the PyPI project version string
|
|
58
|
+
# ALTERNATIVE: exactly, uncomment the following line instead:
|
|
59
|
+
# url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }}
|
|
60
|
+
|
|
61
|
+
steps:
|
|
62
|
+
- name: Retrieve release distributions
|
|
63
|
+
uses: actions/download-artifact@v5
|
|
64
|
+
with:
|
|
65
|
+
name: release-dists
|
|
66
|
+
path: dist/
|
|
67
|
+
|
|
68
|
+
- name: Publish release distributions to PyPI
|
|
69
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
70
|
+
with:
|
|
71
|
+
packages-dir: dist/
|
gpclog-0.2.0/.gitignore
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# git
|
|
10
|
+
.git/
|
|
11
|
+
.worktrees/
|
|
12
|
+
|
|
13
|
+
# Distribution / packaging
|
|
14
|
+
.Python
|
|
15
|
+
build/
|
|
16
|
+
develop-eggs/
|
|
17
|
+
dist/
|
|
18
|
+
downloads/
|
|
19
|
+
eggs/
|
|
20
|
+
.eggs/
|
|
21
|
+
lib/
|
|
22
|
+
lib64/
|
|
23
|
+
parts/
|
|
24
|
+
sdist/
|
|
25
|
+
var/
|
|
26
|
+
wheels/
|
|
27
|
+
share/python-wheels/
|
|
28
|
+
*.egg-info/
|
|
29
|
+
.installed.cfg
|
|
30
|
+
*.egg
|
|
31
|
+
MANIFEST
|
|
32
|
+
|
|
33
|
+
# PyInstaller
|
|
34
|
+
*.manifest
|
|
35
|
+
*.spec
|
|
36
|
+
|
|
37
|
+
# Installer logs
|
|
38
|
+
pip-log.txt
|
|
39
|
+
pip-delete-this-directory.txt
|
|
40
|
+
|
|
41
|
+
# Unit test / coverage reports
|
|
42
|
+
htmlcov/
|
|
43
|
+
.tox/
|
|
44
|
+
.nox/
|
|
45
|
+
.coverage
|
|
46
|
+
.coverage.*
|
|
47
|
+
.cache
|
|
48
|
+
nosetests.xml
|
|
49
|
+
coverage.xml
|
|
50
|
+
*.cover
|
|
51
|
+
*.py.cover
|
|
52
|
+
.hypothesis/
|
|
53
|
+
.pytest_cache/
|
|
54
|
+
cover/
|
|
55
|
+
|
|
56
|
+
# Translations
|
|
57
|
+
*.mo
|
|
58
|
+
*.pot
|
|
59
|
+
|
|
60
|
+
# Django stuff:
|
|
61
|
+
*.log
|
|
62
|
+
local_settings.py
|
|
63
|
+
db.sqlite3
|
|
64
|
+
db.sqlite3-journal
|
|
65
|
+
|
|
66
|
+
# Flask stuff:
|
|
67
|
+
instance/
|
|
68
|
+
.webassets-cache
|
|
69
|
+
|
|
70
|
+
# Scrapy stuff:
|
|
71
|
+
.scrapy
|
|
72
|
+
|
|
73
|
+
# Sphinx documentation
|
|
74
|
+
docs/_build/
|
|
75
|
+
|
|
76
|
+
# PyBuilder
|
|
77
|
+
.pybuilder/
|
|
78
|
+
target/
|
|
79
|
+
|
|
80
|
+
# Jupyter Notebook
|
|
81
|
+
.ipynb_checkpoints
|
|
82
|
+
|
|
83
|
+
# IPython
|
|
84
|
+
profile_default/
|
|
85
|
+
ipython_config.py
|
|
86
|
+
|
|
87
|
+
# pyenv
|
|
88
|
+
.python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
Pipfile.lock
|
|
92
|
+
|
|
93
|
+
# UV
|
|
94
|
+
uv.lock
|
|
95
|
+
|
|
96
|
+
# poetry
|
|
97
|
+
poetry.lock
|
|
98
|
+
poetry.toml
|
|
99
|
+
|
|
100
|
+
# pdm
|
|
101
|
+
pdm.lock
|
|
102
|
+
pdm.toml
|
|
103
|
+
.pdm-python
|
|
104
|
+
.pdm-build/
|
|
105
|
+
|
|
106
|
+
# pixi
|
|
107
|
+
.pixi
|
|
108
|
+
|
|
109
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
110
|
+
__pypackages__/
|
|
111
|
+
|
|
112
|
+
# Celery stuff
|
|
113
|
+
celerybeat-schedule
|
|
114
|
+
celerybeat.pid
|
|
115
|
+
|
|
116
|
+
# SageMath parsed files
|
|
117
|
+
*.sage.py
|
|
118
|
+
|
|
119
|
+
# Environments
|
|
120
|
+
.env
|
|
121
|
+
.envrc
|
|
122
|
+
.venv
|
|
123
|
+
env/
|
|
124
|
+
venv/
|
|
125
|
+
ENV/
|
|
126
|
+
env.bak/
|
|
127
|
+
venv.bak/
|
|
128
|
+
|
|
129
|
+
# Spyder project settings
|
|
130
|
+
.spyderproject
|
|
131
|
+
.spyproject
|
|
132
|
+
|
|
133
|
+
# Rope project settings
|
|
134
|
+
.ropeproject
|
|
135
|
+
|
|
136
|
+
# mkdocs documentation
|
|
137
|
+
/site
|
|
138
|
+
|
|
139
|
+
# mypy
|
|
140
|
+
.mypy_cache/
|
|
141
|
+
.dmypy.json
|
|
142
|
+
dmypy.json
|
|
143
|
+
|
|
144
|
+
# Pyre type checker
|
|
145
|
+
.pyre/
|
|
146
|
+
|
|
147
|
+
# pytype static type analyzer
|
|
148
|
+
.pytype/
|
|
149
|
+
|
|
150
|
+
# Cython debug symbols
|
|
151
|
+
cython_debug/
|
|
152
|
+
|
|
153
|
+
# PyCharm
|
|
154
|
+
.idea/
|
|
155
|
+
|
|
156
|
+
# Abstra
|
|
157
|
+
.abstra/
|
|
158
|
+
|
|
159
|
+
# Visual Studio Code
|
|
160
|
+
.vscode/
|
|
161
|
+
|
|
162
|
+
# Ruff stuff:
|
|
163
|
+
.ruff_cache/
|
|
164
|
+
|
|
165
|
+
# PyPI configuration file
|
|
166
|
+
.pypirc
|
|
167
|
+
|
|
168
|
+
# Cursor
|
|
169
|
+
.cursorignore
|
|
170
|
+
.cursorindexingignore
|
|
171
|
+
|
|
172
|
+
# Calude Code
|
|
173
|
+
CLAUDE.md
|
|
174
|
+
.claude/
|
|
175
|
+
|
|
176
|
+
# OpenCode
|
|
177
|
+
AGENTS.md
|
|
178
|
+
.opencode/
|
|
179
|
+
|
|
180
|
+
# Github Copilot
|
|
181
|
+
.github/copilot-instructions.md
|
|
182
|
+
|
|
183
|
+
# Marimo
|
|
184
|
+
marimo/_static/
|
|
185
|
+
marimo/_lsp/
|
|
186
|
+
__marimo__/
|
|
187
|
+
|
|
188
|
+
# User drafts
|
|
189
|
+
draft/
|
|
190
|
+
dev_docs/
|
|
191
|
+
|
|
192
|
+
# user progress
|
|
193
|
+
PROGRESS.md
|
|
194
|
+
progress.md
|
|
195
|
+
|
|
196
|
+
# user ignore
|
|
197
|
+
tests/mocks/log/
|
gpclog-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Linnet Codes <linnet.codes@gmail.com>
|
|
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 all
|
|
13
|
+
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 THE
|
|
21
|
+
SOFTWARE.
|
gpclog-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gpclog
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: General Purpose Category Logger - A Python library for managing categorized logs in complex projects.
|
|
5
|
+
Project-URL: Homepage, https://github.com/linnetcodes/gpclog
|
|
6
|
+
Project-URL: Documentation, https://linnetcodes.github.io/gpclog
|
|
7
|
+
Project-URL: Repository, https://github.com/linnetcodes/gpclog
|
|
8
|
+
Project-URL: Issues, https://github.com/linnetcodes/gpclog/issues
|
|
9
|
+
Author-email: Linnet Codes <linnet.codes@gmail.com>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: categorized-logging,gpconfig,logging,loguru,python
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
25
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
26
|
+
Classifier: Topic :: System :: Logging
|
|
27
|
+
Requires-Python: >=3.10
|
|
28
|
+
Requires-Dist: gpconfig>=0.3.0
|
|
29
|
+
Requires-Dist: loguru>=0.7.0
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: ruff>=0.4.0; extra == 'dev'
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# gpclog
|
|
37
|
+
|
|
38
|
+
[简体中文](README.zh-CN.md) | English
|
|
39
|
+
|
|
40
|
+
General Purpose Category Logger - A Python library for managing categorized logs in complex projects.
|
|
41
|
+
|
|
42
|
+
## Features
|
|
43
|
+
|
|
44
|
+
- **Category-based Logging** - Each category has its own configuration and file
|
|
45
|
+
- **Built on loguru** - High-performance, feature-rich logging core
|
|
46
|
+
- **Built on gpconfig** - Type-safe configuration management
|
|
47
|
+
- **Smart Defaults** - Works out of the box with zero configuration
|
|
48
|
+
- **Auto Class Registration** - Automatically registers with GPConfigManager on import
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install gpclog
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Quick Start
|
|
57
|
+
|
|
58
|
+
### Basic Usage
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
import gpclog
|
|
62
|
+
|
|
63
|
+
# Get a category logger (zero configuration)
|
|
64
|
+
logger = gpclog.get_logger("my_category")
|
|
65
|
+
logger.info("Hello, gpclog!")
|
|
66
|
+
# Output to: ~/gpclog_output/my_category.log
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Using Configuration Files
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
import gpclog
|
|
73
|
+
from gpconfig import GPConfigManager
|
|
74
|
+
|
|
75
|
+
# Initialize GPConfigManager (GPCLoggerConfig and GPCLogger are auto-registered)
|
|
76
|
+
manager = GPConfigManager("myapp")
|
|
77
|
+
|
|
78
|
+
# Method 1: Using gpclog public API
|
|
79
|
+
logs_folder = manager.get_config("logs")
|
|
80
|
+
gpclog.set_config_folder(logs_folder)
|
|
81
|
+
logger = gpclog.get_logger("database")
|
|
82
|
+
|
|
83
|
+
# Method 2: Using GPConfigManager directly
|
|
84
|
+
logger = manager.get_object("logs.database")
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Configuration schema, multiprocess usage, rotation/retention, and API details are documented in `docs/`.
|
|
88
|
+
|
|
89
|
+
## Documentation
|
|
90
|
+
|
|
91
|
+
Build and validate the documentation locally:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
venv/bin/mkdocs build --clean --strict
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Preview the documentation locally:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
venv/bin/mkdocs serve
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## API Reference
|
|
104
|
+
|
|
105
|
+
See:
|
|
106
|
+
|
|
107
|
+
- [Docs home](docs/index.md)
|
|
108
|
+
- [gpclog module](docs/gpclog.md)
|
|
109
|
+
- [GPCLogger](docs/logger.md)
|
|
110
|
+
- [GPCLoggerConfig](docs/config.md)
|
|
111
|
+
|
|
112
|
+
## License
|
|
113
|
+
|
|
114
|
+
MIT
|
gpclog-0.2.0/README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# gpclog
|
|
2
|
+
|
|
3
|
+
[简体中文](README.zh-CN.md) | English
|
|
4
|
+
|
|
5
|
+
General Purpose Category Logger - A Python library for managing categorized logs in complex projects.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Category-based Logging** - Each category has its own configuration and file
|
|
10
|
+
- **Built on loguru** - High-performance, feature-rich logging core
|
|
11
|
+
- **Built on gpconfig** - Type-safe configuration management
|
|
12
|
+
- **Smart Defaults** - Works out of the box with zero configuration
|
|
13
|
+
- **Auto Class Registration** - Automatically registers with GPConfigManager on import
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install gpclog
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
### Basic Usage
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
import gpclog
|
|
27
|
+
|
|
28
|
+
# Get a category logger (zero configuration)
|
|
29
|
+
logger = gpclog.get_logger("my_category")
|
|
30
|
+
logger.info("Hello, gpclog!")
|
|
31
|
+
# Output to: ~/gpclog_output/my_category.log
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Using Configuration Files
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
import gpclog
|
|
38
|
+
from gpconfig import GPConfigManager
|
|
39
|
+
|
|
40
|
+
# Initialize GPConfigManager (GPCLoggerConfig and GPCLogger are auto-registered)
|
|
41
|
+
manager = GPConfigManager("myapp")
|
|
42
|
+
|
|
43
|
+
# Method 1: Using gpclog public API
|
|
44
|
+
logs_folder = manager.get_config("logs")
|
|
45
|
+
gpclog.set_config_folder(logs_folder)
|
|
46
|
+
logger = gpclog.get_logger("database")
|
|
47
|
+
|
|
48
|
+
# Method 2: Using GPConfigManager directly
|
|
49
|
+
logger = manager.get_object("logs.database")
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Configuration schema, multiprocess usage, rotation/retention, and API details are documented in `docs/`.
|
|
53
|
+
|
|
54
|
+
## Documentation
|
|
55
|
+
|
|
56
|
+
Build and validate the documentation locally:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
venv/bin/mkdocs build --clean --strict
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Preview the documentation locally:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
venv/bin/mkdocs serve
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## API Reference
|
|
69
|
+
|
|
70
|
+
See:
|
|
71
|
+
|
|
72
|
+
- [Docs home](docs/index.md)
|
|
73
|
+
- [gpclog module](docs/gpclog.md)
|
|
74
|
+
- [GPCLogger](docs/logger.md)
|
|
75
|
+
- [GPCLoggerConfig](docs/config.md)
|
|
76
|
+
|
|
77
|
+
## License
|
|
78
|
+
|
|
79
|
+
MIT
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# gpclog
|
|
2
|
+
|
|
3
|
+
简体中文 | [English](README.md)
|
|
4
|
+
|
|
5
|
+
General Purpose Category Logger - 用于在复杂 Python 项目里管理分类日志。
|
|
6
|
+
|
|
7
|
+
## 特性
|
|
8
|
+
|
|
9
|
+
- **分类日志管理** - 每个日志类别独立配置、独立文件
|
|
10
|
+
- **基于 loguru** - 高性能、功能丰富的日志核心
|
|
11
|
+
- **基于 gpconfig** - 类型安全的配置管理
|
|
12
|
+
- **智能默认配置** - 零配置即可使用
|
|
13
|
+
- **自动类注册** - 导入即自动注册到 GPConfigManager
|
|
14
|
+
|
|
15
|
+
## 安装
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install gpclog
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 快速开始
|
|
22
|
+
|
|
23
|
+
### 基本使用
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
import gpclog
|
|
27
|
+
|
|
28
|
+
# 获取一个分类日志器(零配置)
|
|
29
|
+
logger = gpclog.get_logger("my_category")
|
|
30
|
+
logger.info("Hello, gpclog!")
|
|
31
|
+
# 输出到: ~/gpclog_output/my_category.log
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### 使用配置文件
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
import gpclog
|
|
38
|
+
from gpconfig import GPConfigManager
|
|
39
|
+
|
|
40
|
+
# 初始化 GPConfigManager(GPCLoggerConfig 和 GPCLogger 已自动注册)
|
|
41
|
+
manager = GPConfigManager("myapp")
|
|
42
|
+
|
|
43
|
+
# 方式 1:使用 gpclog 公共 API
|
|
44
|
+
logs_folder = manager.get_config("logs")
|
|
45
|
+
gpclog.set_config_folder(logs_folder)
|
|
46
|
+
logger = gpclog.get_logger("database")
|
|
47
|
+
|
|
48
|
+
# 方式 2:使用 GPConfigManager 直接创建
|
|
49
|
+
logger = manager.get_object("logs.database")
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
配置结构、多进程用法、轮转/保留策略以及完整 API 说明请查看 `docs/`。
|
|
53
|
+
|
|
54
|
+
## 文档
|
|
55
|
+
|
|
56
|
+
本地构建并校验文档:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
venv/bin/mkdocs build --clean --strict
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
本地预览文档:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
venv/bin/mkdocs serve
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## API 参考
|
|
69
|
+
|
|
70
|
+
详见:
|
|
71
|
+
|
|
72
|
+
- [文档首页](docs/zh/index.md)
|
|
73
|
+
- [gpclog 模块](docs/zh/gpclog.md)
|
|
74
|
+
- [GPCLogger 类](docs/zh/logger.md)
|
|
75
|
+
- [GPCLoggerConfig 类](docs/zh/config.md)
|
|
76
|
+
|
|
77
|
+
## 许可证
|
|
78
|
+
|
|
79
|
+
MIT
|