Skip to content

Commit 22f1b84

Browse files
Some bug fixes.
1 parent 5b65140 commit 22f1b84

5 files changed

Lines changed: 24 additions & 7 deletions

File tree

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.4.4
10+
11+
Some bug fixes.
12+
913
### 2.4.3
1014

1115
Improvements.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Features
1414

1515
+ Colors : The main reason for this package was to log text in the Windows console with the support of ANSI colors.
1616
+ 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
17+
+ Logging : A similar logger to logging. Logger but with colorized output and other options such as levelname
1818
modifications. It can also decolorize the output if you want to log into a file.
1919
+ Pretty printing : Have you ever wanted to colorize the output of the pprint module? log21's pretty printer can do
2020
that.
@@ -53,9 +53,9 @@ python setup.py install
5353
Changes
5454
-------
5555

56-
### 2.4.3
56+
### 2.4.4
5757

58-
Improvements.
58+
Some bug fixes.
5959

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

log21/Formatters.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
class _Formatter(__Formatter):
14-
level_names: _Dict[int, str] = {
14+
_level_names: _Dict[int, str] = {
1515
DEBUG: 'DEBUG',
1616
INFO: 'INFO',
1717
WARNING: 'WARNING',
@@ -52,6 +52,19 @@ def __init__(self, fmt: str = None, datefmt: str = None, style: str = '%', level
5252
for level, name in level_names.items():
5353
self.level_names[level] = name
5454

55+
@property
56+
def level_names(self):
57+
return self._level_names
58+
59+
@level_names.setter
60+
def level_names(self, level_names):
61+
if level_names:
62+
if not isinstance(level_names, _Dict):
63+
raise TypeError('`level_names` must be a dictionary!')
64+
self._level_names = level_names
65+
else:
66+
self._level_names = dict()
67+
5568
def format(self, record) -> str:
5669
record.message = record.getMessage()
5770
if self.usesTime():

log21/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from log21.Formatters import ColorizingFormatter, DecolorizingFormatter
2323
from log21.Colors import Colors, get_color, get_colors, ansi_escape, get_color_name, closest_color
2424

25-
__version__ = "2.4.3"
25+
__version__ = "2.4.4"
2626
__author__ = "CodeWriter21 (Mehrad Pooryoussof)"
2727
__github__ = "Https://GitHub.com/MPCodeWriter21/log21"
2828
__all__ = ['ColorizingStreamHandler', 'DecolorizingFileHandler', 'ColorizingFormatter', 'DecolorizingFormatter',
@@ -53,7 +53,7 @@ def _prepare_formatter(fmt: str = None, style: str = '%', datefmt: str = "%H:%M:
5353
fmt = '\r' + fmt
5454
# Defines the formatter
5555
formatter = formatter_class(fmt, datefmt, style=style)
56-
if isinstance(formatter, Formatters._Formatter):
56+
if isinstance(formatter, Formatters._Formatter) and level_names:
5757
formatter.level_names = level_names
5858
if not colorize_time_and_level and isinstance(formatter, ColorizingFormatter):
5959
for key in formatter.level_colors:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
long_description = file.read()
88

99
DESCRIPTION = 'A simple logging package that helps you log colorized messages in Windows console.'
10-
VERSION = '2.4.3'
10+
VERSION = '2.4.4'
1111

1212
setup(
1313
name='log21',

0 commit comments

Comments
 (0)