loggerric2 1.0.0__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.
- loggerric2-1.0.0/LICENSE +49 -0
- loggerric2-1.0.0/PKG-INFO +232 -0
- loggerric2-1.0.0/README.md +173 -0
- loggerric2-1.0.0/loggerric2.egg-info/PKG-INFO +232 -0
- loggerric2-1.0.0/loggerric2.egg-info/SOURCES.txt +7 -0
- loggerric2-1.0.0/loggerric2.egg-info/dependency_links.txt +1 -0
- loggerric2-1.0.0/loggerric2.egg-info/top_level.txt +1 -0
- loggerric2-1.0.0/pyproject.toml +16 -0
- loggerric2-1.0.0/setup.cfg +4 -0
loggerric2-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
Custom Non-Commercial Attribution License (CNAL) v1.0
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 LukaRic
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to use,
|
|
7
|
+
copy, modify, merge, publish, and distribute the Software and derivative works,
|
|
8
|
+
subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
1. Attribution Required
|
|
11
|
+
All copies of the Software, in whole or in part, and any derivative works must
|
|
12
|
+
include:
|
|
13
|
+
(a) the original author name,
|
|
14
|
+
(b) a reference or link to the original source or repository if available, and
|
|
15
|
+
(c) a copy of this license.
|
|
16
|
+
Attribution must be reasonably visible in source distributions and any
|
|
17
|
+
accompanying documentation or credits.
|
|
18
|
+
|
|
19
|
+
2. Non-Commercial Use Only
|
|
20
|
+
The Software may not be used, in whole or in part, for any commercial purpose.
|
|
21
|
+
|
|
22
|
+
Commercial purposes include, without limitation:
|
|
23
|
+
- selling or licensing the Software or derivative works
|
|
24
|
+
- charging fees for access to the Software
|
|
25
|
+
- including the Software in paid products or services
|
|
26
|
+
- using the Software to provide paid services
|
|
27
|
+
- internal business, enterprise, or organizational use intended for commercial
|
|
28
|
+
advantage or monetary compensation
|
|
29
|
+
|
|
30
|
+
Commercial use requires prior written permission from the copyright holder.
|
|
31
|
+
|
|
32
|
+
3. Derivative Works
|
|
33
|
+
You may create and distribute modified or derivative versions of the Software
|
|
34
|
+
only if:
|
|
35
|
+
(a) they are licensed under this same license,
|
|
36
|
+
(b) they remain non-commercial, and
|
|
37
|
+
(c) they retain the required attribution and license notice.
|
|
38
|
+
|
|
39
|
+
4. No Warranty
|
|
40
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
41
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
42
|
+
PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
43
|
+
BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
44
|
+
CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE
|
|
45
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
46
|
+
|
|
47
|
+
5. Termination
|
|
48
|
+
Any failure to comply with these terms automatically terminates the rights
|
|
49
|
+
granted under this license.
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: loggerric2
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A logging utility for Python. Developed for readability and QoL.
|
|
5
|
+
Author: Luka Jacobsen
|
|
6
|
+
License: Custom Non-Commercial Attribution License (CNAL) v1.0
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 LukaRic
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to use,
|
|
12
|
+
copy, modify, merge, publish, and distribute the Software and derivative works,
|
|
13
|
+
subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
1. Attribution Required
|
|
16
|
+
All copies of the Software, in whole or in part, and any derivative works must
|
|
17
|
+
include:
|
|
18
|
+
(a) the original author name,
|
|
19
|
+
(b) a reference or link to the original source or repository if available, and
|
|
20
|
+
(c) a copy of this license.
|
|
21
|
+
Attribution must be reasonably visible in source distributions and any
|
|
22
|
+
accompanying documentation or credits.
|
|
23
|
+
|
|
24
|
+
2. Non-Commercial Use Only
|
|
25
|
+
The Software may not be used, in whole or in part, for any commercial purpose.
|
|
26
|
+
|
|
27
|
+
Commercial purposes include, without limitation:
|
|
28
|
+
- selling or licensing the Software or derivative works
|
|
29
|
+
- charging fees for access to the Software
|
|
30
|
+
- including the Software in paid products or services
|
|
31
|
+
- using the Software to provide paid services
|
|
32
|
+
- internal business, enterprise, or organizational use intended for commercial
|
|
33
|
+
advantage or monetary compensation
|
|
34
|
+
|
|
35
|
+
Commercial use requires prior written permission from the copyright holder.
|
|
36
|
+
|
|
37
|
+
3. Derivative Works
|
|
38
|
+
You may create and distribute modified or derivative versions of the Software
|
|
39
|
+
only if:
|
|
40
|
+
(a) they are licensed under this same license,
|
|
41
|
+
(b) they remain non-commercial, and
|
|
42
|
+
(c) they retain the required attribution and license notice.
|
|
43
|
+
|
|
44
|
+
4. No Warranty
|
|
45
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
46
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
47
|
+
PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
48
|
+
BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
49
|
+
CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE
|
|
50
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
51
|
+
|
|
52
|
+
5. Termination
|
|
53
|
+
Any failure to comply with these terms automatically terminates the rights
|
|
54
|
+
granted under this license.
|
|
55
|
+
Requires-Python: >=3.13
|
|
56
|
+
Description-Content-Type: text/markdown
|
|
57
|
+
License-File: LICENSE
|
|
58
|
+
Dynamic: license-file
|
|
59
|
+
|
|
60
|
+
# Loggerric
|
|
61
|
+
|
|
62
|
+
A logging utility for CLI applications. Offers colorful CLI outputs via ANSI escape characters, aswell as filelogging and a bunch of quality of life features.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Features
|
|
67
|
+
|
|
68
|
+
- **Logging:** Structured logging with levels `INFO` `WARN` `ERROR` `DEBUG` and highlighting.
|
|
69
|
+
- **Filelogging:** Automatic logging to file with ISO timestamps and filepath descriptors.
|
|
70
|
+
- **Pretty Printing:** Pretty print different data types with indentation support.
|
|
71
|
+
- **Tables:** Print data tables in different styles, handles autosizing of the headers.
|
|
72
|
+
- **Progress Bars:** Real-time progressbars with metric labels like ETA, elapsed, etc.
|
|
73
|
+
- **Prompts:** Interactive user input with optional choices and default values.
|
|
74
|
+
- **Timers:** Measure execution time of code snippets with ease.
|
|
75
|
+
- **Timestamps:** Optional, can be used independently, supports rolling differences.
|
|
76
|
+
- **Log Manager:** Optional, can be used to disable logging from certain files.
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Installation
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
pip install loggerric2
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Dependencies:**
|
|
87
|
+
```
|
|
88
|
+
pip install colorama
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
### `Log` class
|
|
94
|
+
```py
|
|
95
|
+
import loggerric2 as lr2
|
|
96
|
+
|
|
97
|
+
lr2.Log.info('Output an information message!')
|
|
98
|
+
lr2.Log.warn('You can also do warning messages!', highlight='warning')
|
|
99
|
+
lr2.Log.error('Here is an error message!', hl='error')
|
|
100
|
+
lr2.Log.debug('You can highlight multiple segments!', hl=['highlight', 'segments'])
|
|
101
|
+
|
|
102
|
+
lr2.Log.disable_level('debug') # Now all debug logs wont be logged to CLI or file.
|
|
103
|
+
lr2.Log.enable_level('debug') # Re-enable the debug logging level again.
|
|
104
|
+
|
|
105
|
+
lr2.Log.set_log_filepath(path='./logs') # Make sure to set the filepath before enabling.
|
|
106
|
+
lr2.Log.set_filelogging_state('enabled') # Enable filelogging.
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### `ProgressBar` class
|
|
110
|
+
```py
|
|
111
|
+
import loggerric2 as lr2
|
|
112
|
+
|
|
113
|
+
# This will print a progress bar to the CLI.
|
|
114
|
+
for i in lr2.ProgressBar(range(100)):
|
|
115
|
+
...
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### `Table` class
|
|
119
|
+
```py
|
|
120
|
+
import loggerric2 as lr2
|
|
121
|
+
|
|
122
|
+
headers = ('Item Name', 'Quantity', 'Price')
|
|
123
|
+
rows = (
|
|
124
|
+
('Socks', 24, '$2.24'),
|
|
125
|
+
('Trex', 1, '$12.2M'),
|
|
126
|
+
('Apple', 912, '$0.54')
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
lr2.Table.minimalistic(headers, rows)
|
|
130
|
+
lr2.Table.boxed(headers, rows)
|
|
131
|
+
lr2.Table.borderless(headers, rows)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### `Timer` class
|
|
135
|
+
```py
|
|
136
|
+
import loggerric2 as lr2
|
|
137
|
+
|
|
138
|
+
with Timer(name='Timer Name') as timer:
|
|
139
|
+
...
|
|
140
|
+
|
|
141
|
+
duration = timer.get_duration_ms()
|
|
142
|
+
duration_f = timer.get_formatted_duration()
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### `pretty_print` method
|
|
146
|
+
```py
|
|
147
|
+
import loggerric2 as lr2
|
|
148
|
+
|
|
149
|
+
lr2.pretty_print([1, 2, 'three', 4.5])
|
|
150
|
+
|
|
151
|
+
lr2.pp({ 'Key': 'Value', 'Downloads': 123 }) # Exact same as pretty_print, just an alias
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### `prompt` method
|
|
155
|
+
```py
|
|
156
|
+
import loggerric2 as lr2
|
|
157
|
+
|
|
158
|
+
# Prompt without options, just a regular prompt
|
|
159
|
+
option = prompt('Question')
|
|
160
|
+
|
|
161
|
+
# Prompt with options, still accepts other options than specified
|
|
162
|
+
option = prompt('Question', options=['Option 1', 'Option 2'])
|
|
163
|
+
|
|
164
|
+
# Prompt with options, and a default option if user just clicks enter
|
|
165
|
+
option = prompt('Question', option=['One', 'Two'], default_option='One')
|
|
166
|
+
|
|
167
|
+
# Also supports case sensitive options
|
|
168
|
+
option = prompt('Question', option=['One', 'Two'], case_sensitive=True)
|
|
169
|
+
|
|
170
|
+
# And an autocomplete for long options or faster prompting
|
|
171
|
+
option = prompt('Question', option=['One', 'Two'], auto_complete_option=True)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### `Timestamp` class
|
|
175
|
+
```py
|
|
176
|
+
import loggerric2 as lr2
|
|
177
|
+
|
|
178
|
+
lr2.Timestamp.set_timezone(datetime.timezone.utc) # Sets the timezone to use for timestamps.
|
|
179
|
+
|
|
180
|
+
# Set the format that will be used when getting timestamps
|
|
181
|
+
lr2.Timestamp.set_format('{DD}/{MO}/{YY} {HH}:{MI}:{SS}.{MS} T+{DH}:{DM}:{DS}.{DM}')
|
|
182
|
+
|
|
183
|
+
lr2.Timestamp.get() # Gets the current timestamp with the set format and timezone
|
|
184
|
+
lr2.Timestamp.get_iso() # Gets the current ISO timestamp.
|
|
185
|
+
|
|
186
|
+
lr2.Timestamp.set_state('disabled') # Disable the timestamps on the logs
|
|
187
|
+
lr2.Timestamp.set_state('enabled') # Re-enable them again
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### `LogManager` class
|
|
191
|
+
```py
|
|
192
|
+
import loggerric2 as lr2
|
|
193
|
+
|
|
194
|
+
# Get the file of the function that called this method
|
|
195
|
+
caller = lr2.LogManager.get_method_caller()
|
|
196
|
+
|
|
197
|
+
# Get the file that created a class instance
|
|
198
|
+
owner = lr2.LogManager.get_class_instance_owner_file()
|
|
199
|
+
|
|
200
|
+
# Set how many directories of the caller path to show
|
|
201
|
+
lr2.LogManager.set_caller_file_depth(2)
|
|
202
|
+
|
|
203
|
+
# Get the formatted caller filepath
|
|
204
|
+
lr2.LogManager.get_caller_file()
|
|
205
|
+
|
|
206
|
+
# Get the filepath without ANSI formatting
|
|
207
|
+
lr2.LogManager.get_caller_file(no_ansi=True)
|
|
208
|
+
|
|
209
|
+
# Skip additional caller frames
|
|
210
|
+
lr2.LogManager.get_caller_file(skip_extra=1)
|
|
211
|
+
|
|
212
|
+
# Blacklist the current file
|
|
213
|
+
lr2.LogManager.blacklist_this_file()
|
|
214
|
+
|
|
215
|
+
# Remove the current file from the blacklist
|
|
216
|
+
lr2.LogManager.remove_this_files_blacklist()
|
|
217
|
+
|
|
218
|
+
# Check if the current file is blacklisted
|
|
219
|
+
lr2.LogManager.is_caller_blacklisted()
|
|
220
|
+
|
|
221
|
+
# Add a file or path to the blacklist
|
|
222
|
+
lr2.LogManager.add_blacklist('debug.py')
|
|
223
|
+
|
|
224
|
+
# Remove a file or path from the blacklist
|
|
225
|
+
lr2.LogManager.blacklist_remove('debug.py')
|
|
226
|
+
|
|
227
|
+
# Get all blacklisted paths
|
|
228
|
+
lr2.LogManager.get_blacklist()
|
|
229
|
+
|
|
230
|
+
# Check if a specific path is blacklisted
|
|
231
|
+
lr2.LogManager.is_blacklisted('debug.py')
|
|
232
|
+
```
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# Loggerric
|
|
2
|
+
|
|
3
|
+
A logging utility for CLI applications. Offers colorful CLI outputs via ANSI escape characters, aswell as filelogging and a bunch of quality of life features.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Logging:** Structured logging with levels `INFO` `WARN` `ERROR` `DEBUG` and highlighting.
|
|
10
|
+
- **Filelogging:** Automatic logging to file with ISO timestamps and filepath descriptors.
|
|
11
|
+
- **Pretty Printing:** Pretty print different data types with indentation support.
|
|
12
|
+
- **Tables:** Print data tables in different styles, handles autosizing of the headers.
|
|
13
|
+
- **Progress Bars:** Real-time progressbars with metric labels like ETA, elapsed, etc.
|
|
14
|
+
- **Prompts:** Interactive user input with optional choices and default values.
|
|
15
|
+
- **Timers:** Measure execution time of code snippets with ease.
|
|
16
|
+
- **Timestamps:** Optional, can be used independently, supports rolling differences.
|
|
17
|
+
- **Log Manager:** Optional, can be used to disable logging from certain files.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
pip install loggerric2
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Dependencies:**
|
|
28
|
+
```
|
|
29
|
+
pip install colorama
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
### `Log` class
|
|
35
|
+
```py
|
|
36
|
+
import loggerric2 as lr2
|
|
37
|
+
|
|
38
|
+
lr2.Log.info('Output an information message!')
|
|
39
|
+
lr2.Log.warn('You can also do warning messages!', highlight='warning')
|
|
40
|
+
lr2.Log.error('Here is an error message!', hl='error')
|
|
41
|
+
lr2.Log.debug('You can highlight multiple segments!', hl=['highlight', 'segments'])
|
|
42
|
+
|
|
43
|
+
lr2.Log.disable_level('debug') # Now all debug logs wont be logged to CLI or file.
|
|
44
|
+
lr2.Log.enable_level('debug') # Re-enable the debug logging level again.
|
|
45
|
+
|
|
46
|
+
lr2.Log.set_log_filepath(path='./logs') # Make sure to set the filepath before enabling.
|
|
47
|
+
lr2.Log.set_filelogging_state('enabled') # Enable filelogging.
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### `ProgressBar` class
|
|
51
|
+
```py
|
|
52
|
+
import loggerric2 as lr2
|
|
53
|
+
|
|
54
|
+
# This will print a progress bar to the CLI.
|
|
55
|
+
for i in lr2.ProgressBar(range(100)):
|
|
56
|
+
...
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### `Table` class
|
|
60
|
+
```py
|
|
61
|
+
import loggerric2 as lr2
|
|
62
|
+
|
|
63
|
+
headers = ('Item Name', 'Quantity', 'Price')
|
|
64
|
+
rows = (
|
|
65
|
+
('Socks', 24, '$2.24'),
|
|
66
|
+
('Trex', 1, '$12.2M'),
|
|
67
|
+
('Apple', 912, '$0.54')
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
lr2.Table.minimalistic(headers, rows)
|
|
71
|
+
lr2.Table.boxed(headers, rows)
|
|
72
|
+
lr2.Table.borderless(headers, rows)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### `Timer` class
|
|
76
|
+
```py
|
|
77
|
+
import loggerric2 as lr2
|
|
78
|
+
|
|
79
|
+
with Timer(name='Timer Name') as timer:
|
|
80
|
+
...
|
|
81
|
+
|
|
82
|
+
duration = timer.get_duration_ms()
|
|
83
|
+
duration_f = timer.get_formatted_duration()
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### `pretty_print` method
|
|
87
|
+
```py
|
|
88
|
+
import loggerric2 as lr2
|
|
89
|
+
|
|
90
|
+
lr2.pretty_print([1, 2, 'three', 4.5])
|
|
91
|
+
|
|
92
|
+
lr2.pp({ 'Key': 'Value', 'Downloads': 123 }) # Exact same as pretty_print, just an alias
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### `prompt` method
|
|
96
|
+
```py
|
|
97
|
+
import loggerric2 as lr2
|
|
98
|
+
|
|
99
|
+
# Prompt without options, just a regular prompt
|
|
100
|
+
option = prompt('Question')
|
|
101
|
+
|
|
102
|
+
# Prompt with options, still accepts other options than specified
|
|
103
|
+
option = prompt('Question', options=['Option 1', 'Option 2'])
|
|
104
|
+
|
|
105
|
+
# Prompt with options, and a default option if user just clicks enter
|
|
106
|
+
option = prompt('Question', option=['One', 'Two'], default_option='One')
|
|
107
|
+
|
|
108
|
+
# Also supports case sensitive options
|
|
109
|
+
option = prompt('Question', option=['One', 'Two'], case_sensitive=True)
|
|
110
|
+
|
|
111
|
+
# And an autocomplete for long options or faster prompting
|
|
112
|
+
option = prompt('Question', option=['One', 'Two'], auto_complete_option=True)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### `Timestamp` class
|
|
116
|
+
```py
|
|
117
|
+
import loggerric2 as lr2
|
|
118
|
+
|
|
119
|
+
lr2.Timestamp.set_timezone(datetime.timezone.utc) # Sets the timezone to use for timestamps.
|
|
120
|
+
|
|
121
|
+
# Set the format that will be used when getting timestamps
|
|
122
|
+
lr2.Timestamp.set_format('{DD}/{MO}/{YY} {HH}:{MI}:{SS}.{MS} T+{DH}:{DM}:{DS}.{DM}')
|
|
123
|
+
|
|
124
|
+
lr2.Timestamp.get() # Gets the current timestamp with the set format and timezone
|
|
125
|
+
lr2.Timestamp.get_iso() # Gets the current ISO timestamp.
|
|
126
|
+
|
|
127
|
+
lr2.Timestamp.set_state('disabled') # Disable the timestamps on the logs
|
|
128
|
+
lr2.Timestamp.set_state('enabled') # Re-enable them again
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### `LogManager` class
|
|
132
|
+
```py
|
|
133
|
+
import loggerric2 as lr2
|
|
134
|
+
|
|
135
|
+
# Get the file of the function that called this method
|
|
136
|
+
caller = lr2.LogManager.get_method_caller()
|
|
137
|
+
|
|
138
|
+
# Get the file that created a class instance
|
|
139
|
+
owner = lr2.LogManager.get_class_instance_owner_file()
|
|
140
|
+
|
|
141
|
+
# Set how many directories of the caller path to show
|
|
142
|
+
lr2.LogManager.set_caller_file_depth(2)
|
|
143
|
+
|
|
144
|
+
# Get the formatted caller filepath
|
|
145
|
+
lr2.LogManager.get_caller_file()
|
|
146
|
+
|
|
147
|
+
# Get the filepath without ANSI formatting
|
|
148
|
+
lr2.LogManager.get_caller_file(no_ansi=True)
|
|
149
|
+
|
|
150
|
+
# Skip additional caller frames
|
|
151
|
+
lr2.LogManager.get_caller_file(skip_extra=1)
|
|
152
|
+
|
|
153
|
+
# Blacklist the current file
|
|
154
|
+
lr2.LogManager.blacklist_this_file()
|
|
155
|
+
|
|
156
|
+
# Remove the current file from the blacklist
|
|
157
|
+
lr2.LogManager.remove_this_files_blacklist()
|
|
158
|
+
|
|
159
|
+
# Check if the current file is blacklisted
|
|
160
|
+
lr2.LogManager.is_caller_blacklisted()
|
|
161
|
+
|
|
162
|
+
# Add a file or path to the blacklist
|
|
163
|
+
lr2.LogManager.add_blacklist('debug.py')
|
|
164
|
+
|
|
165
|
+
# Remove a file or path from the blacklist
|
|
166
|
+
lr2.LogManager.blacklist_remove('debug.py')
|
|
167
|
+
|
|
168
|
+
# Get all blacklisted paths
|
|
169
|
+
lr2.LogManager.get_blacklist()
|
|
170
|
+
|
|
171
|
+
# Check if a specific path is blacklisted
|
|
172
|
+
lr2.LogManager.is_blacklisted('debug.py')
|
|
173
|
+
```
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: loggerric2
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A logging utility for Python. Developed for readability and QoL.
|
|
5
|
+
Author: Luka Jacobsen
|
|
6
|
+
License: Custom Non-Commercial Attribution License (CNAL) v1.0
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 LukaRic
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to use,
|
|
12
|
+
copy, modify, merge, publish, and distribute the Software and derivative works,
|
|
13
|
+
subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
1. Attribution Required
|
|
16
|
+
All copies of the Software, in whole or in part, and any derivative works must
|
|
17
|
+
include:
|
|
18
|
+
(a) the original author name,
|
|
19
|
+
(b) a reference or link to the original source or repository if available, and
|
|
20
|
+
(c) a copy of this license.
|
|
21
|
+
Attribution must be reasonably visible in source distributions and any
|
|
22
|
+
accompanying documentation or credits.
|
|
23
|
+
|
|
24
|
+
2. Non-Commercial Use Only
|
|
25
|
+
The Software may not be used, in whole or in part, for any commercial purpose.
|
|
26
|
+
|
|
27
|
+
Commercial purposes include, without limitation:
|
|
28
|
+
- selling or licensing the Software or derivative works
|
|
29
|
+
- charging fees for access to the Software
|
|
30
|
+
- including the Software in paid products or services
|
|
31
|
+
- using the Software to provide paid services
|
|
32
|
+
- internal business, enterprise, or organizational use intended for commercial
|
|
33
|
+
advantage or monetary compensation
|
|
34
|
+
|
|
35
|
+
Commercial use requires prior written permission from the copyright holder.
|
|
36
|
+
|
|
37
|
+
3. Derivative Works
|
|
38
|
+
You may create and distribute modified or derivative versions of the Software
|
|
39
|
+
only if:
|
|
40
|
+
(a) they are licensed under this same license,
|
|
41
|
+
(b) they remain non-commercial, and
|
|
42
|
+
(c) they retain the required attribution and license notice.
|
|
43
|
+
|
|
44
|
+
4. No Warranty
|
|
45
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
46
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
47
|
+
PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
48
|
+
BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
49
|
+
CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE
|
|
50
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
51
|
+
|
|
52
|
+
5. Termination
|
|
53
|
+
Any failure to comply with these terms automatically terminates the rights
|
|
54
|
+
granted under this license.
|
|
55
|
+
Requires-Python: >=3.13
|
|
56
|
+
Description-Content-Type: text/markdown
|
|
57
|
+
License-File: LICENSE
|
|
58
|
+
Dynamic: license-file
|
|
59
|
+
|
|
60
|
+
# Loggerric
|
|
61
|
+
|
|
62
|
+
A logging utility for CLI applications. Offers colorful CLI outputs via ANSI escape characters, aswell as filelogging and a bunch of quality of life features.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Features
|
|
67
|
+
|
|
68
|
+
- **Logging:** Structured logging with levels `INFO` `WARN` `ERROR` `DEBUG` and highlighting.
|
|
69
|
+
- **Filelogging:** Automatic logging to file with ISO timestamps and filepath descriptors.
|
|
70
|
+
- **Pretty Printing:** Pretty print different data types with indentation support.
|
|
71
|
+
- **Tables:** Print data tables in different styles, handles autosizing of the headers.
|
|
72
|
+
- **Progress Bars:** Real-time progressbars with metric labels like ETA, elapsed, etc.
|
|
73
|
+
- **Prompts:** Interactive user input with optional choices and default values.
|
|
74
|
+
- **Timers:** Measure execution time of code snippets with ease.
|
|
75
|
+
- **Timestamps:** Optional, can be used independently, supports rolling differences.
|
|
76
|
+
- **Log Manager:** Optional, can be used to disable logging from certain files.
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Installation
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
pip install loggerric2
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Dependencies:**
|
|
87
|
+
```
|
|
88
|
+
pip install colorama
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
### `Log` class
|
|
94
|
+
```py
|
|
95
|
+
import loggerric2 as lr2
|
|
96
|
+
|
|
97
|
+
lr2.Log.info('Output an information message!')
|
|
98
|
+
lr2.Log.warn('You can also do warning messages!', highlight='warning')
|
|
99
|
+
lr2.Log.error('Here is an error message!', hl='error')
|
|
100
|
+
lr2.Log.debug('You can highlight multiple segments!', hl=['highlight', 'segments'])
|
|
101
|
+
|
|
102
|
+
lr2.Log.disable_level('debug') # Now all debug logs wont be logged to CLI or file.
|
|
103
|
+
lr2.Log.enable_level('debug') # Re-enable the debug logging level again.
|
|
104
|
+
|
|
105
|
+
lr2.Log.set_log_filepath(path='./logs') # Make sure to set the filepath before enabling.
|
|
106
|
+
lr2.Log.set_filelogging_state('enabled') # Enable filelogging.
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### `ProgressBar` class
|
|
110
|
+
```py
|
|
111
|
+
import loggerric2 as lr2
|
|
112
|
+
|
|
113
|
+
# This will print a progress bar to the CLI.
|
|
114
|
+
for i in lr2.ProgressBar(range(100)):
|
|
115
|
+
...
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### `Table` class
|
|
119
|
+
```py
|
|
120
|
+
import loggerric2 as lr2
|
|
121
|
+
|
|
122
|
+
headers = ('Item Name', 'Quantity', 'Price')
|
|
123
|
+
rows = (
|
|
124
|
+
('Socks', 24, '$2.24'),
|
|
125
|
+
('Trex', 1, '$12.2M'),
|
|
126
|
+
('Apple', 912, '$0.54')
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
lr2.Table.minimalistic(headers, rows)
|
|
130
|
+
lr2.Table.boxed(headers, rows)
|
|
131
|
+
lr2.Table.borderless(headers, rows)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### `Timer` class
|
|
135
|
+
```py
|
|
136
|
+
import loggerric2 as lr2
|
|
137
|
+
|
|
138
|
+
with Timer(name='Timer Name') as timer:
|
|
139
|
+
...
|
|
140
|
+
|
|
141
|
+
duration = timer.get_duration_ms()
|
|
142
|
+
duration_f = timer.get_formatted_duration()
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### `pretty_print` method
|
|
146
|
+
```py
|
|
147
|
+
import loggerric2 as lr2
|
|
148
|
+
|
|
149
|
+
lr2.pretty_print([1, 2, 'three', 4.5])
|
|
150
|
+
|
|
151
|
+
lr2.pp({ 'Key': 'Value', 'Downloads': 123 }) # Exact same as pretty_print, just an alias
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### `prompt` method
|
|
155
|
+
```py
|
|
156
|
+
import loggerric2 as lr2
|
|
157
|
+
|
|
158
|
+
# Prompt without options, just a regular prompt
|
|
159
|
+
option = prompt('Question')
|
|
160
|
+
|
|
161
|
+
# Prompt with options, still accepts other options than specified
|
|
162
|
+
option = prompt('Question', options=['Option 1', 'Option 2'])
|
|
163
|
+
|
|
164
|
+
# Prompt with options, and a default option if user just clicks enter
|
|
165
|
+
option = prompt('Question', option=['One', 'Two'], default_option='One')
|
|
166
|
+
|
|
167
|
+
# Also supports case sensitive options
|
|
168
|
+
option = prompt('Question', option=['One', 'Two'], case_sensitive=True)
|
|
169
|
+
|
|
170
|
+
# And an autocomplete for long options or faster prompting
|
|
171
|
+
option = prompt('Question', option=['One', 'Two'], auto_complete_option=True)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### `Timestamp` class
|
|
175
|
+
```py
|
|
176
|
+
import loggerric2 as lr2
|
|
177
|
+
|
|
178
|
+
lr2.Timestamp.set_timezone(datetime.timezone.utc) # Sets the timezone to use for timestamps.
|
|
179
|
+
|
|
180
|
+
# Set the format that will be used when getting timestamps
|
|
181
|
+
lr2.Timestamp.set_format('{DD}/{MO}/{YY} {HH}:{MI}:{SS}.{MS} T+{DH}:{DM}:{DS}.{DM}')
|
|
182
|
+
|
|
183
|
+
lr2.Timestamp.get() # Gets the current timestamp with the set format and timezone
|
|
184
|
+
lr2.Timestamp.get_iso() # Gets the current ISO timestamp.
|
|
185
|
+
|
|
186
|
+
lr2.Timestamp.set_state('disabled') # Disable the timestamps on the logs
|
|
187
|
+
lr2.Timestamp.set_state('enabled') # Re-enable them again
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### `LogManager` class
|
|
191
|
+
```py
|
|
192
|
+
import loggerric2 as lr2
|
|
193
|
+
|
|
194
|
+
# Get the file of the function that called this method
|
|
195
|
+
caller = lr2.LogManager.get_method_caller()
|
|
196
|
+
|
|
197
|
+
# Get the file that created a class instance
|
|
198
|
+
owner = lr2.LogManager.get_class_instance_owner_file()
|
|
199
|
+
|
|
200
|
+
# Set how many directories of the caller path to show
|
|
201
|
+
lr2.LogManager.set_caller_file_depth(2)
|
|
202
|
+
|
|
203
|
+
# Get the formatted caller filepath
|
|
204
|
+
lr2.LogManager.get_caller_file()
|
|
205
|
+
|
|
206
|
+
# Get the filepath without ANSI formatting
|
|
207
|
+
lr2.LogManager.get_caller_file(no_ansi=True)
|
|
208
|
+
|
|
209
|
+
# Skip additional caller frames
|
|
210
|
+
lr2.LogManager.get_caller_file(skip_extra=1)
|
|
211
|
+
|
|
212
|
+
# Blacklist the current file
|
|
213
|
+
lr2.LogManager.blacklist_this_file()
|
|
214
|
+
|
|
215
|
+
# Remove the current file from the blacklist
|
|
216
|
+
lr2.LogManager.remove_this_files_blacklist()
|
|
217
|
+
|
|
218
|
+
# Check if the current file is blacklisted
|
|
219
|
+
lr2.LogManager.is_caller_blacklisted()
|
|
220
|
+
|
|
221
|
+
# Add a file or path to the blacklist
|
|
222
|
+
lr2.LogManager.add_blacklist('debug.py')
|
|
223
|
+
|
|
224
|
+
# Remove a file or path from the blacklist
|
|
225
|
+
lr2.LogManager.blacklist_remove('debug.py')
|
|
226
|
+
|
|
227
|
+
# Get all blacklisted paths
|
|
228
|
+
lr2.LogManager.get_blacklist()
|
|
229
|
+
|
|
230
|
+
# Check if a specific path is blacklisted
|
|
231
|
+
lr2.LogManager.is_blacklisted('debug.py')
|
|
232
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "loggerric2"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
description = "A logging utility for Python. Developed for readability and QoL."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.13"
|
|
7
|
+
authors = [{ name="Luka Jacobsen" }]
|
|
8
|
+
license = { file="LICENSE" }
|
|
9
|
+
|
|
10
|
+
[build-system]
|
|
11
|
+
requires = ["setuptools", "wheel"]
|
|
12
|
+
build-backend = "setuptools.build_meta"
|
|
13
|
+
|
|
14
|
+
[tool.setuptools.packages.find]
|
|
15
|
+
include = ["source*"]
|
|
16
|
+
exclude = ["testing*"]
|