log21 2.8.1b0__tar.gz → 2.9.1__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.
- log21-2.9.1/PKG-INFO +134 -0
- log21-2.9.1/README.md +103 -0
- {log21-2.8.1b0 → log21-2.9.1}/pyproject.toml +7 -1
- {log21-2.8.1b0 → log21-2.9.1}/src/log21/Logger.py +115 -9
- {log21-2.8.1b0 → log21-2.9.1}/src/log21/__init__.py +31 -30
- log21-2.9.1/src/log21.egg-info/PKG-INFO +134 -0
- log21-2.8.1b0/PKG-INFO +0 -508
- log21-2.8.1b0/README.md +0 -477
- log21-2.8.1b0/src/log21.egg-info/PKG-INFO +0 -508
- {log21-2.8.1b0 → log21-2.9.1}/LICENSE.txt +0 -0
- {log21-2.8.1b0 → log21-2.9.1}/setup.cfg +0 -0
- {log21-2.8.1b0 → log21-2.9.1}/src/log21/Argparse.py +0 -0
- {log21-2.8.1b0 → log21-2.9.1}/src/log21/Argumentify.py +0 -0
- {log21-2.8.1b0 → log21-2.9.1}/src/log21/Colors.py +0 -0
- {log21-2.8.1b0 → log21-2.9.1}/src/log21/CrashReporter/Formatters.py +0 -0
- {log21-2.8.1b0 → log21-2.9.1}/src/log21/CrashReporter/Reporters.py +0 -0
- {log21-2.8.1b0 → log21-2.9.1}/src/log21/CrashReporter/__init__.py +0 -0
- {log21-2.8.1b0 → log21-2.9.1}/src/log21/FileHandler.py +0 -0
- {log21-2.8.1b0 → log21-2.9.1}/src/log21/Formatters.py +0 -0
- {log21-2.8.1b0 → log21-2.9.1}/src/log21/Levels.py +0 -0
- {log21-2.8.1b0 → log21-2.9.1}/src/log21/LoggingWindow.py +0 -0
- {log21-2.8.1b0 → log21-2.9.1}/src/log21/Manager.py +0 -0
- {log21-2.8.1b0 → log21-2.9.1}/src/log21/PPrint.py +0 -0
- {log21-2.8.1b0 → log21-2.9.1}/src/log21/ProgressBar.py +0 -0
- {log21-2.8.1b0 → log21-2.9.1}/src/log21/StreamHandler.py +0 -0
- {log21-2.8.1b0 → log21-2.9.1}/src/log21/TreePrint.py +0 -0
- {log21-2.8.1b0 → log21-2.9.1}/src/log21.egg-info/SOURCES.txt +0 -0
- {log21-2.8.1b0 → log21-2.9.1}/src/log21.egg-info/dependency_links.txt +0 -0
- {log21-2.8.1b0 → log21-2.9.1}/src/log21.egg-info/requires.txt +0 -0
- {log21-2.8.1b0 → log21-2.9.1}/src/log21.egg-info/top_level.txt +0 -0
log21-2.9.1/PKG-INFO
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: log21
|
|
3
|
+
Version: 2.9.1
|
|
4
|
+
Summary: A simple logging package that helps you log colorized messages in Windows console.
|
|
5
|
+
Author-email: "CodeWriter21(Mehrad Pooryoussof)" <CodeWriter21@gmail.com>
|
|
6
|
+
License: Apache License 2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/MPCodeWriter21/log21
|
|
8
|
+
Project-URL: Donations, https://github.com/MPCodeWriter21/log21/blob/master/DONATE.md
|
|
9
|
+
Project-URL: Source, https://github.com/MPCodeWriter21/log21
|
|
10
|
+
Keywords: python,log,colorize,color,logging,Python3,CodeWriter21
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Operating System :: Unix
|
|
17
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
18
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
19
|
+
Requires-Python: >=3.8
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE.txt
|
|
22
|
+
Requires-Dist: webcolors
|
|
23
|
+
Requires-Dist: docstring-parser
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: yapf; extra == "dev"
|
|
26
|
+
Requires-Dist: isort; extra == "dev"
|
|
27
|
+
Requires-Dist: docformatter; extra == "dev"
|
|
28
|
+
Requires-Dist: pylint; extra == "dev"
|
|
29
|
+
Requires-Dist: json5; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest; extra == "dev"
|
|
31
|
+
|
|
32
|
+
log21
|
|
33
|
+
=====
|
|
34
|
+
|
|
35
|
+

|
|
36
|
+

|
|
37
|
+

|
|
38
|
+

|
|
39
|
+
[](https://www.codefactor.io/repository/github/mpcodewriter21/log21)
|
|
40
|
+
|
|
41
|
+
A simple logging package that helps you log colorized messages in Windows console and other operating systems.
|
|
42
|
+
|
|
43
|
+
Features
|
|
44
|
+
--------
|
|
45
|
+
|
|
46
|
+
+ Colors : The main reason for this package was to log text in the Windows console with the support of ANSI colors.
|
|
47
|
+
+ Argument parsing : log21's argument parser can be used like python's argparse but it also colorizes the output.
|
|
48
|
+
+ Logging : A similar logger to logging. Logger but with colorized output and other options such as levelname
|
|
49
|
+
modifications. It can also decolorize the output if you want to log into a file.
|
|
50
|
+
+ Pretty printing : Have you ever wanted to colorize the output of the pprint module? log21's pretty printer can do
|
|
51
|
+
that.
|
|
52
|
+
+ Tree printing : You can pass a dict or list to `log21.tree_print` function and it will print it in a tree-like
|
|
53
|
+
structure. It's also colorized XD.
|
|
54
|
+
+ ProgressBar : log21's progress bar can be used to show progress of a process in a beautiful way.
|
|
55
|
+
+ LoggingWindow : Helps you to log messages and debug your code in a window other than the console.
|
|
56
|
+
+ CrashReporter : log21's crash reporter can be used to report crashes in different
|
|
57
|
+
ways. You can use it to log crashes to console or files or use it to receive crash
|
|
58
|
+
reports of your program through email. And you can also define your own crash
|
|
59
|
+
reporter functions and use them instead!
|
|
60
|
+
+ Argumentify : You can use the argumentify feature to decrease the number of lines you
|
|
61
|
+
need to write to parse command-line arguments. It's colored by the way!
|
|
62
|
+
+ Any idea? Feel free to [open an issue](https://github.com/MPCodeWriter21/log21/issues) or submit a pull request.
|
|
63
|
+
|
|
64
|
+

|
|
65
|
+

|
|
66
|
+
|
|
67
|
+
Installation
|
|
68
|
+
------------
|
|
69
|
+
|
|
70
|
+
Well, this is a python package so the first thing you need is python.
|
|
71
|
+
|
|
72
|
+
If you don't have python installed, please visit [Python.org](https://python.org) and install the latest version of
|
|
73
|
+
python.
|
|
74
|
+
|
|
75
|
+
Then you can install log21 using pip module:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
python -m pip install log21 -U
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Or you can clone [the repository](https://github.com/MPCodeWriter21/log21) and run:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pip install .
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Or let the pip get it using git:
|
|
88
|
+
```bash
|
|
89
|
+
pip install git+https://github.com/MPCodeWriter21/log21
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Changes
|
|
93
|
+
-------
|
|
94
|
+
|
|
95
|
+
### 2.9.1
|
|
96
|
+
|
|
97
|
+
+ Update `README.md`.
|
|
98
|
+
|
|
99
|
+
[Full CHANGELOG](https://github.com/MPCodeWriter21/log21/blob/master/CHANGELOG.md)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
Usage Examples:
|
|
103
|
+
---------------
|
|
104
|
+
|
|
105
|
+
See [EXAMPLES.md](https://github.com/MPCodeWriter21/log21/blob/master/EXAMPLES.md)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
About
|
|
109
|
+
-----
|
|
110
|
+
Author: CodeWriter21 (Mehrad Pooryoussof)
|
|
111
|
+
|
|
112
|
+
GitHub: [MPCodeWriter21](https://github.com/MPCodeWriter21)
|
|
113
|
+
|
|
114
|
+
Telegram Channel: [@CodeWriter21](https://t.me/CodeWriter21)
|
|
115
|
+
|
|
116
|
+
### License
|
|
117
|
+
|
|
118
|
+

|
|
119
|
+
|
|
120
|
+
[apache-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
|
121
|
+
|
|
122
|
+
### Donate
|
|
123
|
+
|
|
124
|
+
In order to support this project you can donate some crypto of your choice 8D
|
|
125
|
+
|
|
126
|
+
[Donate Addresses](https://github.com/MPCodeWriter21/log21/blob/master/DONATE.md)
|
|
127
|
+
|
|
128
|
+
Or if you can't, give [this project](https://github.com/MPCodeWriter21/log21) a star on GitHub :)
|
|
129
|
+
|
|
130
|
+
References
|
|
131
|
+
----------
|
|
132
|
+
|
|
133
|
+
+ ANSI Color Codes (
|
|
134
|
+
Wikipedia): [https://en.wikipedia.org/wiki/ANSI_escape_code](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors)
|
log21-2.9.1/README.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
log21
|
|
2
|
+
=====
|
|
3
|
+
|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
[](https://www.codefactor.io/repository/github/mpcodewriter21/log21)
|
|
9
|
+
|
|
10
|
+
A simple logging package that helps you log colorized messages in Windows console and other operating systems.
|
|
11
|
+
|
|
12
|
+
Features
|
|
13
|
+
--------
|
|
14
|
+
|
|
15
|
+
+ Colors : The main reason for this package was to log text in the Windows console with the support of ANSI colors.
|
|
16
|
+
+ Argument parsing : log21's argument parser can be used like python's argparse but it also colorizes the output.
|
|
17
|
+
+ Logging : A similar logger to logging. Logger but with colorized output and other options such as levelname
|
|
18
|
+
modifications. It can also decolorize the output if you want to log into a file.
|
|
19
|
+
+ Pretty printing : Have you ever wanted to colorize the output of the pprint module? log21's pretty printer can do
|
|
20
|
+
that.
|
|
21
|
+
+ Tree printing : You can pass a dict or list to `log21.tree_print` function and it will print it in a tree-like
|
|
22
|
+
structure. It's also colorized XD.
|
|
23
|
+
+ ProgressBar : log21's progress bar can be used to show progress of a process in a beautiful way.
|
|
24
|
+
+ LoggingWindow : Helps you to log messages and debug your code in a window other than the console.
|
|
25
|
+
+ CrashReporter : log21's crash reporter can be used to report crashes in different
|
|
26
|
+
ways. You can use it to log crashes to console or files or use it to receive crash
|
|
27
|
+
reports of your program through email. And you can also define your own crash
|
|
28
|
+
reporter functions and use them instead!
|
|
29
|
+
+ Argumentify : You can use the argumentify feature to decrease the number of lines you
|
|
30
|
+
need to write to parse command-line arguments. It's colored by the way!
|
|
31
|
+
+ Any idea? Feel free to [open an issue](https://github.com/MPCodeWriter21/log21/issues) or submit a pull request.
|
|
32
|
+
|
|
33
|
+

|
|
34
|
+

|
|
35
|
+
|
|
36
|
+
Installation
|
|
37
|
+
------------
|
|
38
|
+
|
|
39
|
+
Well, this is a python package so the first thing you need is python.
|
|
40
|
+
|
|
41
|
+
If you don't have python installed, please visit [Python.org](https://python.org) and install the latest version of
|
|
42
|
+
python.
|
|
43
|
+
|
|
44
|
+
Then you can install log21 using pip module:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
python -m pip install log21 -U
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Or you can clone [the repository](https://github.com/MPCodeWriter21/log21) and run:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install .
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Or let the pip get it using git:
|
|
57
|
+
```bash
|
|
58
|
+
pip install git+https://github.com/MPCodeWriter21/log21
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Changes
|
|
62
|
+
-------
|
|
63
|
+
|
|
64
|
+
### 2.9.1
|
|
65
|
+
|
|
66
|
+
+ Update `README.md`.
|
|
67
|
+
|
|
68
|
+
[Full CHANGELOG](https://github.com/MPCodeWriter21/log21/blob/master/CHANGELOG.md)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
Usage Examples:
|
|
72
|
+
---------------
|
|
73
|
+
|
|
74
|
+
See [EXAMPLES.md](https://github.com/MPCodeWriter21/log21/blob/master/EXAMPLES.md)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
About
|
|
78
|
+
-----
|
|
79
|
+
Author: CodeWriter21 (Mehrad Pooryoussof)
|
|
80
|
+
|
|
81
|
+
GitHub: [MPCodeWriter21](https://github.com/MPCodeWriter21)
|
|
82
|
+
|
|
83
|
+
Telegram Channel: [@CodeWriter21](https://t.me/CodeWriter21)
|
|
84
|
+
|
|
85
|
+
### License
|
|
86
|
+
|
|
87
|
+

|
|
88
|
+
|
|
89
|
+
[apache-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
|
90
|
+
|
|
91
|
+
### Donate
|
|
92
|
+
|
|
93
|
+
In order to support this project you can donate some crypto of your choice 8D
|
|
94
|
+
|
|
95
|
+
[Donate Addresses](https://github.com/MPCodeWriter21/log21/blob/master/DONATE.md)
|
|
96
|
+
|
|
97
|
+
Or if you can't, give [this project](https://github.com/MPCodeWriter21/log21) a star on GitHub :)
|
|
98
|
+
|
|
99
|
+
References
|
|
100
|
+
----------
|
|
101
|
+
|
|
102
|
+
+ ANSI Color Codes (
|
|
103
|
+
Wikipedia): [https://en.wikipedia.org/wiki/ANSI_escape_code](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors)
|
|
@@ -26,7 +26,7 @@ dependencies = [
|
|
|
26
26
|
"webcolors",
|
|
27
27
|
"docstring-parser"
|
|
28
28
|
]
|
|
29
|
-
version = "2.
|
|
29
|
+
version = "2.9.1"
|
|
30
30
|
|
|
31
31
|
[tool.setuptools.packages.find]
|
|
32
32
|
where = ["src"]
|
|
@@ -62,4 +62,10 @@ dedent_closing_brackets = true
|
|
|
62
62
|
[tool.isort]
|
|
63
63
|
line_length = 88
|
|
64
64
|
combine_as_imports = true
|
|
65
|
+
length_sort = true
|
|
65
66
|
order_by_type = true
|
|
67
|
+
|
|
68
|
+
[tool.docformatter]
|
|
69
|
+
recursive = true
|
|
70
|
+
wrap-summaries = 88
|
|
71
|
+
wrap-descriptions = 88
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
# CodeWriter21
|
|
3
3
|
|
|
4
4
|
import re as _re
|
|
5
|
+
import sys as _sys
|
|
5
6
|
import logging as _logging
|
|
6
7
|
from types import MethodType as _MethodType
|
|
7
|
-
from typing import (Union as _Union, Literal as _Literal, Mapping,
|
|
8
|
+
from typing import (Any, List, Union as _Union, Literal as _Literal, Mapping,
|
|
8
9
|
Callable as _Callable, Optional as _Optional, Sequence as _Sequence)
|
|
9
10
|
from getpass import getpass as _getpass
|
|
10
11
|
from logging import raiseExceptions as _raiseExceptions
|
|
@@ -40,7 +41,7 @@ class Logger(_logging.Logger):
|
|
|
40
41
|
handlers = [handlers]
|
|
41
42
|
else:
|
|
42
43
|
raise TypeError(
|
|
43
|
-
|
|
44
|
+
'handlers must be a list of logging.Handler objects'
|
|
44
45
|
)
|
|
45
46
|
for handler in handlers:
|
|
46
47
|
self.addHandler(handler)
|
|
@@ -61,7 +62,7 @@ class Logger(_logging.Logger):
|
|
|
61
62
|
msg = ' '.join([str(m) for m in msg]) + end
|
|
62
63
|
if not isinstance(level, int):
|
|
63
64
|
if _raiseExceptions:
|
|
64
|
-
raise TypeError(
|
|
65
|
+
raise TypeError('level must be an integer')
|
|
65
66
|
return
|
|
66
67
|
if self.isEnabledFor(level):
|
|
67
68
|
self._log(level, msg, args, **kwargs)
|
|
@@ -161,8 +162,9 @@ class Logger(_logging.Logger):
|
|
|
161
162
|
"""Log 'msg % args'.
|
|
162
163
|
|
|
163
164
|
To pass exception information, use the keyword argument exc_info with a true
|
|
164
|
-
value
|
|
165
|
+
value.
|
|
165
166
|
|
|
167
|
+
Usage example:
|
|
166
168
|
age = logger.input("Enter your age: ")
|
|
167
169
|
"""
|
|
168
170
|
msg = ' '.join([str(m) for m in msg]) + end
|
|
@@ -170,10 +172,12 @@ class Logger(_logging.Logger):
|
|
|
170
172
|
return input()
|
|
171
173
|
|
|
172
174
|
def getpass(self, *msg, args: tuple = (), end='', **kwargs):
|
|
173
|
-
"""
|
|
174
|
-
|
|
175
|
+
"""Takes a password input from the user.
|
|
175
176
|
|
|
176
|
-
:
|
|
177
|
+
:param msg: The message to display to the user.
|
|
178
|
+
:param args: The arguments to pass to the message.
|
|
179
|
+
:param end: The ending character to append to the message.
|
|
180
|
+
:return: The password.
|
|
177
181
|
"""
|
|
178
182
|
msg = ' '.join([str(m) for m in msg]) + end
|
|
179
183
|
self._log(self.level if self.level >= NOTSET else NOTSET, msg, args, **kwargs)
|
|
@@ -213,7 +217,7 @@ class Logger(_logging.Logger):
|
|
|
213
217
|
self,
|
|
214
218
|
level: int,
|
|
215
219
|
name: str,
|
|
216
|
-
errors: _Literal[
|
|
220
|
+
errors: _Literal['raise', 'ignore', 'handle', 'force'] = 'raise'
|
|
217
221
|
) -> str:
|
|
218
222
|
"""Adds a new method to the logger with a specific level and name.
|
|
219
223
|
|
|
@@ -276,7 +280,7 @@ class Logger(_logging.Logger):
|
|
|
276
280
|
def add_levels(
|
|
277
281
|
self,
|
|
278
282
|
level_names: Mapping[int, str],
|
|
279
|
-
errors: _Literal[
|
|
283
|
+
errors: _Literal['raise', 'ignore', 'handle', 'force'] = 'raise'
|
|
280
284
|
) -> None:
|
|
281
285
|
"""Adds new methods to the logger with specific levels and names.
|
|
282
286
|
|
|
@@ -287,6 +291,108 @@ class Logger(_logging.Logger):
|
|
|
287
291
|
for level, name in level_names.items():
|
|
288
292
|
self.add_level(level, name, errors)
|
|
289
293
|
|
|
294
|
+
def __lshift__(self, obj):
|
|
295
|
+
"""Prints the object to the output stream.
|
|
296
|
+
This operator is meant to make the Logger object be usable in a
|
|
297
|
+
std::cout-like way.
|
|
298
|
+
|
|
299
|
+
:param obj: The object to print.
|
|
300
|
+
:return: The Logger object.
|
|
301
|
+
"""
|
|
302
|
+
logger = self
|
|
303
|
+
found = 0
|
|
304
|
+
while logger:
|
|
305
|
+
for handler in logger.handlers:
|
|
306
|
+
if (isinstance(handler, _logging.StreamHandler)
|
|
307
|
+
and hasattr(handler.stream, 'write')
|
|
308
|
+
and hasattr(handler.stream, 'flush')):
|
|
309
|
+
found = found + 1
|
|
310
|
+
handler.stream.write(str(obj))
|
|
311
|
+
handler.stream.flush()
|
|
312
|
+
if not logger.propagate:
|
|
313
|
+
break
|
|
314
|
+
logger = logger.parent
|
|
315
|
+
if found == 0:
|
|
316
|
+
_sys.stderr.write(
|
|
317
|
+
f"No handlers could be found for logger \"{self.name}\"\n"
|
|
318
|
+
)
|
|
319
|
+
return self
|
|
320
|
+
|
|
321
|
+
def __rshift__(self, obj: List[Any]):
|
|
322
|
+
"""A way of receiving input from the stdin.
|
|
323
|
+
This operator is meant to make a std::cin-like operation possible in Python.
|
|
324
|
+
|
|
325
|
+
Usage examples:
|
|
326
|
+
>>> import log21
|
|
327
|
+
>>> cout = cin = log21.get_logger()
|
|
328
|
+
>>>
|
|
329
|
+
>>> # Example 1
|
|
330
|
+
>>> # Get three inputs of type: str, str or None, and float
|
|
331
|
+
>>> data = [str, None, float] # first name, last name and age
|
|
332
|
+
>>> cout << "Please enter a first name, last name and age(separated by space): "
|
|
333
|
+
Please enter a first name, last name and age(separated by space):
|
|
334
|
+
>>> cin >> data;
|
|
335
|
+
M 21
|
|
336
|
+
>>> name = data[0] + (data[1] if data[1] is not None else '')
|
|
337
|
+
>>> age = data[2]
|
|
338
|
+
>>> cout << name << " is " << age << " years old." << log21.endl;
|
|
339
|
+
M is 21.0 years old.
|
|
340
|
+
>>>
|
|
341
|
+
>>> # Example 2
|
|
342
|
+
>>> # Get any number of inputs
|
|
343
|
+
>>> data = []
|
|
344
|
+
>>> cout << "Enter something: ";
|
|
345
|
+
Enter something:
|
|
346
|
+
>>> cin >> data;
|
|
347
|
+
What ever man 1 2 3 !
|
|
348
|
+
>>> cout << "Here are the items you chose: " << data << log21.endl;
|
|
349
|
+
Here are the items you chose: ['What', 'ever', 'man', '1', '2', '3', '!']
|
|
350
|
+
>>>
|
|
351
|
+
>>> # Example 3
|
|
352
|
+
>>> # Get two inputs of type int with defaults: 1280 and 720
|
|
353
|
+
>>> data = [1280, 720]
|
|
354
|
+
>>> cout << "Enter the width and the height: ";
|
|
355
|
+
Enter the width and the height:
|
|
356
|
+
>>> cin >> data;
|
|
357
|
+
500
|
|
358
|
+
|
|
359
|
+
>>> cout << "Width: " << data[0] << " Height: " << data[1] << log21.endl;
|
|
360
|
+
Width: 500 Height: 720
|
|
361
|
+
>>>
|
|
362
|
+
|
|
363
|
+
:param obj: The object to redirect the output to.
|
|
364
|
+
:return: The Logger object.
|
|
365
|
+
"""
|
|
366
|
+
n = len(obj) - 1
|
|
367
|
+
if n >= 0:
|
|
368
|
+
data = []
|
|
369
|
+
while n >= 0:
|
|
370
|
+
tmp = _sys.stdin.readline()[:-1].split(' ', maxsplit=n)
|
|
371
|
+
if tmp:
|
|
372
|
+
data.extend(tmp)
|
|
373
|
+
else:
|
|
374
|
+
data.append('')
|
|
375
|
+
n -= len(tmp)
|
|
376
|
+
tmp = []
|
|
377
|
+
for i, item in enumerate(data):
|
|
378
|
+
if obj[i] is None:
|
|
379
|
+
tmp.append(item or None)
|
|
380
|
+
elif isinstance(obj[i], type):
|
|
381
|
+
try:
|
|
382
|
+
tmp.append(obj[i](item))
|
|
383
|
+
except ValueError:
|
|
384
|
+
tmp.append(obj[i]())
|
|
385
|
+
else:
|
|
386
|
+
try:
|
|
387
|
+
tmp.append(obj[i].__class__(item))
|
|
388
|
+
except ValueError:
|
|
389
|
+
tmp.append(obj[i])
|
|
390
|
+
obj[:] = tmp
|
|
391
|
+
else:
|
|
392
|
+
obj[:] = _sys.stdin.readline()[:-1].split()
|
|
393
|
+
|
|
394
|
+
return self
|
|
395
|
+
|
|
290
396
|
|
|
291
397
|
def _add_one(name: str) -> str:
|
|
292
398
|
"""Add one to the end of a string.
|
|
@@ -6,35 +6,34 @@ import logging as _logging
|
|
|
6
6
|
from typing import (Type as _Type, Tuple as _Tuple, Union as _Union,
|
|
7
7
|
Mapping as _Mapping, Optional as _Optional)
|
|
8
8
|
|
|
9
|
-
from
|
|
10
|
-
from
|
|
11
|
-
|
|
12
|
-
from
|
|
13
|
-
|
|
14
|
-
from
|
|
15
|
-
from
|
|
16
|
-
from
|
|
17
|
-
from
|
|
18
|
-
from
|
|
19
|
-
from
|
|
20
|
-
from
|
|
21
|
-
from
|
|
22
|
-
from
|
|
23
|
-
from
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
__version__ =
|
|
27
|
-
|
|
28
|
-
__github__ = "Https://GitHub.com/MPCodeWriter21/log21"
|
|
9
|
+
from . import CrashReporter
|
|
10
|
+
from .Colors import (Colors, get_color, get_colors, ansi_escape, closest_color,
|
|
11
|
+
get_color_name)
|
|
12
|
+
from .Levels import INFO, WARN, DEBUG, ERROR, FATAL, INPUT, NOTSET, WARNING, CRITICAL
|
|
13
|
+
from .Logger import Logger
|
|
14
|
+
from .PPrint import PrettyPrinter, pformat
|
|
15
|
+
from .Manager import Manager
|
|
16
|
+
from .Argparse import ColorizingArgumentParser
|
|
17
|
+
from .TreePrint import TreePrint, tree_format
|
|
18
|
+
from .Formatters import ColorizingFormatter, DecolorizingFormatter, _Formatter
|
|
19
|
+
from .Argumentify import argumentify
|
|
20
|
+
from .FileHandler import FileHandler, DecolorizingFileHandler
|
|
21
|
+
from .ProgressBar import ProgressBar
|
|
22
|
+
from .LoggingWindow import LoggingWindow, LoggingWindowHandler
|
|
23
|
+
from .StreamHandler import StreamHandler, ColorizingStreamHandler
|
|
24
|
+
|
|
25
|
+
__author__ = 'CodeWriter21 (Mehrad Pooryoussof)'
|
|
26
|
+
__version__ = '2.9.1'
|
|
27
|
+
__github__ = 'Https://GitHub.com/MPCodeWriter21/log21'
|
|
29
28
|
__all__ = [
|
|
30
29
|
'ColorizingStreamHandler', 'DecolorizingFileHandler', 'ColorizingFormatter',
|
|
31
30
|
'DecolorizingFormatter', 'get_logger', 'Logger', 'Colors', 'get_color',
|
|
32
31
|
'get_colors', 'CRITICAL', 'FATAL', 'ERROR', 'WARNING', 'WARN', 'INFO', 'DEBUG',
|
|
33
32
|
'NOTSET', 'INPUT', 'StreamHandler', 'ColorizingArgumentParser', 'PrettyPrinter',
|
|
34
33
|
'pformat', 'pprint', 'pretty_print', 'tree_format', 'TreePrint', 'Manager',
|
|
35
|
-
'get_color_name', 'closest_color', 'ansi_escape', '
|
|
36
|
-
'
|
|
37
|
-
'
|
|
34
|
+
'get_color_name', 'closest_color', 'ansi_escape', '__author__', '__github__',
|
|
35
|
+
'debug', 'info', 'warning', 'warn', 'error', 'critical', 'fatal', 'exception',
|
|
36
|
+
'log', 'basic_config', 'basicConfig', 'ProgressBar', 'progress_bar',
|
|
38
37
|
'LoggingWindow', 'LoggingWindowHandler', 'get_logging_window', 'CrashReporter',
|
|
39
38
|
'console_reporter', 'file_reporter', 'argumentify'
|
|
40
39
|
]
|
|
@@ -46,7 +45,7 @@ _logging.setLoggerClass(Logger)
|
|
|
46
45
|
def _prepare_formatter(
|
|
47
46
|
fmt: _Optional[str] = None,
|
|
48
47
|
style: str = '%',
|
|
49
|
-
datefmt: str =
|
|
48
|
+
datefmt: str = '%H:%M:%S',
|
|
50
49
|
show_level: bool = True,
|
|
51
50
|
show_time: bool = True,
|
|
52
51
|
colorize_time_and_level: bool = True,
|
|
@@ -57,11 +56,11 @@ def _prepare_formatter(
|
|
|
57
56
|
# Prepares a formatting if the fmt was None
|
|
58
57
|
if not fmt:
|
|
59
58
|
style = '%'
|
|
60
|
-
fmt =
|
|
59
|
+
fmt = '%(message)s'
|
|
61
60
|
if show_level:
|
|
62
|
-
fmt =
|
|
61
|
+
fmt = '[%(levelname)s] ' + fmt
|
|
63
62
|
if show_time:
|
|
64
|
-
fmt =
|
|
63
|
+
fmt = '[%(asctime)s] ' + fmt
|
|
65
64
|
fmt = '\r' + fmt
|
|
66
65
|
|
|
67
66
|
if level_colors and not issubclass(formatter_class, ColorizingFormatter):
|
|
@@ -101,7 +100,7 @@ def get_logger(
|
|
|
101
100
|
show_level: bool = True,
|
|
102
101
|
colorize_time_and_level: bool = True,
|
|
103
102
|
fmt: _Optional[str] = None,
|
|
104
|
-
datefmt: str =
|
|
103
|
+
datefmt: str = '%H:%M:%S',
|
|
105
104
|
style: str = '%',
|
|
106
105
|
handle_carriage_return: bool = True,
|
|
107
106
|
handle_new_line: bool = True,
|
|
@@ -209,7 +208,7 @@ def get_logging_window(
|
|
|
209
208
|
show_level: bool = True,
|
|
210
209
|
colorize_time_and_level: bool = True,
|
|
211
210
|
fmt: _Optional[str] = None,
|
|
212
|
-
datefmt: str =
|
|
211
|
+
datefmt: str = '%H:%M:%S',
|
|
213
212
|
style: str = '%',
|
|
214
213
|
handle_carriage_return: bool = True,
|
|
215
214
|
handle_new_line: bool = True,
|
|
@@ -421,7 +420,7 @@ def basic_config(
|
|
|
421
420
|
stream=None,
|
|
422
421
|
filename=None,
|
|
423
422
|
filemode: str = 'a',
|
|
424
|
-
date_format: str =
|
|
423
|
+
date_format: str = '%H:%M:%S',
|
|
425
424
|
style: str = '%',
|
|
426
425
|
format_: _Optional[str] = None,
|
|
427
426
|
level: _Optional[_Union[int, str]] = None
|
|
@@ -627,6 +626,8 @@ def progress_bar(
|
|
|
627
626
|
print(progress_bar_.get_bar(progress, total))
|
|
628
627
|
|
|
629
628
|
|
|
629
|
+
endl = '\n'
|
|
630
|
+
|
|
630
631
|
console_reporter = CrashReporter.ConsoleReporter()
|
|
631
632
|
|
|
632
633
|
file_reporter = CrashReporter.FileReporter(file='.crash_report.log')
|