inspy-logger 3.2.2__tar.gz → 3.2.4__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 (55) hide show
  1. inspy_logger-3.2.4/PKG-INFO +138 -0
  2. inspy_logger-3.2.4/README.md +112 -0
  3. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/Scripts/main.py +10 -15
  4. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/__about__.py +0 -10
  5. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/__init__.py +12 -21
  6. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/config/levels.py +0 -1
  7. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/constants.py +3 -1
  8. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/engine/__init__.py +105 -136
  9. inspy_logger-3.2.4/inspy_logger/engine/handlers.py +136 -0
  10. inspy_logger-3.2.4/inspy_logger/engine/hierarchy.py +64 -0
  11. inspy_logger-3.2.2/inspy_logger/helpers/base_classes_old.py → inspy_logger-3.2.4/inspy_logger/helpers/base_classes.py +32 -25
  12. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/helpers/network.py +25 -2
  13. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/tool/config/arguments/__init__.py +3 -9
  14. inspy_logger-3.2.4/inspy_logger/utils/__init__.py +21 -0
  15. inspy_logger-3.2.4/inspy_logger/version/VERSION.txt +1 -0
  16. inspy_logger-3.2.4/pyproject.toml +44 -0
  17. inspy_logger-3.2.2/PKG-INFO +0 -81
  18. inspy_logger-3.2.2/README.md +0 -54
  19. inspy_logger-3.2.2/inspy_logger/engine/handlers.py +0 -50
  20. inspy_logger-3.2.2/inspy_logger/helpers/base_classes.py +0 -174
  21. inspy_logger-3.2.2/inspy_logger/version/VERSION.txt +0 -1
  22. inspy_logger-3.2.2/pyproject.toml +0 -45
  23. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/LICENSE.md +0 -0
  24. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/common/__init__.py +0 -0
  25. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/common/meta.py +0 -0
  26. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/config/__init__.py +0 -0
  27. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/config/dirs.py +0 -0
  28. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/engine/adapters/__init__.py +0 -0
  29. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/engine/adapters/thread.py +0 -0
  30. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/engine/errors.py +0 -0
  31. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/errors/__init__.py +0 -0
  32. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/helpers/__init__.py +0 -0
  33. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/helpers/command_line/__init__.py +0 -0
  34. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/helpers/debug/__init__.py +0 -0
  35. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/helpers/debug/environment.py +0 -0
  36. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/helpers/debug/system/__init__.py +0 -0
  37. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/helpers/debug/system/processor/__init__.py +0 -0
  38. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/helpers/debug/system/winx/__init__.py +0 -0
  39. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/helpers/decorators.py +0 -0
  40. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/helpers/descriptors.py +0 -0
  41. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/helpers/units.py +0 -0
  42. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/manifest.py +0 -0
  43. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/models/__init__.py +0 -0
  44. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/models/announcement/__init__.py +0 -0
  45. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/models/announcement/placeholder/__init__.py +0 -0
  46. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/models/announcement/placeholder/helpers.py +0 -0
  47. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/system/__init__.py +0 -0
  48. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/system/linux.py +0 -0
  49. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/system/mac_os.py +0 -0
  50. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/system/win32.py +0 -0
  51. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/tool/__init__.py +0 -0
  52. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/tool/config/__init__.py +0 -0
  53. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/types.py +0 -0
  54. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/version/__init__.py +0 -0
  55. {inspy_logger-3.2.2 → inspy_logger-3.2.4}/inspy_logger/version.py +0 -0
@@ -0,0 +1,138 @@
1
+ Metadata-Version: 2.4
2
+ Name: inspy-logger
3
+ Version: 3.2.4
4
+ Summary: Colorable, scalable logger for CLI
5
+ License-Expression: MIT
6
+ License-File: LICENSE.md
7
+ Author: Taylor B.
8
+ Author-email: t.blackstone@inspyre.tech
9
+ Requires-Python: >=3.10,<4.0
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Requires-Dist: packaging (>=26.3,<27.0)
17
+ Requires-Dist: platformdirs (>=4.12.3,<5.0.0)
18
+ Requires-Dist: psutil (>=7.2.2,<8.0.0)
19
+ Requires-Dist: public-suffix-list (>=1.1.0,<2.0.0)
20
+ Requires-Dist: pyperclip (>=1.11.0,<2.0.0)
21
+ Requires-Dist: python-box (>=7.4.1,<8.0.0)
22
+ Requires-Dist: requests (>=2.34.2,<3.0.0)
23
+ Requires-Dist: rich (>=15.0.0,<16.0.0)
24
+ Description-Content-Type: text/markdown
25
+
26
+ # InspyLogger
27
+
28
+ InspyLogger is a colorful, hierarchical logging library for Python CLI
29
+ applications. It keeps the standard library's logging semantics while adding
30
+ named singleton devices, child loggers, Rich console output, file output, and
31
+ one-time warnings.
32
+
33
+ Version 3.2.4 supports Python 3.10 and newer.
34
+
35
+ ## Installation
36
+
37
+ ```console
38
+ python -m pip install inspy-logger
39
+ ```
40
+
41
+ To install this checkout for development, use `poetry install --with dev,docs`.
42
+
43
+ ## Quick start
44
+
45
+ ```python
46
+ from inspy_logger import InspyLogger
47
+
48
+ log = InspyLogger(
49
+ "my-app",
50
+ console_level="info",
51
+ file_level="debug",
52
+ file_name="my-app.log",
53
+ )
54
+
55
+ log.debug("Written to the file, but hidden from the console")
56
+ log.info("Started %s", "successfully")
57
+ log.warning("Something may need attention")
58
+ ```
59
+
60
+ `InspyLogger(name, ...)` returns the same logger device for repeated uses of a
61
+ name. Log methods accept the same positional formatting arguments as
62
+ `logging.Logger`.
63
+
64
+ ## Console-only logging
65
+
66
+ ```python
67
+ log = InspyLogger(
68
+ "console-app",
69
+ console_level="warning",
70
+ no_file_logging=True,
71
+ )
72
+ ```
73
+
74
+ With `no_file_logging=True`, no file handler is installed and no log file is
75
+ created.
76
+
77
+ ## Child loggers
78
+
79
+ ```python
80
+ database_log = log.get_child("database")
81
+ query_log = log.get_child("database.query")
82
+
83
+ database_log.info("Connected")
84
+ query_log.debug("Executing %s", statement)
85
+ ```
86
+
87
+ Child retrieval is stable: requesting the same child name returns the same
88
+ device and does not add duplicate handlers.
89
+
90
+ ## Logging-enabled classes
91
+
92
+ ```python
93
+ from inspy_logger import Loggable
94
+
95
+
96
+ class Worker(Loggable):
97
+ def run(self):
98
+ self.method_logger.info("Worker started")
99
+
100
+
101
+ worker = Worker(parent_log_device=log)
102
+ worker.run()
103
+ ```
104
+
105
+ `method_logger` resolves to a child named for the calling method. It remains a
106
+ descriptor, so each method gets the correct child rather than an instance
107
+ attribute captured during initialization.
108
+
109
+ ## Levels and handlers
110
+
111
+ Console and file levels are independent. The wrapped `logging.Logger` is kept
112
+ at the lowest enabled handler level, so a configuration such as console
113
+ `WARNING` plus file `DEBUG` works as expected.
114
+
115
+ The supported named levels are `internal`, `debug`, `info`, `warning`, `error`,
116
+ `critical`, and `fatal`. Integer levels from `logging` are also accepted.
117
+
118
+ ## Compatibility
119
+
120
+ The v2 `start()` method remains available as a deprecated compatibility shim.
121
+ New code should use the logger returned by `InspyLogger(...)` directly.
122
+
123
+ ## Development
124
+
125
+ ```console
126
+ poetry install --with dev
127
+ poetry run pytest
128
+ poetry build
129
+ ```
130
+
131
+ The contract suite covers identity, hierarchy, handler configuration,
132
+ independent levels, caller attribution, `Loggable`, `warn_once()`, and runtime
133
+ environment detection.
134
+
135
+ ## License
136
+
137
+ InspyLogger is distributed under the MIT License. See `LICENSE.md`.
138
+
@@ -0,0 +1,112 @@
1
+ # InspyLogger
2
+
3
+ InspyLogger is a colorful, hierarchical logging library for Python CLI
4
+ applications. It keeps the standard library's logging semantics while adding
5
+ named singleton devices, child loggers, Rich console output, file output, and
6
+ one-time warnings.
7
+
8
+ Version 3.2.4 supports Python 3.10 and newer.
9
+
10
+ ## Installation
11
+
12
+ ```console
13
+ python -m pip install inspy-logger
14
+ ```
15
+
16
+ To install this checkout for development, use `poetry install --with dev,docs`.
17
+
18
+ ## Quick start
19
+
20
+ ```python
21
+ from inspy_logger import InspyLogger
22
+
23
+ log = InspyLogger(
24
+ "my-app",
25
+ console_level="info",
26
+ file_level="debug",
27
+ file_name="my-app.log",
28
+ )
29
+
30
+ log.debug("Written to the file, but hidden from the console")
31
+ log.info("Started %s", "successfully")
32
+ log.warning("Something may need attention")
33
+ ```
34
+
35
+ `InspyLogger(name, ...)` returns the same logger device for repeated uses of a
36
+ name. Log methods accept the same positional formatting arguments as
37
+ `logging.Logger`.
38
+
39
+ ## Console-only logging
40
+
41
+ ```python
42
+ log = InspyLogger(
43
+ "console-app",
44
+ console_level="warning",
45
+ no_file_logging=True,
46
+ )
47
+ ```
48
+
49
+ With `no_file_logging=True`, no file handler is installed and no log file is
50
+ created.
51
+
52
+ ## Child loggers
53
+
54
+ ```python
55
+ database_log = log.get_child("database")
56
+ query_log = log.get_child("database.query")
57
+
58
+ database_log.info("Connected")
59
+ query_log.debug("Executing %s", statement)
60
+ ```
61
+
62
+ Child retrieval is stable: requesting the same child name returns the same
63
+ device and does not add duplicate handlers.
64
+
65
+ ## Logging-enabled classes
66
+
67
+ ```python
68
+ from inspy_logger import Loggable
69
+
70
+
71
+ class Worker(Loggable):
72
+ def run(self):
73
+ self.method_logger.info("Worker started")
74
+
75
+
76
+ worker = Worker(parent_log_device=log)
77
+ worker.run()
78
+ ```
79
+
80
+ `method_logger` resolves to a child named for the calling method. It remains a
81
+ descriptor, so each method gets the correct child rather than an instance
82
+ attribute captured during initialization.
83
+
84
+ ## Levels and handlers
85
+
86
+ Console and file levels are independent. The wrapped `logging.Logger` is kept
87
+ at the lowest enabled handler level, so a configuration such as console
88
+ `WARNING` plus file `DEBUG` works as expected.
89
+
90
+ The supported named levels are `internal`, `debug`, `info`, `warning`, `error`,
91
+ `critical`, and `fatal`. Integer levels from `logging` are also accepted.
92
+
93
+ ## Compatibility
94
+
95
+ The v2 `start()` method remains available as a deprecated compatibility shim.
96
+ New code should use the logger returned by `InspyLogger(...)` directly.
97
+
98
+ ## Development
99
+
100
+ ```console
101
+ poetry install --with dev
102
+ poetry run pytest
103
+ poetry build
104
+ ```
105
+
106
+ The contract suite covers identity, hierarchy, handler configuration,
107
+ independent levels, caller attribution, `Loggable`, `warn_once()`, and runtime
108
+ environment detection.
109
+
110
+ ## License
111
+
112
+ InspyLogger is distributed under the MIT License. See `LICENSE.md`.
@@ -51,22 +51,11 @@ fmt_grp.add_argument('-J', '--json', action='store_true', help='Formats the debu
51
51
 
52
52
  fmt_grp.add_argument('-T', '--text', action='store_true', help='Formats the debug information in plain text.')
53
53
 
54
- # Parse the arguments
55
- parsed_args = parser.parse_args()
56
-
57
- # END PARSER SETUP
58
-
59
- if parsed_args.subcommand == 'update':
60
- INCLUDE_PRE_RELEASE_FOR_UPDATE_CHECK = parsed_args.pre_release
61
- else:
62
- INCLUDE_PRE_RELEASE_FOR_UPDATE_CHECK = False
63
-
64
-
65
54
  def get_parser():
66
55
  return parser
67
56
 
68
57
 
69
- def debug(args = parsed_args):
58
+ def debug(args):
70
59
  if args.markdown:
71
60
  fmt = 'markdown'
72
61
  elif args.json:
@@ -78,14 +67,20 @@ def debug(args = parsed_args):
78
67
 
79
68
 
80
69
 
81
- def main():
70
+ def main(argv=None):
71
+ parsed_args = parser.parse_args(argv)
72
+ include_pre_release = (
73
+ parsed_args.pre_release
74
+ if parsed_args.subcommand == "update"
75
+ else False
76
+ )
82
77
 
83
- version = PyPiVersionInfo(INCLUDE_PRE_RELEASE_FOR_UPDATE_CHECK)
78
+ version = PyPiVersionInfo(include_pre_release)
84
79
 
85
80
  ACTIONS = {
86
81
  'default': version.print_version_info,
87
82
  'update': version.update,
88
- 'debug': debug,
83
+ 'debug': lambda: debug(parsed_args),
89
84
 
90
85
  }
91
86
 
@@ -12,7 +12,6 @@ Since:
12
12
 
13
13
  """
14
14
  from inspy_logger.version import parse_version
15
- from inspy_logger.version import parse_version
16
15
 
17
16
  __PROG__ = 'inSPy-Logger'
18
17
  __VERSION__: str = parse_version()
@@ -21,13 +20,4 @@ __AUTHORS__: list[tuple[str, str]] = [
21
20
  ('Taylor-Jayde Blackstone', '<t.blackstone@inspyre.tech>')
22
21
  ]
23
22
 
24
- from inspy_logger.version import parse_version
25
-
26
- __PROG__ = 'inSPy-Logger'
27
- __VERSION__: str = parse_version()
28
- __AUTHORS__: list[tuple[str, str]] = [
29
- ('Inspyre-Softworks', 'https://inspyre.tech'),
30
- ('Taylor-Jayde Blackstone', '<t.blackstone@inspyre.tech')
31
- ]
32
-
33
23
  SOFTWARE_ORG = __AUTHORS__[0][0]
@@ -1,10 +1,6 @@
1
1
  #!/usr/bin/env python3
2
2
  import contextlib
3
3
  import sys
4
- import inspect
5
- import os
6
- import logging
7
- from pypattyrn.behavioral.null import Null
8
4
  from inspy_logger.common import PROG_NAME as ISL_PROG_NAME, DEFAULT_LOGGING_LEVEL, DEFAULT_LOG_FILE_PATH, LEVELS
9
5
  from inspy_logger.helpers import find_variable_in_call_stack, check_preemptive_level_set, find_argument_parser, determine_start_block, determine_level
10
6
 
@@ -16,21 +12,6 @@ from inspy_logger.helpers import (
16
12
  determine_log_file_path
17
13
  )
18
14
 
19
- # Existing log record factory
20
- old_factory = logging.getLogRecordFactory()
21
-
22
-
23
- def record_factory(*args, **kwargs):
24
- record = old_factory(*args, **kwargs)
25
- # Set the file_name attribute to the name of the file where the log is called
26
- frame = inspect.stack()[1]
27
- record.file_name = frame.filename
28
- return record
29
-
30
-
31
- logging.setLogRecordFactory(record_factory)
32
-
33
-
34
15
  from inspy_logger.engine import Logger
35
16
  from inspy_logger.helpers import get_existing_logger
36
17
 
@@ -61,6 +42,16 @@ INIT_LOG_LEVEL = determine_level(CLIENT_PROG_NAME)
61
42
  INTERACTIVE_SESSION = find_variable_in_call_stack('INSPY_INTERACTIVE_SESSION', default=False)
62
43
 
63
44
 
45
+ class _NullLogger:
46
+ """No-op logger used when automatic startup is explicitly blocked."""
47
+
48
+ def __getattr__(self, _name):
49
+ return self
50
+
51
+ def __call__(self, *_args, **_kwargs):
52
+ return None
53
+
54
+
64
55
  def start_logger(override_block=True):
65
56
  """
66
57
  Starts the logger.
@@ -96,14 +87,14 @@ def start_logger(override_block=True):
96
87
 
97
88
  LOG_DEVICE.replay_and_setup_handlers()
98
89
  elif CLIENT_PROG_NAME:
99
- prog_logger = Null()
90
+ prog_logger = _NullLogger()
100
91
 
101
92
  with contextlib.suppress(NameError):
102
93
  global PROG_LOGGER
103
94
 
104
95
  PROG_LOGGER = prog_logger
105
96
 
106
- if isinstance(PROG_LOGGER, Null):
97
+ if isinstance(PROG_LOGGER, _NullLogger):
107
98
  from rich import print
108
99
  print("The logger has been blocked from starting. To start the logger, run `start_logger()`.")
109
100
 
@@ -19,7 +19,6 @@ import logging
19
19
 
20
20
 
21
21
  LEVEL_MAP = {
22
- 'internal': 5,
23
22
  'debug': logging.DEBUG,
24
23
  'info': logging.INFO,
25
24
  'warning': logging.WARNING,
@@ -20,6 +20,8 @@ Description:
20
20
  import logging
21
21
  from rich.logging import RichHandler
22
22
 
23
+ from inspy_logger.utils import check_if_interactive
24
+
23
25
  DEFAULT_LOGGING_LEVEL = logging.DEBUG
24
26
 
25
27
  HANDLER_TYPES = {
@@ -44,5 +46,5 @@ LEVELS = [level.upper() for level in LEVEL_MAP]
44
46
  INTERNAL = LEVEL_MAP['debug'] - 5
45
47
 
46
48
 
47
- INTERACTIVE_SESSION = __name__ != '__main__'
49
+ INTERACTIVE_SESSION = check_if_interactive()
48
50
  """A flag to indicate whether the session is interactive."""