zendev-log 0.2.0__py3-none-any.whl

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.
zendev/log/__init__.py ADDED
@@ -0,0 +1,38 @@
1
+ """Loguru configuration for all projects."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ import sys
7
+
8
+ from loguru import logger
9
+
10
+ _configured = False
11
+
12
+ # TODO: Move this generic helper only after existing ``zendev.setup_log`` users have a documented migration path.
13
+
14
+
15
+ def setup_log(*, verbose: bool = False, json: bool = False) -> int | None:
16
+ """Configure loguru for CLI usage. Safe to call multiple times.
17
+
18
+ Args:
19
+ verbose: If True, set log level to DEBUG. Defaults to False (INFO).
20
+ json: If True, use JSON serialization (CI-friendly). Defaults to False.
21
+
22
+ Returns:
23
+ The handler id on first call, ``None`` on subsequent calls.
24
+ """
25
+ global _configured
26
+ if _configured:
27
+ return None
28
+ _configured = True
29
+
30
+ logger.remove()
31
+
32
+ env_level = os.environ.get("ZENDEV_LOG_LEVEL")
33
+ level = env_level.upper() if env_level else ("DEBUG" if verbose else "INFO")
34
+
35
+ if json:
36
+ return logger.add(sys.stderr, level=level, serialize=True)
37
+ fmt = "<green>{time:HH:mm:ss.SSS}</green> | <level>{level: <7}</level> | <level>{message}</level>"
38
+ return logger.add(sys.stderr, format=fmt, level=level, colorize=True)
zendev/log/py.typed ADDED
File without changes
@@ -0,0 +1,28 @@
1
+ Metadata-Version: 2.5
2
+ Name: zendev-log
3
+ Version: 0.2.0
4
+ Summary: Small Loguru configuration helper for command-line applications
5
+ Project-URL: Homepage, https://github.com/zendev-lab/zendev
6
+ Project-URL: Issues, https://github.com/zendev-lab/zendev/issues
7
+ Project-URL: Repository, https://github.com/zendev-lab/zendev
8
+ License-Expression: MIT
9
+ Requires-Python: >=3.12
10
+ Requires-Dist: loguru>=0.7
11
+ Description-Content-Type: text/markdown
12
+
13
+ # zendev-log
14
+
15
+ `zendev-log` provides a small, idempotent Loguru setup helper for command-line
16
+ applications.
17
+
18
+ ```console
19
+ $ uv add zendev-log
20
+ ```
21
+
22
+ ```python
23
+ from zendev.log import setup_log
24
+
25
+ setup_log(verbose=True)
26
+ ```
27
+
28
+ Version 0.2.0 removes the former `from zendev import setup_log` re-export.
@@ -0,0 +1,5 @@
1
+ zendev/log/__init__.py,sha256=j9cwbuTCW0m0-Gw-3fEHLSdbwQCkubwCW_VLJYIxTFE,1166
2
+ zendev/log/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ zendev_log-0.2.0.dist-info/METADATA,sha256=jHxDK52BoIeJppOLstkHdWgZ7nYYrGrs94JcYO_nv-k,722
4
+ zendev_log-0.2.0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
5
+ zendev_log-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.32.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any