instruktai-python-logger 0.1.2__tar.gz → 0.1.5__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.2 → instruktai_python_logger-0.1.5}/PKG-INFO +2 -2
  2. {instruktai_python_logger-0.1.2 → instruktai_python_logger-0.1.5}/README.md +1 -1
  3. {instruktai_python_logger-0.1.2 → instruktai_python_logger-0.1.5}/instrukt_ai_logging/logging.py +18 -13
  4. {instruktai_python_logger-0.1.2 → instruktai_python_logger-0.1.5}/instruktai_python_logger.egg-info/PKG-INFO +2 -2
  5. {instruktai_python_logger-0.1.2 → instruktai_python_logger-0.1.5}/pyproject.toml +1 -1
  6. {instruktai_python_logger-0.1.2 → instruktai_python_logger-0.1.5}/tests/test_configure_logging.py +3 -12
  7. {instruktai_python_logger-0.1.2 → instruktai_python_logger-0.1.5}/instrukt_ai_logging/__init__.py +0 -0
  8. {instruktai_python_logger-0.1.2 → instruktai_python_logger-0.1.5}/instrukt_ai_logging/cli.py +0 -0
  9. {instruktai_python_logger-0.1.2 → instruktai_python_logger-0.1.5}/instruktai_python_logger.egg-info/SOURCES.txt +0 -0
  10. {instruktai_python_logger-0.1.2 → instruktai_python_logger-0.1.5}/instruktai_python_logger.egg-info/dependency_links.txt +0 -0
  11. {instruktai_python_logger-0.1.2 → instruktai_python_logger-0.1.5}/instruktai_python_logger.egg-info/entry_points.txt +0 -0
  12. {instruktai_python_logger-0.1.2 → instruktai_python_logger-0.1.5}/instruktai_python_logger.egg-info/requires.txt +0 -0
  13. {instruktai_python_logger-0.1.2 → instruktai_python_logger-0.1.5}/instruktai_python_logger.egg-info/top_level.txt +0 -0
  14. {instruktai_python_logger-0.1.2 → instruktai_python_logger-0.1.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: instruktai-python-logger
3
- Version: 0.1.2
3
+ Version: 0.1.5
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(name="teleclaude", app_logger_prefix="teleclaude")
46
+ configure_logging("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(name="teleclaude", app_logger_prefix="teleclaude")
36
+ configure_logging("teleclaude")
37
37
  logger = logging.getLogger("teleclaude.core")
38
38
  logger.info("job_started", job_id="abc123", user_id=123)
39
39
  ```
@@ -35,6 +35,18 @@ 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
+
38
50
  def _level_name_to_int(level_name: str, default: int) -> int:
39
51
  name = level_name.strip().upper()
40
52
  if not name:
@@ -303,11 +315,8 @@ def _ensure_log_dir(log_dir: Path) -> None:
303
315
 
304
316
 
305
317
  def configure_logging(
318
+ name: str,
306
319
  *,
307
- app_logger_prefix: str,
308
- name: str | None = None,
309
- env_prefix: str | None = None,
310
- app_name: str | None = None,
311
320
  log_filename: str | None = None,
312
321
  max_message_chars: int = 4000,
313
322
  ) -> Path:
@@ -315,14 +324,10 @@ def configure_logging(
315
324
 
316
325
  Returns the resolved log file path in use.
317
326
  """
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=")
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"
326
331
 
327
332
  contract = LoggingContract(
328
333
  env_prefix=env_prefix,
@@ -353,7 +358,7 @@ def configure_logging(
353
358
  log_dir = _fallback_log_root(app_name)
354
359
  _ensure_log_dir(log_dir)
355
360
 
356
- log_file = log_dir / (log_filename or f"{app_name}.log")
361
+ log_file = log_dir / log_filename
357
362
 
358
363
  formatter = LogfmtFormatter(max_message_chars=max_message_chars)
359
364
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: instruktai-python-logger
3
- Version: 0.1.2
3
+ Version: 0.1.5
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(name="teleclaude", app_logger_prefix="teleclaude")
46
+ configure_logging("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.2"
7
+ version = "0.1.5"
8
8
  description = "Centralized logging utilities for InstruktAI Python services."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -35,10 +35,7 @@ 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(
39
- app_logger_prefix="teleclaude",
40
- name="teleclaude",
41
- )
38
+ log_path = configure_logging("teleclaude")
42
39
 
43
40
  logging.getLogger("teleclaude.core").debug("hello from ours")
44
41
  logging.getLogger("httpcore.http11").info("hello from third-party")
@@ -56,10 +53,7 @@ def test_spotlight_allows_selected_third_party_only(isolated_logging, monkeypatc
56
53
  monkeypatch.setenv("TELECLAUDE_THIRD_PARTY_LOG_LEVEL", "INFO")
57
54
  monkeypatch.setenv("TELECLAUDE_THIRD_PARTY_LOGGERS", "httpcore")
58
55
 
59
- log_path = configure_logging(
60
- app_logger_prefix="teleclaude",
61
- name="teleclaude",
62
- )
56
+ log_path = configure_logging("teleclaude")
63
57
 
64
58
  # Ensure records are actually created even though root is WARNING in spotlight mode.
65
59
  httpcore_logger = logging.getLogger("httpcore")
@@ -89,10 +83,7 @@ def test_named_kv_logger_emits_pairs(isolated_logging, monkeypatch):
89
83
  monkeypatch.setenv("TELECLAUDE_LOG_LEVEL", "INFO")
90
84
  monkeypatch.setenv("TELECLAUDE_THIRD_PARTY_LOG_LEVEL", "WARNING")
91
85
 
92
- log_path = configure_logging(
93
- app_logger_prefix="teleclaude",
94
- name="teleclaude",
95
- )
86
+ log_path = configure_logging("teleclaude")
96
87
 
97
88
  logging.getLogger("teleclaude.core").info("hello", session="abc123", n=1)
98
89