Skip to content

Commit 77a604e

Browse files
Added Print logging level.
1 parent b03f85c commit 77a604e

11 files changed

Lines changed: 162 additions & 15 deletions

File tree

.gitignore

Lines changed: 126 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,129 @@
1-
.idea/
1+
# Byte-compiled / optimized / DLL files
22
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
311
build/
12+
develop-eggs/
413
dist/
5-
log21.egg-*/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
target/
76+
77+
# Jupyter Notebook
78+
.ipynb_checkpoints
79+
80+
# IPython
81+
profile_default/
82+
ipython_config.py
83+
84+
# pyenv
85+
.python-version
86+
87+
# pipenv
88+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91+
# install all needed dependencies.
92+
#Pipfile.lock
93+
94+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
95+
__pypackages__/
96+
97+
# Celery stuff
98+
celerybeat-schedule
99+
celerybeat.pid
100+
101+
# SageMath parsed files
102+
*.sage.py
103+
104+
# Environments
105+
.env
106+
.venv
107+
env/
108+
venv/
109+
ENV/
110+
env.bak/
111+
venv.bak/
112+
113+
# Spyder project settings
114+
.spyderproject
115+
.spyproject
116+
117+
# Rope project settings
118+
.ropeproject
119+
120+
# mkdocs documentation
121+
/site
122+
123+
# mypy
124+
.mypy_cache/
125+
.dmypy.json
126+
dmypy.json
127+
128+
# Pyre type checker
129+
.pyre/

CHANGES-LOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ Help this project by [Donation](DONATE.md)
66
Changes log
77
-----------
88

9+
### 2.3.6
10+
11+
Added `Print` logging level.
12+
913
### 2.3.5
1014

1115
Minor improvements.

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ python setup.py install
5353
Changes
5454
-------
5555

56-
### 2.3.5
56+
### 2.3.6
5757

58-
Minor improvements.
58+
Added `Print` logging level.
5959

6060
[Full Changes Log](https://github.com/MPCodeWriter21/log21/blob/master/CHANGES-LOG.md)
6161

@@ -259,4 +259,8 @@ In order to support this project you can donate some crypto of your choice 8D
259259

260260
Or if you can't, give [this project](https://github.com/MPCodeWriter21/log21) a star on GitHub :)
261261

262+
References
263+
----------
262264

265+
+ ANSI Color Codes (
266+
Wikipedia): [https://en.wikipedia.org/wiki/ANSI_escape_code](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors)

docs/README-fa.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,12 @@ for i in range(84):
254254
[آدرس های رمزارز](https://github.com/MPCodeWriter21/log21/blob/master/DONATE.md)
255255

256256
یا اگر نمی توانید، به [این پروژه](https://github.com/MPCodeWriter21/log21) در GitHub ستاره بدهید :)
257-
</div>
258257

259258

259+
ارجاع ها
260+
----------
261+
262+
+ کد های رنگ ANSI (
263+
ویکیپدیا): [https://en.wikipedia.org/wiki/ANSI_escape_code](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors)
264+
265+
</div>

docs/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,4 +252,9 @@ In order to support this project you can donate some crypto of your choice 8D
252252

253253
Or if you can't, give [this project](https://github.com/MPCodeWriter21/log21) a star on GitHub :)
254254

255+
References
256+
----------
257+
258+
+ ANSI Color Codes (
259+
Wikipedia): [https://en.wikipedia.org/wiki/ANSI_escape_code](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors)
255260

log21/CrashReporter/crash_report.log

Whitespace-only changes.

log21/Formatters.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from logging import Formatter as __Formatter
66
from typing import Dict as _Dict, Tuple as _Tuple
77
from log21.Colors import get_colors as _gc, ansi_escape
8-
from log21.Levels import INPUT, CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET
8+
from log21.Levels import INPUT, CRITICAL, ERROR, WARNING, INFO, DEBUG, PRINT
99

1010
__all__ = ['ColorizingFormatter', 'DecolorizingFormatter']
1111

@@ -17,6 +17,7 @@ class _Formatter(__Formatter):
1717
WARNING: 'WARNING',
1818
ERROR: 'ERROR',
1919
CRITICAL: 'CRITICAL',
20+
PRINT: 'PRINT',
2021
INPUT: 'INPUT'
2122
}
2223

@@ -80,7 +81,9 @@ class ColorizingFormatter(_Formatter):
8081
INFO: ('green',),
8182
WARNING: ('lightyellow',),
8283
ERROR: ('light red',),
83-
CRITICAL: ('background red', 'white')
84+
CRITICAL: ('background red', 'white'),
85+
PRINT: ('Cyan',),
86+
INPUT: ('Magenta',)
8487
}
8588
time_color: _Tuple[str, ...] = ('lightblue',)
8689
name_color = pathname_color = filename_color = module_color = func_name_color = thread_name_color = \

log21/Levels.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33

44
import logging as _logging
55

6-
__all__ = ['CRITICAL', 'FATAL', 'ERROR', 'WARNING', 'WARN', 'INFO', 'DEBUG', 'NOTSET', 'INPUT']
6+
__all__ = ['CRITICAL', 'FATAL', 'ERROR', 'WARNING', 'WARN', 'INFO', 'DEBUG', 'NOTSET', 'INPUT', 'PRINT']
77

8-
INPUT = 60
8+
INPUT = 70
9+
PRINT = 60
910
CRITICAL = _logging.CRITICAL
1011
FATAL = CRITICAL
1112
ERROR = _logging.ERROR

log21/Logger.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from logging import raiseExceptions as _raiseExceptions
99

1010
import log21 as _log21
11-
from log21.Levels import CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET
11+
from log21.Levels import CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET, PRINT, INPUT
1212

1313
__all__ = ['Logger']
1414

@@ -32,7 +32,7 @@ def isEnabledFor(self, level):
3232
Is this logger enabled for level 'level'?
3333
"""
3434

35-
return self.level <= level
35+
return (self.level <= level) or (level in (PRINT, INPUT))
3636

3737
def log(self, level: int, *msg, args: tuple = (), end='\n', **kwargs):
3838
"""
@@ -150,7 +150,7 @@ def print(self, *msg, args: tuple = (), end='\n', **kwargs):
150150
logger.print("Houston, we have a %s", args=("major disaster",), exc_info=1)
151151
"""
152152
msg = ' '.join([str(m) for m in msg]) + end
153-
self._log(self.level if self.level >= NOTSET else NOTSET, msg, args, **kwargs)
153+
self._log(PRINT, msg, args, **kwargs)
154154

155155
def input(self, *msg, args: tuple = (), end='', **kwargs):
156156
"""
@@ -162,7 +162,7 @@ def input(self, *msg, args: tuple = (), end='', **kwargs):
162162
age = logger.input("Enter your age: ")
163163
"""
164164
msg = ' '.join([str(m) for m in msg]) + end
165-
self._log(self.level if self.level >= NOTSET else NOTSET, msg, args, **kwargs)
165+
self._log(INPUT, msg, args, **kwargs)
166166
return input()
167167

168168
def getpass(self, *msg, args: tuple = (), end='', **kwargs):

log21/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from log21.Formatters import ColorizingFormatter, DecolorizingFormatter
2222
from log21.Colors import Colors, get_color, get_colors, ansi_escape, get_color_name, closest_color
2323

24-
__version__ = "2.3.5"
24+
__version__ = "2.3.6"
2525
__author__ = "CodeWriter21 (Mehrad Pooryoussof)"
2626
__github__ = "Https://GitHub.com/MPCodeWriter21/log21"
2727
__all__ = ['ColorizingStreamHandler', 'DecolorizingFileHandler', 'ColorizingFormatter', 'DecolorizingFormatter',

0 commit comments

Comments
 (0)