Skip to content

Commit

Permalink
Some bug fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
MPCodeWriter21 committed Apr 14, 2023
1 parent 5b65140 commit 22f1b84
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGES-LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Help this project by [Donation](DONATE.md)
Changes log
-----------

### 2.4.4

Some bug fixes.

### 2.4.3

Improvements.
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Features

+ Colors : The main reason for this package was to log text in the Windows console with the support of ANSI colors.
+ Argument parsing : log21's argument parser can be used like python's argparse but it also colorizes the output.
+ Logging : A similar logger to logging.Logger but with colorized output and other options such as levelname
+ Logging : A similar logger to logging. Logger but with colorized output and other options such as levelname
modifications. It can also decolorize the output if you want to log into a file.
+ Pretty printing : Have you ever wanted to colorize the output of the pprint module? log21's pretty printer can do
that.
Expand Down Expand Up @@ -53,9 +53,9 @@ python setup.py install
Changes
-------

### 2.4.3
### 2.4.4

Improvements.
Some bug fixes.

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

Expand Down
15 changes: 14 additions & 1 deletion log21/Formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


class _Formatter(__Formatter):
level_names: _Dict[int, str] = {
_level_names: _Dict[int, str] = {
DEBUG: 'DEBUG',
INFO: 'INFO',
WARNING: 'WARNING',
Expand Down Expand Up @@ -52,6 +52,19 @@ def __init__(self, fmt: str = None, datefmt: str = None, style: str = '%', level
for level, name in level_names.items():
self.level_names[level] = name

@property
def level_names(self):
return self._level_names

@level_names.setter
def level_names(self, level_names):
if level_names:
if not isinstance(level_names, _Dict):
raise TypeError('`level_names` must be a dictionary!')
self._level_names = level_names
else:
self._level_names = dict()

def format(self, record) -> str:
record.message = record.getMessage()
if self.usesTime():
Expand Down
4 changes: 2 additions & 2 deletions log21/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from log21.Formatters import ColorizingFormatter, DecolorizingFormatter
from log21.Colors import Colors, get_color, get_colors, ansi_escape, get_color_name, closest_color

__version__ = "2.4.3"
__version__ = "2.4.4"
__author__ = "CodeWriter21 (Mehrad Pooryoussof)"
__github__ = "Https://GitHub.com/MPCodeWriter21/log21"
__all__ = ['ColorizingStreamHandler', 'DecolorizingFileHandler', 'ColorizingFormatter', 'DecolorizingFormatter',
Expand Down Expand Up @@ -53,7 +53,7 @@ def _prepare_formatter(fmt: str = None, style: str = '%', datefmt: str = "%H:%M:
fmt = '\r' + fmt
# Defines the formatter
formatter = formatter_class(fmt, datefmt, style=style)
if isinstance(formatter, Formatters._Formatter):
if isinstance(formatter, Formatters._Formatter) and level_names:
formatter.level_names = level_names
if not colorize_time_and_level and isinstance(formatter, ColorizingFormatter):
for key in formatter.level_colors:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
long_description = file.read()

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

setup(
name='log21',
Expand Down

0 comments on commit 22f1b84

Please sign in to comment.