inspy-logger 3.1.0.dev2__tar.gz → 3.1.0.dev4__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.
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/LICENSE.md +20 -20
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/PKG-INFO +2 -1
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/README.md +54 -54
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/__about__.py +24 -24
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/__init__.py +137 -135
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/common/__init__.py +1 -1
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/config/dirs.py +133 -134
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/constants.py +12 -0
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/engine/__init__.py +729 -688
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/engine/handlers.py +1 -1
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/errors/__init__.py +121 -121
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/helpers/__init__.py +542 -542
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/helpers/base_classes.py +149 -145
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/helpers/decorators.py +28 -7
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/helpers/network.py +388 -388
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/helpers/units.py +1 -1
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/manifest.py +40 -40
- inspy_logger-3.1.0.dev4/inspy_logger/tool/__init__.py +4 -0
- inspy_logger-3.1.0.dev4/inspy_logger/types.py +169 -0
- inspy_logger-3.1.0.dev4/inspy_logger/version/VERSION.txt +1 -0
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/version/__init__.py +0 -3
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/pyproject.toml +77 -77
- inspy_logger-3.1.0.dev2/inspy_logger/tool/config/__init__.py +0 -0
- inspy_logger-3.1.0.dev2/inspy_logger/version/VERSION.txt +0 -1
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/Scripts/main.py +0 -0
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/common/meta.py +0 -0
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/config/__init__.py +0 -0
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/config/levels.py +0 -0
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/engine/errors.py +0 -0
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/helpers/command_line/__init__.py +0 -0
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/helpers/debug/__init__.py +0 -0
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/helpers/debug/environment.py +0 -0
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/helpers/debug/system/__init__.py +0 -0
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/helpers/debug/system/processor/__init__.py +0 -0
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/helpers/debug/system/winx/__init__.py +0 -0
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/helpers/descriptors.py +0 -0
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/system/__init__.py +0 -0
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/system/linux.py +0 -0
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/system/mac_os.py +0 -0
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/system/win32.py +0 -0
- {inspy_logger-3.1.0.dev2/inspy_logger/tool → inspy_logger-3.1.0.dev4/inspy_logger/tool/config}/__init__.py +0 -0
- {inspy_logger-3.1.0.dev2 → inspy_logger-3.1.0.dev4}/inspy_logger/tool/config/arguments/__init__.py +0 -0
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
### Do What the Fuck You Want To - Public License (v3.0 3, Sept. 2020)
|
|
2
|
-
----
|
|
3
|
-
----
|
|
4
|
-
|
|
5
|
-
Copyright (C) 2020 Taylor-Jayde Blackstone <t.blackstone@inspyre.tech>
|
|
6
|
-
|
|
7
|
-
----
|
|
8
|
-
|
|
9
|
-
Everyone is permitted to copy and distribute verbatim or modified
|
|
10
|
-
copies of this license document, and changing it is allowed as long
|
|
11
|
-
as the name is changed. That's my name, you can't have it.
|
|
12
|
-
|
|
13
|
-
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
|
14
|
-
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
15
|
-
|
|
16
|
-
- You just **DO WHAT THE FUCK YOU WANT TO**.
|
|
17
|
-
- You **don't** blame me for **shit**. _I don't care_ how much smoke your hard-drive spewed out.
|
|
18
|
-
- If someone else did what the fuck they wanted to and you're _**triggered**_ I'm **not** responsible.
|
|
19
|
-
|
|
20
|
-
Contact <dev.null@inspyre.tech> with any complaints.
|
|
1
|
+
### Do What the Fuck You Want To - Public License (v3.0 3, Sept. 2020)
|
|
2
|
+
----
|
|
3
|
+
----
|
|
4
|
+
|
|
5
|
+
Copyright (C) 2020 Taylor-Jayde Blackstone <t.blackstone@inspyre.tech>
|
|
6
|
+
|
|
7
|
+
----
|
|
8
|
+
|
|
9
|
+
Everyone is permitted to copy and distribute verbatim or modified
|
|
10
|
+
copies of this license document, and changing it is allowed as long
|
|
11
|
+
as the name is changed. That's my name, you can't have it.
|
|
12
|
+
|
|
13
|
+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
|
14
|
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
15
|
+
|
|
16
|
+
- You just **DO WHAT THE FUCK YOU WANT TO**.
|
|
17
|
+
- You **don't** blame me for **shit**. _I don't care_ how much smoke your hard-drive spewed out.
|
|
18
|
+
- If someone else did what the fuck they wanted to and you're _**triggered**_ I'm **not** responsible.
|
|
19
|
+
|
|
20
|
+
Contact <dev.null@inspyre.tech> with any complaints.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: inspy-logger
|
|
3
|
-
Version: 3.1.0.
|
|
3
|
+
Version: 3.1.0.dev4
|
|
4
4
|
Summary: Colorable, scalable logger for CLI
|
|
5
5
|
Home-page: https://github.com/Inspyre-Softworks/inSPy-Logger
|
|
6
6
|
License: MIT
|
|
@@ -32,6 +32,7 @@ Requires-Dist: luddite (>=1.0.4,<2.0.0)
|
|
|
32
32
|
Requires-Dist: packaging (>=24.0,<25.0)
|
|
33
33
|
Requires-Dist: platformdirs (>=4.2.0,<5.0.0)
|
|
34
34
|
Requires-Dist: pypattyrn (>=1.2,<2.0)
|
|
35
|
+
Requires-Dist: pyperclip (>=1.8.2,<2.0.0)
|
|
35
36
|
Requires-Dist: python-box (>=7.1.1,<8.0.0)
|
|
36
37
|
Requires-Dist: requests (>=2.28.1,<3.0.0)
|
|
37
38
|
Requires-Dist: rich (>=13.7.0,<14.0.0)
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
# inSPy-Logger
|
|
2
|
-

|
|
3
|
-

|
|
4
|
-

|
|
5
|
-

|
|
6
|
-

|
|
7
|
-

|
|
8
|
-
|
|
9
|
-
## Installation
|
|
10
|
-
|
|
11
|
-
### Prerequisites:
|
|
12
|
-
|
|
13
|
-
**Platform/Env**:
|
|
14
|
-
* **Python**: ^3.6.3
|
|
15
|
-
* **PIP**: (_If you want to install via PIP, that is_)
|
|
16
|
-
|
|
17
|
-
**inSPy-Logger Runtime Dependencies**:
|
|
18
|
-
I am providing this list of dependencies for transparency and for instances where one would not be able to install inSPy-Logger via PyPi's package manager. It is **highly** recommended you use `python3 -m pip install inspy_logger==<ver>` to install inSPy-Logger 2.0+
|
|
19
|
-
|
|
20
|
-
* [colorlog](https://pypi.org/project/colorlog) (^4.2.1)
|
|
21
|
-
* [setuptools-autover](https://pypi.org/project/setuptools-autover) = (^1.0.2)
|
|
22
|
-
* [luddite](https://pypi.org/project/luddite) = (^1.0.1)
|
|
23
|
-
* [packaging](https://pypi.org/project/packaging) = (^20.4)
|
|
24
|
-
|
|
25
|
-
### Installation via Pip on Python 3.6.3+ (recommended method):
|
|
26
|
-
|
|
27
|
-
- `$> python3 -m pip install inspy_logger==<version>`
|
|
28
|
-
|
|
29
|
-
#### Test out InspyLogger:
|
|
30
|
-
|
|
31
|
-
```python3
|
|
32
|
-
|
|
33
|
-
import inspy_logger
|
|
34
|
-
|
|
35
|
-
# Set up a log device object. The first parameter is the root loggers name, and the second is the debug level
|
|
36
|
-
log_device = inspy_logger.InspyLogger('LogName', 'debug')
|
|
37
|
-
|
|
38
|
-
# Start a running log from that device
|
|
39
|
-
log = log_device.start()
|
|
40
|
-
|
|
41
|
-
# Output our own logger lines:
|
|
42
|
-
log.debug('This is a debug log entry')
|
|
43
|
-
log.info('This is an info log entry')
|
|
44
|
-
log.warning('This is a warning log entry!')
|
|
45
|
-
log.error('This is an error log entry!')
|
|
46
|
-
log.exception('This is an exception log entry!')
|
|
47
|
-
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
If you run the code above you'll get output similar to this:
|
|
51
|
-
|
|
52
|
-

|
|
53
|
-
|
|
54
|
-
v2.0+ repository for inSPy-Logger
|
|
1
|
+
# inSPy-Logger
|
|
2
|
+

|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
### Prerequisites:
|
|
12
|
+
|
|
13
|
+
**Platform/Env**:
|
|
14
|
+
* **Python**: ^3.6.3
|
|
15
|
+
* **PIP**: (_If you want to install via PIP, that is_)
|
|
16
|
+
|
|
17
|
+
**inSPy-Logger Runtime Dependencies**:
|
|
18
|
+
I am providing this list of dependencies for transparency and for instances where one would not be able to install inSPy-Logger via PyPi's package manager. It is **highly** recommended you use `python3 -m pip install inspy_logger==<ver>` to install inSPy-Logger 2.0+
|
|
19
|
+
|
|
20
|
+
* [colorlog](https://pypi.org/project/colorlog) (^4.2.1)
|
|
21
|
+
* [setuptools-autover](https://pypi.org/project/setuptools-autover) = (^1.0.2)
|
|
22
|
+
* [luddite](https://pypi.org/project/luddite) = (^1.0.1)
|
|
23
|
+
* [packaging](https://pypi.org/project/packaging) = (^20.4)
|
|
24
|
+
|
|
25
|
+
### Installation via Pip on Python 3.6.3+ (recommended method):
|
|
26
|
+
|
|
27
|
+
- `$> python3 -m pip install inspy_logger==<version>`
|
|
28
|
+
|
|
29
|
+
#### Test out InspyLogger:
|
|
30
|
+
|
|
31
|
+
```python3
|
|
32
|
+
|
|
33
|
+
import inspy_logger
|
|
34
|
+
|
|
35
|
+
# Set up a log device object. The first parameter is the root loggers name, and the second is the debug level
|
|
36
|
+
log_device = inspy_logger.InspyLogger('LogName', 'debug')
|
|
37
|
+
|
|
38
|
+
# Start a running log from that device
|
|
39
|
+
log = log_device.start()
|
|
40
|
+
|
|
41
|
+
# Output our own logger lines:
|
|
42
|
+
log.debug('This is a debug log entry')
|
|
43
|
+
log.info('This is an info log entry')
|
|
44
|
+
log.warning('This is a warning log entry!')
|
|
45
|
+
log.error('This is an error log entry!')
|
|
46
|
+
log.exception('This is an exception log entry!')
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
If you run the code above you'll get output similar to this:
|
|
51
|
+
|
|
52
|
+

|
|
53
|
+
|
|
54
|
+
v2.0+ repository for inSPy-Logger
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
"""
|
|
2
|
-
|
|
3
|
-
File: inspy_logger/__about__.py
|
|
4
|
-
Project: inSPy-Logger
|
|
5
|
-
Description:
|
|
6
|
-
Holds information about the inSPy-Logger program and its version.
|
|
7
|
-
|
|
8
|
-
Created: 11/3/22 - 21:05:06
|
|
9
|
-
|
|
10
|
-
Since:
|
|
11
|
-
v2.1.1
|
|
12
|
-
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
from inspy_logger.version import parse_version
|
|
16
|
-
|
|
17
|
-
__PROG__ = 'inSPy-Logger'
|
|
18
|
-
__VERSION__: str = parse_version()
|
|
19
|
-
__AUTHORS__: list[tuple[str, str]] = [
|
|
20
|
-
('Inspyre-Softworks', 'https://inspyre.tech'),
|
|
21
|
-
('Taylor-Jayde Blackstone', '<t.blackstone@inspyre.tech')
|
|
22
|
-
]
|
|
23
|
-
|
|
24
|
-
SOFTWARE_ORG = __AUTHORS__[0][0]
|
|
1
|
+
"""
|
|
2
|
+
|
|
3
|
+
File: inspy_logger/__about__.py
|
|
4
|
+
Project: inSPy-Logger
|
|
5
|
+
Description:
|
|
6
|
+
Holds information about the inSPy-Logger program and its version.
|
|
7
|
+
|
|
8
|
+
Created: 11/3/22 - 21:05:06
|
|
9
|
+
|
|
10
|
+
Since:
|
|
11
|
+
v2.1.1
|
|
12
|
+
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from inspy_logger.version import parse_version
|
|
16
|
+
|
|
17
|
+
__PROG__ = 'inSPy-Logger'
|
|
18
|
+
__VERSION__: str = parse_version()
|
|
19
|
+
__AUTHORS__: list[tuple[str, str]] = [
|
|
20
|
+
('Inspyre-Softworks', 'https://inspyre.tech'),
|
|
21
|
+
('Taylor-Jayde Blackstone', '<t.blackstone@inspyre.tech')
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
SOFTWARE_ORG = __AUTHORS__[0][0]
|
|
@@ -1,135 +1,137 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
import contextlib
|
|
3
|
-
import sys
|
|
4
|
-
import inspect
|
|
5
|
-
import logging
|
|
6
|
-
from pypattyrn.behavioral.null import Null
|
|
7
|
-
from inspy_logger.common import PROG_NAME as ISL_PROG_NAME, DEFAULT_LOGGING_LEVEL, DEFAULT_LOG_FILE_PATH, LEVELS
|
|
8
|
-
from inspy_logger.helpers import find_variable_in_call_stack, check_preemptive_level_set, find_argument_parser, determine_start_block, determine_level
|
|
9
|
-
|
|
10
|
-
from inspy_logger.helpers import (
|
|
11
|
-
translate_to_logging_level,
|
|
12
|
-
clean_module_name,
|
|
13
|
-
CustomFormatter,
|
|
14
|
-
determine_client_prog_name,
|
|
15
|
-
determine_log_file_path
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
# Existing log record factory
|
|
19
|
-
old_factory = logging.getLogRecordFactory()
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
def record_factory(*args, **kwargs):
|
|
23
|
-
record = old_factory(*args, **kwargs)
|
|
24
|
-
# Set the file_name attribute to the name of the file where the log is called
|
|
25
|
-
frame = inspect.stack()[1]
|
|
26
|
-
record.file_name = frame.filename
|
|
27
|
-
return record
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
logging.setLogRecordFactory(record_factory)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
from inspy_logger.engine import Logger
|
|
34
|
-
|
|
35
|
-
__all__ = [
|
|
36
|
-
"clean_module_name",
|
|
37
|
-
"CustomFormatter",
|
|
38
|
-
"DEFAULT_LOGGING_LEVEL",
|
|
39
|
-
"determine_level",
|
|
40
|
-
"InspyLogger",
|
|
41
|
-
"LOG_DEVICE",
|
|
42
|
-
"Logger",
|
|
43
|
-
"ISL_PROG_NAME",
|
|
44
|
-
"translate_to_logging_level",
|
|
45
|
-
]
|
|
46
|
-
|
|
47
|
-
BLOCKED = determine_start_block()
|
|
48
|
-
|
|
49
|
-
LOG_FILE = determine_log_file_path()
|
|
50
|
-
|
|
51
|
-
LOG_DEVICE = None if BLOCKED else Logger(ISL_PROG_NAME)
|
|
52
|
-
|
|
53
|
-
MODULE_OBJ = sys.modules[__name__]
|
|
54
|
-
|
|
55
|
-
CLIENT_PROG_NAME = determine_client_prog_name()
|
|
56
|
-
|
|
57
|
-
INIT_LOG_LEVEL = determine_level(CLIENT_PROG_NAME)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
global
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
PROG_LOGGER
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
bisect
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
import contextlib
|
|
3
|
+
import sys
|
|
4
|
+
import inspect
|
|
5
|
+
import logging
|
|
6
|
+
from pypattyrn.behavioral.null import Null
|
|
7
|
+
from inspy_logger.common import PROG_NAME as ISL_PROG_NAME, DEFAULT_LOGGING_LEVEL, DEFAULT_LOG_FILE_PATH, LEVELS
|
|
8
|
+
from inspy_logger.helpers import find_variable_in_call_stack, check_preemptive_level_set, find_argument_parser, determine_start_block, determine_level
|
|
9
|
+
|
|
10
|
+
from inspy_logger.helpers import (
|
|
11
|
+
translate_to_logging_level,
|
|
12
|
+
clean_module_name,
|
|
13
|
+
CustomFormatter,
|
|
14
|
+
determine_client_prog_name,
|
|
15
|
+
determine_log_file_path
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
# Existing log record factory
|
|
19
|
+
old_factory = logging.getLogRecordFactory()
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def record_factory(*args, **kwargs):
|
|
23
|
+
record = old_factory(*args, **kwargs)
|
|
24
|
+
# Set the file_name attribute to the name of the file where the log is called
|
|
25
|
+
frame = inspect.stack()[1]
|
|
26
|
+
record.file_name = frame.filename
|
|
27
|
+
return record
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
logging.setLogRecordFactory(record_factory)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
from inspy_logger.engine import Logger
|
|
34
|
+
|
|
35
|
+
__all__ = [
|
|
36
|
+
"clean_module_name",
|
|
37
|
+
"CustomFormatter",
|
|
38
|
+
"DEFAULT_LOGGING_LEVEL",
|
|
39
|
+
"determine_level",
|
|
40
|
+
"InspyLogger",
|
|
41
|
+
"LOG_DEVICE",
|
|
42
|
+
"Logger",
|
|
43
|
+
"ISL_PROG_NAME",
|
|
44
|
+
"translate_to_logging_level",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
BLOCKED = determine_start_block()
|
|
48
|
+
|
|
49
|
+
LOG_FILE = determine_log_file_path()
|
|
50
|
+
|
|
51
|
+
LOG_DEVICE = None if BLOCKED else Logger(ISL_PROG_NAME)
|
|
52
|
+
|
|
53
|
+
MODULE_OBJ = sys.modules[__name__]
|
|
54
|
+
|
|
55
|
+
CLIENT_PROG_NAME = determine_client_prog_name()
|
|
56
|
+
|
|
57
|
+
INIT_LOG_LEVEL = determine_level(CLIENT_PROG_NAME)
|
|
58
|
+
|
|
59
|
+
INTERACTIVE_SESSION = find_variable_in_call_stack('INSPY_INTERACTIVE_SESSION', default=False)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def start_logger(override_block=True):
|
|
63
|
+
"""
|
|
64
|
+
Starts the logger.
|
|
65
|
+
|
|
66
|
+
Parameters:
|
|
67
|
+
override_block (Union[bool, None], optional):
|
|
68
|
+
A flag to override the block on the logger. Defaults to True.
|
|
69
|
+
|
|
70
|
+
Note:
|
|
71
|
+
You only need to run this function if you have blocked the logger from starting automatically.
|
|
72
|
+
|
|
73
|
+
Returns:
|
|
74
|
+
|
|
75
|
+
"""
|
|
76
|
+
global LOG_DEVICE
|
|
77
|
+
global CLIENT_PROG_NAME
|
|
78
|
+
global INIT_LOG_LEVEL
|
|
79
|
+
|
|
80
|
+
if not BLOCKED or override_block:
|
|
81
|
+
LOG_DEVICE = Logger(ISL_PROG_NAME)
|
|
82
|
+
LOG_DEVICE.set_level(INIT_LOG_LEVEL)
|
|
83
|
+
|
|
84
|
+
if CLIENT_PROG_NAME:
|
|
85
|
+
|
|
86
|
+
prog_logger = Logger(
|
|
87
|
+
CLIENT_PROG_NAME,
|
|
88
|
+
LOG_DEVICE.console_level,
|
|
89
|
+
LOG_DEVICE.file_level,
|
|
90
|
+
file_name=DEFAULT_LOG_FILE_PATH.name,
|
|
91
|
+
file_path=DEFAULT_LOG_FILE_PATH.parent
|
|
92
|
+
)
|
|
93
|
+
__all__.append('PROG_LOGGER')
|
|
94
|
+
|
|
95
|
+
LOG_DEVICE.replay_and_setup_handlers()
|
|
96
|
+
elif CLIENT_PROG_NAME:
|
|
97
|
+
prog_logger = Null()
|
|
98
|
+
|
|
99
|
+
with contextlib.suppress(NameError):
|
|
100
|
+
global PROG_LOGGER
|
|
101
|
+
|
|
102
|
+
PROG_LOGGER = prog_logger
|
|
103
|
+
|
|
104
|
+
if isinstance(PROG_LOGGER, Null):
|
|
105
|
+
from rich import print
|
|
106
|
+
print("The logger has been blocked from starting. To start the logger, run `start_logger()`.")
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
InspyLogger = Logger
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def _get_loggable():
|
|
113
|
+
from inspy_logger.helpers.base_classes import Loggable
|
|
114
|
+
import bisect
|
|
115
|
+
# Add the `Loggable` class to `__all__` in alphabetical order.
|
|
116
|
+
bisect.insort(__all__, 'Loggable')
|
|
117
|
+
|
|
118
|
+
return Loggable
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
Loggable = _get_loggable()
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
start_logger(override_block=False)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
deprecation_warning_deliveries = 0
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def getLogger(*args, **kwargs):
|
|
131
|
+
global deprecation_warning_deliveries
|
|
132
|
+
|
|
133
|
+
if deprecation_warning_deliveries < 5:
|
|
134
|
+
LOG_DEVICE.warning('The `getLogger` function is deprecated. Use `InspyLogger` instead.')
|
|
135
|
+
deprecation_warning_deliveries += 1
|
|
136
|
+
|
|
137
|
+
return InspyLogger(*args, **kwargs)
|