instruktai-python-logger 0.1.0.post1__tar.gz → 0.1.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.
Files changed (14) hide show
  1. {instruktai_python_logger-0.1.0.post1 → instruktai_python_logger-0.1.2}/PKG-INFO +2 -2
  2. {instruktai_python_logger-0.1.0.post1 → instruktai_python_logger-0.1.2}/README.md +1 -1
  3. {instruktai_python_logger-0.1.0.post1 → instruktai_python_logger-0.1.2}/instrukt_ai_logging/logging.py +13 -18
  4. {instruktai_python_logger-0.1.0.post1 → instruktai_python_logger-0.1.2}/instruktai_python_logger.egg-info/PKG-INFO +2 -2
  5. {instruktai_python_logger-0.1.0.post1 → instruktai_python_logger-0.1.2}/pyproject.toml +1 -1
  6. {instruktai_python_logger-0.1.0.post1 → instruktai_python_logger-0.1.2}/tests/test_configure_logging.py +12 -3
  7. {instruktai_python_logger-0.1.0.post1 → instruktai_python_logger-0.1.2}/instrukt_ai_logging/__init__.py +0 -0
  8. {instruktai_python_logger-0.1.0.post1 → instruktai_python_logger-0.1.2}/instrukt_ai_logging/cli.py +0 -0
  9. {instruktai_python_logger-0.1.0.post1 → instruktai_python_logger-0.1.2}/instruktai_python_logger.egg-info/SOURCES.txt +0 -0
  10. {instruktai_python_logger-0.1.0.post1 → instruktai_python_logger-0.1.2}/instruktai_python_logger.egg-info/dependency_links.txt +0 -0
  11. {instruktai_python_logger-0.1.0.post1 → instruktai_python_logger-0.1.2}/instruktai_python_logger.egg-info/entry_points.txt +0 -0
  12. {instruktai_python_logger-0.1.0.post1 → instruktai_python_logger-0.1.2}/instruktai_python_logger.egg-info/requires.txt +0 -0
  13. {instruktai_python_logger-0.1.0.post1 → instruktai_python_logger-0.1.2}/instruktai_python_logger.egg-info/top_level.txt +0 -0
  14. {instruktai_python_logger-0.1.0.post1 → instruktai_python_logger-0.1.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: instruktai-python-logger
3
- Version: 0.1.0.post1
3
+ Version: 0.1.2
4
4
  Summary: Centralized logging utilities for InstruktAI Python services.
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -43,7 +43,7 @@ Example:
43
43
  import logging
44
44
  from instrukt_ai_logging import configure_logging
45
45
 
46
- configure_logging("teleclaude")
46
+ configure_logging(name="teleclaude", app_logger_prefix="teleclaude")
47
47
  logger = logging.getLogger("teleclaude.core")
48
48
  logger.info("job_started", job_id="abc123", user_id=123)
49
49
  ```
@@ -33,7 +33,7 @@ Example:
33
33
  import logging
34
34
  from instrukt_ai_logging import configure_logging
35
35
 
36
- configure_logging("teleclaude")
36
+ configure_logging(name="teleclaude", app_logger_prefix="teleclaude")
37
37
  logger = logging.getLogger("teleclaude.core")
38
38
  logger.info("job_started", job_id="abc123", user_id=123)
39
39
  ```
@@ -35,18 +35,6 @@ def _normalize_app_name(name: str) -> str:
35
35
  return raw
36
36
 
37
37
 
38
- def _normalize_logger_prefix(name: str) -> str:
39
- # teleclaude, crypto_ai, etc. (match Python package style)
40
- raw = name.strip().lower()
41
- if not raw:
42
- raise ValueError("name must be non-empty")
43
- raw = re.sub(r"[^a-z0-9]+", "_", raw)
44
- raw = re.sub(r"_+", "_", raw).strip("_")
45
- if not raw:
46
- raise ValueError("name did not produce a valid logger prefix")
47
- return raw
48
-
49
-
50
38
  def _level_name_to_int(level_name: str, default: int) -> int:
51
39
  name = level_name.strip().upper()
52
40
  if not name:
@@ -315,8 +303,11 @@ def _ensure_log_dir(log_dir: Path) -> None:
315
303
 
316
304
 
317
305
  def configure_logging(
318
- name: str,
319
306
  *,
307
+ app_logger_prefix: str,
308
+ name: str | None = None,
309
+ env_prefix: str | None = None,
310
+ app_name: str | None = None,
320
311
  log_filename: str | None = None,
321
312
  max_message_chars: int = 4000,
322
313
  ) -> Path:
@@ -324,10 +315,14 @@ def configure_logging(
324
315
 
325
316
  Returns the resolved log file path in use.
326
317
  """
327
- env_prefix = _normalize_env_prefix(name)
328
- app_logger_prefix = _normalize_logger_prefix(name)
329
- app_name = app_logger_prefix
330
- log_filename = log_filename or f"{app_logger_prefix}.log"
318
+ if name is not None:
319
+ if env_prefix is not None or app_name is not None:
320
+ raise ValueError("Pass either name= OR env_prefix/app_name (not both)")
321
+ env_prefix = _normalize_env_prefix(name)
322
+ app_name = _normalize_app_name(name)
323
+
324
+ if env_prefix is None or app_name is None:
325
+ raise ValueError("Missing required config: name= OR both env_prefix= and app_name=")
331
326
 
332
327
  contract = LoggingContract(
333
328
  env_prefix=env_prefix,
@@ -358,7 +353,7 @@ def configure_logging(
358
353
  log_dir = _fallback_log_root(app_name)
359
354
  _ensure_log_dir(log_dir)
360
355
 
361
- log_file = log_dir / log_filename
356
+ log_file = log_dir / (log_filename or f"{app_name}.log")
362
357
 
363
358
  formatter = LogfmtFormatter(max_message_chars=max_message_chars)
364
359
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: instruktai-python-logger
3
- Version: 0.1.0.post1
3
+ Version: 0.1.2
4
4
  Summary: Centralized logging utilities for InstruktAI Python services.
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -43,7 +43,7 @@ Example:
43
43
  import logging
44
44
  from instrukt_ai_logging import configure_logging
45
45
 
46
- configure_logging("teleclaude")
46
+ configure_logging(name="teleclaude", app_logger_prefix="teleclaude")
47
47
  logger = logging.getLogger("teleclaude.core")
48
48
  logger.info("job_started", job_id="abc123", user_id=123)
49
49
  ```
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "instruktai-python-logger"
7
- version = "0.1.0.post1"
7
+ version = "0.1.2"
8
8
  description = "Centralized logging utilities for InstruktAI Python services."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -35,7 +35,10 @@ def test_our_logs_respect_app_level_and_third_party_baseline(isolated_logging, m
35
35
  monkeypatch.setenv("TELECLAUDE_THIRD_PARTY_LOG_LEVEL", "WARNING")
36
36
  monkeypatch.delenv("TELECLAUDE_THIRD_PARTY_LOGGERS", raising=False)
37
37
 
38
- log_path = configure_logging("teleclaude")
38
+ log_path = configure_logging(
39
+ app_logger_prefix="teleclaude",
40
+ name="teleclaude",
41
+ )
39
42
 
40
43
  logging.getLogger("teleclaude.core").debug("hello from ours")
41
44
  logging.getLogger("httpcore.http11").info("hello from third-party")
@@ -53,7 +56,10 @@ def test_spotlight_allows_selected_third_party_only(isolated_logging, monkeypatc
53
56
  monkeypatch.setenv("TELECLAUDE_THIRD_PARTY_LOG_LEVEL", "INFO")
54
57
  monkeypatch.setenv("TELECLAUDE_THIRD_PARTY_LOGGERS", "httpcore")
55
58
 
56
- log_path = configure_logging("teleclaude")
59
+ log_path = configure_logging(
60
+ app_logger_prefix="teleclaude",
61
+ name="teleclaude",
62
+ )
57
63
 
58
64
  # Ensure records are actually created even though root is WARNING in spotlight mode.
59
65
  httpcore_logger = logging.getLogger("httpcore")
@@ -83,7 +89,10 @@ def test_named_kv_logger_emits_pairs(isolated_logging, monkeypatch):
83
89
  monkeypatch.setenv("TELECLAUDE_LOG_LEVEL", "INFO")
84
90
  monkeypatch.setenv("TELECLAUDE_THIRD_PARTY_LOG_LEVEL", "WARNING")
85
91
 
86
- log_path = configure_logging("teleclaude")
92
+ log_path = configure_logging(
93
+ app_logger_prefix="teleclaude",
94
+ name="teleclaude",
95
+ )
87
96
 
88
97
  logging.getLogger("teleclaude.core").info("hello", session="abc123", n=1)
89
98