logust 0.4.2__tar.gz → 0.5.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.
- {logust-0.4.2 → logust-0.5.0}/.github/workflows/CI.yml +1 -1
- {logust-0.4.2 → logust-0.5.0}/.github/workflows/freethreaded-release.yml +1 -1
- {logust-0.4.2 → logust-0.5.0}/.github/workflows/release-drafter.yml +0 -2
- {logust-0.4.2 → logust-0.5.0}/.github/workflows/test.yml +4 -4
- {logust-0.4.2 → logust-0.5.0}/CHANGELOG.md +17 -1
- {logust-0.4.2 → logust-0.5.0}/Cargo.lock +50 -43
- {logust-0.4.2 → logust-0.5.0}/Cargo.toml +1 -1
- {logust-0.4.2 → logust-0.5.0}/PKG-INFO +1 -1
- {logust-0.4.2 → logust-0.5.0}/docs/comparison.md +16 -0
- {logust-0.4.2 → logust-0.5.0}/docs/guide/integrations.md +54 -0
- logust-0.5.0/examples/09_rich_progress.py +47 -0
- {logust-0.4.2 → logust-0.5.0}/examples/README.md +1 -0
- {logust-0.4.2 → logust-0.5.0}/logust/__init__.py +2 -2
- {logust-0.4.2 → logust-0.5.0}/logust/_logger.py +77 -17
- {logust-0.4.2 → logust-0.5.0}/logust/_logust.pyi +23 -0
- {logust-0.4.2 → logust-0.5.0}/logust/_template.py +111 -13
- {logust-0.4.2 → logust-0.5.0}/prek.toml +4 -4
- {logust-0.4.2 → logust-0.5.0}/pyproject.toml +1 -0
- {logust-0.4.2 → logust-0.5.0}/src/format.rs +336 -248
- {logust-0.4.2 → logust-0.5.0}/src/handler.rs +10 -2
- {logust-0.4.2 → logust-0.5.0}/src/lib.rs +52 -2
- logust-0.5.0/tests/test_colorize.py +188 -0
- logust-0.5.0/tests/test_markup_strip.py +76 -0
- logust-0.5.0/tests/test_rich_progress.py +65 -0
- logust-0.5.0/tests/test_stream_sink.py +117 -0
- {logust-0.4.2 → logust-0.5.0}/.github/CODEOWNERS +0 -0
- {logust-0.4.2 → logust-0.5.0}/.github/FUNDING.yml +0 -0
- {logust-0.4.2 → logust-0.5.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {logust-0.4.2 → logust-0.5.0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {logust-0.4.2 → logust-0.5.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {logust-0.4.2 → logust-0.5.0}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {logust-0.4.2 → logust-0.5.0}/.github/release-drafter.yml +0 -0
- {logust-0.4.2 → logust-0.5.0}/.github/workflows/docs.yml +0 -0
- {logust-0.4.2 → logust-0.5.0}/.github/workflows/security.yml +0 -0
- {logust-0.4.2 → logust-0.5.0}/.gitignore +0 -0
- {logust-0.4.2 → logust-0.5.0}/CODE_OF_CONDUCT.md +0 -0
- {logust-0.4.2 → logust-0.5.0}/CONTRIBUTING.md +0 -0
- {logust-0.4.2 → logust-0.5.0}/LICENSE +0 -0
- {logust-0.4.2 → logust-0.5.0}/README.md +0 -0
- {logust-0.4.2 → logust-0.5.0}/SECURITY.md +0 -0
- {logust-0.4.2 → logust-0.5.0}/benchmarks/README.md +0 -0
- {logust-0.4.2 → logust-0.5.0}/benchmarks/__init__.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/benchmarks/bench_filter_mixed.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/benchmarks/bench_format_record.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/benchmarks/bench_lazy_is_level.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/benchmarks/bench_throughput.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/benchmarks/conftest.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/docs/api.md +0 -0
- {logust-0.4.2 → logust-0.5.0}/docs/assets/favicon.svg +0 -0
- {logust-0.4.2 → logust-0.5.0}/docs/assets/logo.svg +0 -0
- {logust-0.4.2 → logust-0.5.0}/docs/getting-started/installation.md +0 -0
- {logust-0.4.2 → logust-0.5.0}/docs/getting-started/quick-start.md +0 -0
- {logust-0.4.2 → logust-0.5.0}/docs/guide/canonical-events.md +0 -0
- {logust-0.4.2 → logust-0.5.0}/docs/guide/context.md +0 -0
- {logust-0.4.2 → logust-0.5.0}/docs/guide/exceptions.md +0 -0
- {logust-0.4.2 → logust-0.5.0}/docs/guide/file-output.md +0 -0
- {logust-0.4.2 → logust-0.5.0}/docs/guide/formatting.md +0 -0
- {logust-0.4.2 → logust-0.5.0}/docs/guide/levels.md +0 -0
- {logust-0.4.2 → logust-0.5.0}/docs/index.md +0 -0
- {logust-0.4.2 → logust-0.5.0}/docs/stylesheets/extra.css +0 -0
- {logust-0.4.2 → logust-0.5.0}/examples/01_basic_logging.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/examples/02_file_output.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/examples/03_json_serialization.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/examples/04_context_binding.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/examples/05_exception_handling.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/examples/06_custom_levels.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/examples/07_callbacks.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/examples/08_fastapi_integration.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/logust/_opt.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/logust/_parse.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/logust/_traceback.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/logust/_types.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/logust/contrib/__init__.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/logust/contrib/decorators.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/logust/contrib/events.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/logust/contrib/logging_handler.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/logust/contrib/starlette.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/logust/py.typed +0 -0
- {logust-0.4.2 → logust-0.5.0}/mkdocs.yml +0 -0
- {logust-0.4.2 → logust-0.5.0}/renovate.json +0 -0
- {logust-0.4.2 → logust-0.5.0}/src/level.rs +0 -0
- {logust-0.4.2 → logust-0.5.0}/src/sink.rs +0 -0
- {logust-0.4.2 → logust-0.5.0}/tests/__init__.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/tests/conftest.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/tests/test_callable_sink.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/tests/test_callable_template.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/tests/test_callbacks.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/tests/test_caller_info.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/tests/test_canonical_events.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/tests/test_collect_options.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/tests/test_configure.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/tests/test_context.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/tests/test_filter_fast_path.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/tests/test_format_optimization.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/tests/test_format_tokens.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/tests/test_handlers.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/tests/test_kwargs_extra.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/tests/test_levels.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/tests/test_logger.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/tests/test_multiprocessing.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/tests/test_opt.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/tests/test_parsing.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/tests/test_starlette_middleware.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/tests/test_starlette_security.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/tests/test_token_registry.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/tests/test_typed_json_extra.py +0 -0
- {logust-0.4.2 → logust-0.5.0}/tests/test_web_integration.py +0 -0
|
@@ -172,7 +172,7 @@ jobs:
|
|
|
172
172
|
subject-path: 'wheels-*/*'
|
|
173
173
|
- name: Install uv
|
|
174
174
|
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
|
175
|
-
uses: astral-sh/setup-uv@
|
|
175
|
+
uses: astral-sh/setup-uv@v10.2.0
|
|
176
176
|
- name: Publish to PyPI
|
|
177
177
|
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
|
178
178
|
run: uv publish --trusted-publishing always --check-url https://pypi.org/simple/ 'wheels-*/*'
|
|
@@ -116,7 +116,7 @@ jobs:
|
|
|
116
116
|
subject-path: 'wheels-*/*'
|
|
117
117
|
- name: Install uv
|
|
118
118
|
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
|
119
|
-
uses: astral-sh/setup-uv@
|
|
119
|
+
uses: astral-sh/setup-uv@v10.2.0
|
|
120
120
|
- name: Publish to PyPI
|
|
121
121
|
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
|
122
122
|
run: uv publish --trusted-publishing always --check-url https://pypi.org/simple/ 'wheels-*/*'
|
|
@@ -66,12 +66,12 @@ jobs:
|
|
|
66
66
|
uses: dtolnay/rust-toolchain@stable
|
|
67
67
|
|
|
68
68
|
- name: Install uv
|
|
69
|
-
uses: astral-sh/setup-uv@
|
|
69
|
+
uses: astral-sh/setup-uv@v10.2.0
|
|
70
70
|
|
|
71
71
|
- name: Install dependencies and build
|
|
72
72
|
run: |
|
|
73
73
|
uv venv
|
|
74
|
-
uv pip install maturin pytest pytest-cov
|
|
74
|
+
uv pip install maturin pytest pytest-cov rich
|
|
75
75
|
uv run maturin develop
|
|
76
76
|
|
|
77
77
|
- name: Run tests
|
|
@@ -99,7 +99,7 @@ jobs:
|
|
|
99
99
|
uses: dtolnay/rust-toolchain@stable
|
|
100
100
|
|
|
101
101
|
- name: Install uv
|
|
102
|
-
uses: astral-sh/setup-uv@
|
|
102
|
+
uses: astral-sh/setup-uv@v10.2.0
|
|
103
103
|
|
|
104
104
|
- name: Install dependencies and build
|
|
105
105
|
run: |
|
|
@@ -125,7 +125,7 @@ jobs:
|
|
|
125
125
|
uses: dtolnay/rust-toolchain@stable
|
|
126
126
|
|
|
127
127
|
- name: Install uv
|
|
128
|
-
uses: astral-sh/setup-uv@
|
|
128
|
+
uses: astral-sh/setup-uv@v10.2.0
|
|
129
129
|
|
|
130
130
|
- name: Install dependencies and build
|
|
131
131
|
run: |
|
|
@@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.5.0] - 2026-10-01
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- **Stream sinks**: `logger.add()` accepts any object with a callable `write()` (e.g. `io.StringIO`, a redirected `sys.stdout`). Only `sys.__stdout__` / `sys.__stderr__` use the Rust fast path. Item 1 from issue #59 (#64)
|
|
14
|
+
- **`colorize` for every sink type**: callable and file sinks accept `colorize=True` (level colors, token styles, message markup). Item 2 from issue #59 (#65)
|
|
15
|
+
- **`rich` progress bar example**: `examples/09_rich_progress.py` logs above a live progress bar. (#65)
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
- **Color markup is stripped from non-colorized output**: Item 3 from issue #59 (#61)
|
|
19
|
+
- **Stream `colorize` auto-detection follows loguru**: `NO_COLOR`, `FORCE_COLOR`, CI, PyCharm, Jupyter, and `TERM=dumb` are honored before `isatty()`. `serialize=True`, file, and callable sinks default to no color. (#65)
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
- **Color markup in the `format` string**: tags such as `<green>{time}</green>` and loguru's `<level>...</level>` are rendered when colorized and stripped otherwise, on every sink type. A token inside markup takes the markup's color instead of its default style. (#66)
|
|
23
|
+
- **Callable sinks include tracebacks**: formatted callable sinks now append the exception text, the same as file and console sinks. (#64)
|
|
24
|
+
|
|
10
25
|
## [0.4.2] - 2026-08-06
|
|
11
26
|
|
|
12
27
|
### Changed
|
|
@@ -149,7 +164,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
149
164
|
- 1.3x faster than Python standard logging
|
|
150
165
|
- Lock-free fast path for filtered messages
|
|
151
166
|
|
|
152
|
-
[Unreleased]: https://github.com/yamaaaaaa31/logust/compare/v0.
|
|
167
|
+
[Unreleased]: https://github.com/yamaaaaaa31/logust/compare/v0.5.0...HEAD
|
|
168
|
+
[0.5.0]: https://github.com/yamaaaaaa31/logust/compare/v0.4.2...v0.5.0
|
|
153
169
|
[0.4.2]: https://github.com/yamaaaaaa31/logust/compare/v0.4.1...v0.4.2
|
|
154
170
|
[0.4.1]: https://github.com/yamaaaaaa31/logust/compare/v0.4.0...v0.4.1
|
|
155
171
|
[0.4.0]: https://github.com/yamaaaaaa31/logust/compare/v0.3.2...v0.4.0
|
|
@@ -31,9 +31,9 @@ checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
|
|
|
31
31
|
|
|
32
32
|
[[package]]
|
|
33
33
|
name = "cc"
|
|
34
|
-
version = "1.
|
|
34
|
+
version = "1.5.1"
|
|
35
35
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
36
|
-
checksum = "
|
|
36
|
+
checksum = "f360145194ee8e21db5ee7f3fcd4fe52210864c75c985dae33218202c8bbe040"
|
|
37
37
|
dependencies = [
|
|
38
38
|
"find-msvc-tools",
|
|
39
39
|
"shlex",
|
|
@@ -41,9 +41,9 @@ dependencies = [
|
|
|
41
41
|
|
|
42
42
|
[[package]]
|
|
43
43
|
name = "cfg-if"
|
|
44
|
-
version = "1.0.
|
|
44
|
+
version = "1.0.5"
|
|
45
45
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
46
|
-
checksum = "
|
|
46
|
+
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
|
|
47
47
|
|
|
48
48
|
[[package]]
|
|
49
49
|
name = "chrono"
|
|
@@ -76,61 +76,62 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
|
|
|
76
76
|
|
|
77
77
|
[[package]]
|
|
78
78
|
name = "crc32fast"
|
|
79
|
-
version = "1.5.
|
|
79
|
+
version = "1.5.2"
|
|
80
80
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
81
|
-
checksum = "
|
|
81
|
+
checksum = "01a7799fd6b852db0e61728dde9a204c423b44d689dbd432522543614b490e78"
|
|
82
82
|
dependencies = [
|
|
83
83
|
"cfg-if",
|
|
84
84
|
]
|
|
85
85
|
|
|
86
86
|
[[package]]
|
|
87
87
|
name = "crossbeam-channel"
|
|
88
|
-
version = "0.5.
|
|
88
|
+
version = "0.5.17"
|
|
89
89
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
90
|
-
checksum = "
|
|
90
|
+
checksum = "98b0cc327b5bc766e7fda9c9260cc0fa81b43a8e240440422dff70788e3f9ef1"
|
|
91
91
|
dependencies = [
|
|
92
92
|
"crossbeam-utils",
|
|
93
93
|
]
|
|
94
94
|
|
|
95
95
|
[[package]]
|
|
96
96
|
name = "crossbeam-utils"
|
|
97
|
-
version = "0.8.
|
|
97
|
+
version = "0.8.23"
|
|
98
98
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
99
|
-
checksum = "
|
|
99
|
+
checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6"
|
|
100
100
|
|
|
101
101
|
[[package]]
|
|
102
102
|
name = "find-msvc-tools"
|
|
103
|
-
version = "0.1.
|
|
103
|
+
version = "0.1.14"
|
|
104
104
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
105
|
-
checksum = "
|
|
105
|
+
checksum = "aedcfb3409746eddb02b9e19ebda1c3394f759a152e48ee875a0844d1b955484"
|
|
106
106
|
|
|
107
107
|
[[package]]
|
|
108
108
|
name = "flate2"
|
|
109
|
-
version = "1.1.
|
|
109
|
+
version = "1.1.10"
|
|
110
110
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
111
|
-
checksum = "
|
|
111
|
+
checksum = "6e634e2e0ebac1ee034020da1ca582e17ffe4e0f5e985823721e168928136dcb"
|
|
112
112
|
dependencies = [
|
|
113
113
|
"crc32fast",
|
|
114
114
|
"miniz_oxide",
|
|
115
|
+
"zlib-rs",
|
|
115
116
|
]
|
|
116
117
|
|
|
117
118
|
[[package]]
|
|
118
119
|
name = "futures-core"
|
|
119
|
-
version = "0.3.
|
|
120
|
+
version = "0.3.34"
|
|
120
121
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
121
|
-
checksum = "
|
|
122
|
+
checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e"
|
|
122
123
|
|
|
123
124
|
[[package]]
|
|
124
125
|
name = "futures-task"
|
|
125
|
-
version = "0.3.
|
|
126
|
+
version = "0.3.34"
|
|
126
127
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
127
|
-
checksum = "
|
|
128
|
+
checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd"
|
|
128
129
|
|
|
129
130
|
[[package]]
|
|
130
131
|
name = "futures-util"
|
|
131
|
-
version = "0.3.
|
|
132
|
+
version = "0.3.34"
|
|
132
133
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
133
|
-
checksum = "
|
|
134
|
+
checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc"
|
|
134
135
|
dependencies = [
|
|
135
136
|
"futures-core",
|
|
136
137
|
"futures-task",
|
|
@@ -176,9 +177,9 @@ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
|
|
|
176
177
|
|
|
177
178
|
[[package]]
|
|
178
179
|
name = "js-sys"
|
|
179
|
-
version = "0.3.
|
|
180
|
+
version = "0.3.106"
|
|
180
181
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
181
|
-
checksum = "
|
|
182
|
+
checksum = "7883d941dae510fb2d978fc3fe018c71c9e2892fd38854de3e8b92c2e5ad9cc5"
|
|
182
183
|
dependencies = [
|
|
183
184
|
"cfg-if",
|
|
184
185
|
"futures-util",
|
|
@@ -193,13 +194,13 @@ checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
|
|
|
193
194
|
|
|
194
195
|
[[package]]
|
|
195
196
|
name = "log"
|
|
196
|
-
version = "0.4.
|
|
197
|
+
version = "0.4.34"
|
|
197
198
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
198
|
-
checksum = "
|
|
199
|
+
checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"
|
|
199
200
|
|
|
200
201
|
[[package]]
|
|
201
202
|
name = "logust"
|
|
202
|
-
version = "0.
|
|
203
|
+
version = "0.5.0"
|
|
203
204
|
dependencies = [
|
|
204
205
|
"chrono",
|
|
205
206
|
"colored",
|
|
@@ -220,9 +221,9 @@ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
|
|
220
221
|
|
|
221
222
|
[[package]]
|
|
222
223
|
name = "miniz_oxide"
|
|
223
|
-
version = "0.
|
|
224
|
+
version = "0.9.1"
|
|
224
225
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
225
|
-
checksum = "
|
|
226
|
+
checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c"
|
|
226
227
|
dependencies = [
|
|
227
228
|
"adler2",
|
|
228
229
|
"simd-adler32",
|
|
@@ -251,9 +252,9 @@ checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
|
|
|
251
252
|
|
|
252
253
|
[[package]]
|
|
253
254
|
name = "portable-atomic"
|
|
254
|
-
version = "1.
|
|
255
|
+
version = "1.15.0"
|
|
255
256
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
256
|
-
checksum = "
|
|
257
|
+
checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
|
|
257
258
|
|
|
258
259
|
[[package]]
|
|
259
260
|
name = "proc-macro2"
|
|
@@ -363,7 +364,7 @@ checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
|
|
|
363
364
|
dependencies = [
|
|
364
365
|
"proc-macro2",
|
|
365
366
|
"quote",
|
|
366
|
-
"syn 3.0.
|
|
367
|
+
"syn 3.0.6",
|
|
367
368
|
]
|
|
368
369
|
|
|
369
370
|
[[package]]
|
|
@@ -410,9 +411,9 @@ dependencies = [
|
|
|
410
411
|
|
|
411
412
|
[[package]]
|
|
412
413
|
name = "syn"
|
|
413
|
-
version = "3.0.
|
|
414
|
+
version = "3.0.6"
|
|
414
415
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
415
|
-
checksum = "
|
|
416
|
+
checksum = "8593e8e72159ed2257d083c7a454a85cbf854f37a0966d8d483aff8c8a3ebcee"
|
|
416
417
|
dependencies = [
|
|
417
418
|
"proc-macro2",
|
|
418
419
|
"quote",
|
|
@@ -427,15 +428,15 @@ checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
|
|
|
427
428
|
|
|
428
429
|
[[package]]
|
|
429
430
|
name = "unicode-ident"
|
|
430
|
-
version = "1.0.
|
|
431
|
+
version = "1.0.26"
|
|
431
432
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
432
|
-
checksum = "
|
|
433
|
+
checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"
|
|
433
434
|
|
|
434
435
|
[[package]]
|
|
435
436
|
name = "wasm-bindgen"
|
|
436
|
-
version = "0.2.
|
|
437
|
+
version = "0.2.129"
|
|
437
438
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
438
|
-
checksum = "
|
|
439
|
+
checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409"
|
|
439
440
|
dependencies = [
|
|
440
441
|
"cfg-if",
|
|
441
442
|
"once_cell",
|
|
@@ -446,9 +447,9 @@ dependencies = [
|
|
|
446
447
|
|
|
447
448
|
[[package]]
|
|
448
449
|
name = "wasm-bindgen-macro"
|
|
449
|
-
version = "0.2.
|
|
450
|
+
version = "0.2.129"
|
|
450
451
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
451
|
-
checksum = "
|
|
452
|
+
checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535"
|
|
452
453
|
dependencies = [
|
|
453
454
|
"quote",
|
|
454
455
|
"wasm-bindgen-macro-support",
|
|
@@ -456,22 +457,22 @@ dependencies = [
|
|
|
456
457
|
|
|
457
458
|
[[package]]
|
|
458
459
|
name = "wasm-bindgen-macro-support"
|
|
459
|
-
version = "0.2.
|
|
460
|
+
version = "0.2.129"
|
|
460
461
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
461
|
-
checksum = "
|
|
462
|
+
checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7"
|
|
462
463
|
dependencies = [
|
|
463
464
|
"bumpalo",
|
|
464
465
|
"proc-macro2",
|
|
465
466
|
"quote",
|
|
466
|
-
"syn
|
|
467
|
+
"syn 3.0.6",
|
|
467
468
|
"wasm-bindgen-shared",
|
|
468
469
|
]
|
|
469
470
|
|
|
470
471
|
[[package]]
|
|
471
472
|
name = "wasm-bindgen-shared"
|
|
472
|
-
version = "0.2.
|
|
473
|
+
version = "0.2.129"
|
|
473
474
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
474
|
-
checksum = "
|
|
475
|
+
checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6"
|
|
475
476
|
dependencies = [
|
|
476
477
|
"unicode-ident",
|
|
477
478
|
]
|
|
@@ -544,6 +545,12 @@ dependencies = [
|
|
|
544
545
|
"windows-link",
|
|
545
546
|
]
|
|
546
547
|
|
|
548
|
+
[[package]]
|
|
549
|
+
name = "zlib-rs"
|
|
550
|
+
version = "0.6.8"
|
|
551
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
552
|
+
checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112"
|
|
553
|
+
|
|
547
554
|
[[package]]
|
|
548
555
|
name = "zmij"
|
|
549
556
|
version = "1.0.23"
|
|
@@ -90,6 +90,22 @@ logger.add("app.log", rotation="500 MB")
|
|
|
90
90
|
logger.info("Hello")
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
+
### Callable sinks receive no trailing newline
|
|
94
|
+
|
|
95
|
+
loguru passes callable sinks the formatted message **with** a trailing `"\n"`, so its recipes use `end=""`. Logust passes it **without** one, so drop `end=""` when porting:
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
# loguru
|
|
99
|
+
logger.add(lambda msg: tqdm.write(msg, end=""))
|
|
100
|
+
logger.add(lambda msg: print(msg, end=""))
|
|
101
|
+
|
|
102
|
+
# logust
|
|
103
|
+
logger.add(lambda msg: tqdm.write(msg))
|
|
104
|
+
logger.add(lambda msg: print(msg))
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Keeping `end=""` with logust joins every log line into one. Stream sinks (objects with a `write()` method, such as `sys.stdout` or `io.StringIO`) get a trailing newline in both libraries.
|
|
108
|
+
|
|
93
109
|
## When to choose logust
|
|
94
110
|
|
|
95
111
|
- Performance and throughput are critical
|
|
@@ -82,6 +82,60 @@ def slow_operation():
|
|
|
82
82
|
pass
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
+
## Progress Bars (rich, tqdm)
|
|
86
|
+
|
|
87
|
+
Live displays like `rich.progress.Progress` and `tqdm` redraw the bar around each line they print. Logust's default console handler writes straight to the process stdout, so its lines land in the middle of the bar. Replace it with a callable sink that prints through the progress bar's own API.
|
|
88
|
+
|
|
89
|
+
=== "rich"
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from rich.progress import Progress
|
|
93
|
+
from rich.text import Text
|
|
94
|
+
|
|
95
|
+
from logust import logger
|
|
96
|
+
|
|
97
|
+
logger.remove()
|
|
98
|
+
|
|
99
|
+
with Progress() as progress:
|
|
100
|
+
handler_id = logger.add(
|
|
101
|
+
lambda msg: progress.console.print(Text.from_ansi(msg)),
|
|
102
|
+
format="{time} | {level:<8} | {message}",
|
|
103
|
+
colorize=True,
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
task = progress.add_task("Processing", total=100)
|
|
107
|
+
for i in range(100):
|
|
108
|
+
if i % 25 == 0:
|
|
109
|
+
logger.info(f"Checkpoint <green>{i}</green> reached")
|
|
110
|
+
progress.advance(task)
|
|
111
|
+
|
|
112
|
+
logger.remove(handler_id)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
=== "tqdm"
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
from tqdm import tqdm
|
|
119
|
+
|
|
120
|
+
from logust import logger
|
|
121
|
+
|
|
122
|
+
logger.remove()
|
|
123
|
+
logger.add(lambda msg: tqdm.write(msg), colorize=True)
|
|
124
|
+
|
|
125
|
+
for i in tqdm(range(100)):
|
|
126
|
+
if i % 25 == 0:
|
|
127
|
+
logger.info(f"Checkpoint <green>{i}</green> reached")
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
- `colorize=True` gives the sink level colors and renders `<green>...</green>` markup, as on the console. Callable sinks default to no color.
|
|
131
|
+
- With rich, wrap the message in `Text.from_ansi()`. A plain string is parsed as rich markup, which mangles the ANSI codes.
|
|
132
|
+
- Don't pass `end=""`: logust hands callable sinks the message **without** a trailing newline (see [Comparison](../comparison.md#callable-sinks-receive-no-trailing-newline)).
|
|
133
|
+
|
|
134
|
+
!!! note "Add the sink after the display starts"
|
|
135
|
+
A sink is bound when `add()` is called. Adding `sys.stdout` before `rich` swaps it out does not make the two cooperate, so call `logger.remove()` and add the callable sink explicitly, as above. A stream added while the display is active (`logger.add(sys.stdout)` inside `with Progress():`) does go through rich's proxy.
|
|
136
|
+
|
|
137
|
+
See [`examples/09_rich_progress.py`](https://github.com/yamaaaaaa31/logust/blob/main/examples/09_rich_progress.py) for a runnable version.
|
|
138
|
+
|
|
85
139
|
## FastAPI / Starlette Middleware
|
|
86
140
|
|
|
87
141
|
Automatic request/response logging for web applications:
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Logging above a rich progress bar with Logust.
|
|
4
|
+
|
|
5
|
+
Logust's default console handler writes straight to the process stdout, which
|
|
6
|
+
corrupts a live rich display. Replace it with a callable sink that prints through
|
|
7
|
+
the progress console, so rich erases the bar, prints the log line, and redraws.
|
|
8
|
+
|
|
9
|
+
Requirements:
|
|
10
|
+
pip install rich
|
|
11
|
+
|
|
12
|
+
Run:
|
|
13
|
+
python examples/09_rich_progress.py
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import random
|
|
17
|
+
import time
|
|
18
|
+
|
|
19
|
+
from rich.progress import Progress
|
|
20
|
+
from rich.text import Text
|
|
21
|
+
|
|
22
|
+
from logust import logger
|
|
23
|
+
|
|
24
|
+
logger.remove()
|
|
25
|
+
|
|
26
|
+
with Progress() as progress:
|
|
27
|
+
handler_id = logger.add(
|
|
28
|
+
lambda msg: progress.console.print(Text.from_ansi(msg)),
|
|
29
|
+
format="{time} | {level:<8} | {message}",
|
|
30
|
+
colorize=True,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
task = progress.add_task("Processing", total=20)
|
|
34
|
+
|
|
35
|
+
for i in range(20):
|
|
36
|
+
time.sleep(0.15)
|
|
37
|
+
|
|
38
|
+
if i % 5 == 0:
|
|
39
|
+
logger.info(f"Checkpoint <green>{i}</green> reached")
|
|
40
|
+
|
|
41
|
+
if random.random() < 0.1:
|
|
42
|
+
logger.warning(f"Item <yellow>{i}</yellow> needed a retry")
|
|
43
|
+
|
|
44
|
+
progress.advance(task)
|
|
45
|
+
|
|
46
|
+
logger.success("<bold>All items processed</bold>")
|
|
47
|
+
logger.remove(handler_id)
|
|
@@ -17,6 +17,7 @@ python examples/01_basic_logging.py
|
|
|
17
17
|
- `06_custom_levels.py`: custom level names, colors, and filtering
|
|
18
18
|
- `07_callbacks.py`: callbacks for metrics, alerts, and external services
|
|
19
19
|
- `08_fastapi_integration.py`: FastAPI canonical request events and tail sampling
|
|
20
|
+
- `09_rich_progress.py`: log lines above a live `rich` progress bar (`pip install rich`)
|
|
20
21
|
|
|
21
22
|
## FastAPI Example
|
|
22
23
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Logust - A fast, Rust-powered Python logging library inspired by loguru.
|
|
2
2
|
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
|
|
5
5
|
Usage:
|
|
6
6
|
>>> import logust
|
|
@@ -82,7 +82,7 @@ if TYPE_CHECKING:
|
|
|
82
82
|
def critical(message: str, *, exception: str | None = None, **kwargs: Any) -> None: ...
|
|
83
83
|
|
|
84
84
|
|
|
85
|
-
__version__ = "0.
|
|
85
|
+
__version__ = "0.5.0"
|
|
86
86
|
|
|
87
87
|
logger = Logger(_rust_logger)
|
|
88
88
|
|