log21 2.4.7__tar.gz → 2.5.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.
Files changed (26) hide show
  1. {log21-2.4.7 → log21-2.5.0}/LICENSE.txt +1 -1
  2. {log21-2.4.7 → log21-2.5.0}/PKG-INFO +5 -7
  3. {log21-2.4.7 → log21-2.5.0}/README.md +4 -6
  4. {log21-2.4.7 → log21-2.5.0}/log21/Argparse.py +3 -3
  5. {log21-2.4.7 → log21-2.5.0}/log21/CrashReporter/Formatters.py +2 -2
  6. {log21-2.4.7 → log21-2.5.0}/log21/Formatters.py +18 -18
  7. {log21-2.4.7 → log21-2.5.0}/log21/PPrint.py +4 -4
  8. {log21-2.4.7 → log21-2.5.0}/log21/ProgressBar.py +4 -4
  9. {log21-2.4.7 → log21-2.5.0}/log21/TreePrint.py +16 -14
  10. {log21-2.4.7 → log21-2.5.0}/log21/__init__.py +24 -11
  11. {log21-2.4.7 → log21-2.5.0}/log21.egg-info/PKG-INFO +5 -7
  12. {log21-2.4.7 → log21-2.5.0}/setup.py +1 -1
  13. {log21-2.4.7 → log21-2.5.0}/log21/Colors.py +0 -0
  14. {log21-2.4.7 → log21-2.5.0}/log21/CrashReporter/Reporters.py +0 -0
  15. {log21-2.4.7 → log21-2.5.0}/log21/CrashReporter/__init__.py +0 -0
  16. {log21-2.4.7 → log21-2.5.0}/log21/FileHandler.py +0 -0
  17. {log21-2.4.7 → log21-2.5.0}/log21/Levels.py +0 -0
  18. {log21-2.4.7 → log21-2.5.0}/log21/Logger.py +0 -0
  19. {log21-2.4.7 → log21-2.5.0}/log21/LoggingWindow.py +0 -0
  20. {log21-2.4.7 → log21-2.5.0}/log21/Manager.py +0 -0
  21. {log21-2.4.7 → log21-2.5.0}/log21/StreamHandler.py +0 -0
  22. {log21-2.4.7 → log21-2.5.0}/log21.egg-info/SOURCES.txt +0 -0
  23. {log21-2.4.7 → log21-2.5.0}/log21.egg-info/dependency_links.txt +0 -0
  24. {log21-2.4.7 → log21-2.5.0}/log21.egg-info/requires.txt +0 -0
  25. {log21-2.4.7 → log21-2.5.0}/log21.egg-info/top_level.txt +0 -0
  26. {log21-2.4.7 → log21-2.5.0}/setup.cfg +0 -0
@@ -186,7 +186,7 @@
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright [2021-2022] [CodeWriter21]
189
+ Copyright [2021-2023] [CodeWriter21]
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: log21
3
- Version: 2.4.7
3
+ Version: 2.5.0
4
4
  Summary: A simple logging package that helps you log colorized messages in Windows console.
5
5
  Home-page: https://github.com/MPCodeWriter21/log21
6
6
  Author: CodeWriter21(Mehrad Pooryoussof)
@@ -73,14 +73,12 @@ python setup.py install
73
73
  Changes
74
74
  -------
75
75
 
76
- ### 2.4.7
76
+ ### 2.5.0
77
77
 
78
- Added `extra_values` argument to `CrashReporter.Formatter` which will let you pass extra static or dynamic values to the
79
- report formatter.
80
- They can be used in the format string. For dynamic values you can pass a function that takes no
81
- arguments as the value.
78
+ Added `level_colors` argument to `log21.get_logger` function with will be passed to the formatter and allows
79
+ user to set custom level colors while making a new logger.
82
80
 
83
- [Full Changes Log](https://github.com/MPCodeWriter21/log21/blob/master/CHANGES-LOG.md)
81
+ [Full CHANGELOG](https://github.com/MPCodeWriter21/log21/blob/master/CHANGELOG.md)
84
82
 
85
83
 
86
84
  Usage Examples:
@@ -53,14 +53,12 @@ python setup.py install
53
53
  Changes
54
54
  -------
55
55
 
56
- ### 2.4.7
56
+ ### 2.5.0
57
57
 
58
- Added `extra_values` argument to `CrashReporter.Formatter` which will let you pass extra static or dynamic values to the
59
- report formatter.
60
- They can be used in the format string. For dynamic values you can pass a function that takes no
61
- arguments as the value.
58
+ Added `level_colors` argument to `log21.get_logger` function with will be passed to the formatter and allows
59
+ user to set custom level colors while making a new logger.
62
60
 
63
- [Full Changes Log](https://github.com/MPCodeWriter21/log21/blob/master/CHANGES-LOG.md)
61
+ [Full CHANGELOG](https://github.com/MPCodeWriter21/log21/blob/master/CHANGELOG.md)
64
62
 
65
63
 
66
64
  Usage Examples:
@@ -5,7 +5,7 @@ import re as _re
5
5
  import sys as _sys
6
6
  import log21 as _log21
7
7
  import argparse as _argparse
8
- from typing import Dict as _Dict
8
+ from typing import Mapping as _Mapping
9
9
  from gettext import gettext as _gettext
10
10
  from textwrap import TextWrapper as _TextWrapper
11
11
  from log21.Colors import get_colors as _gc
@@ -27,7 +27,7 @@ class ColorizingHelpFormatter(_argparse.HelpFormatter):
27
27
  'choices': 'LightGreen'
28
28
  }
29
29
 
30
- def __init__(self, prog, indent_increment=2, max_help_position=24, width=None, colors: _Dict[str, str] = None):
30
+ def __init__(self, prog, indent_increment=2, max_help_position=24, width=None, colors: _Mapping[str, str] = None):
31
31
  super().__init__(prog, indent_increment, max_help_position, width)
32
32
  if colors:
33
33
  for key, value in colors.items():
@@ -477,7 +477,7 @@ class ColorizingTextWrapper(_TextWrapper):
477
477
 
478
478
 
479
479
  class ColorizingArgumentParser(_argparse.ArgumentParser):
480
- def __init__(self, formatter_class=ColorizingHelpFormatter, colors: _Dict[str, str] = None, **kwargs):
480
+ def __init__(self, formatter_class=ColorizingHelpFormatter, colors: _Mapping[str, str] = None, **kwargs):
481
481
  self.logger = _log21.Logger('ArgumentParser')
482
482
  self.colors = colors
483
483
  super().__init__(formatter_class=formatter_class, **kwargs)
@@ -4,7 +4,7 @@
4
4
  import traceback
5
5
 
6
6
  from datetime import datetime as _datetime
7
- from typing import Dict as _Dict, Union as _Union, Callable as _Callable, Any as _Any
7
+ from typing import Mapping as _Mapping, Union as _Union, Callable as _Callable, Any as _Any
8
8
 
9
9
  __all__ = ['Formatter', 'CONSOLE_REPORTER_FORMAT', 'FILE_REPORTER_FORMAT', 'EMAIL_REPORTER_FORMAT']
10
10
 
@@ -23,7 +23,7 @@ RESERVED_KEYS = (
23
23
 
24
24
  class Formatter:
25
25
  def __init__(self, format_: str, style: str = '%', datefmt: str = '%Y-%m-%d %H:%M:%S',
26
- extra_values: _Dict[str, _Union[str, _Callable, _Any]] = None):
26
+ extra_values: _Mapping[str, _Union[str, _Callable, _Any]] = None):
27
27
  self._format = format_
28
28
 
29
29
  if style in ['%', '{']:
@@ -3,7 +3,7 @@
3
3
 
4
4
  import time as _time
5
5
  from logging import Formatter as __Formatter
6
- from typing import Dict as _Dict, Tuple as _Tuple
6
+ from typing import Mapping as _Mapping, Tuple as _Tuple
7
7
  from log21.Colors import get_colors as _gc, ansi_escape
8
8
  from log21.Levels import INPUT, CRITICAL, ERROR, WARNING, INFO, DEBUG, PRINT
9
9
 
@@ -11,7 +11,7 @@ __all__ = ['ColorizingFormatter', 'DecolorizingFormatter']
11
11
 
12
12
 
13
13
  class _Formatter(__Formatter):
14
- _level_names: _Dict[int, str] = {
14
+ _level_names: _Mapping[int, str] = {
15
15
  DEBUG: 'DEBUG',
16
16
  INFO: 'INFO',
17
17
  WARNING: 'WARNING',
@@ -21,7 +21,7 @@ class _Formatter(__Formatter):
21
21
  INPUT: 'INPUT'
22
22
  }
23
23
 
24
- def __init__(self, fmt: str = None, datefmt: str = None, style: str = '%', level_names: _Dict[int, str] = None):
24
+ def __init__(self, fmt: str = None, datefmt: str = None, style: str = '%', level_names: _Mapping[int, str] = None):
25
25
  """
26
26
  `level_names` usage:
27
27
  >>> import log21
@@ -59,8 +59,8 @@ class _Formatter(__Formatter):
59
59
  @level_names.setter
60
60
  def level_names(self, level_names):
61
61
  if level_names:
62
- if not isinstance(level_names, _Dict):
63
- raise TypeError('`level_names` must be a dictionary!')
62
+ if not isinstance(level_names, _Mapping):
63
+ raise TypeError('`level_names` must be a Mapping, a dictionary like object!')
64
64
  self._level_names = level_names
65
65
  else:
66
66
  self._level_names = dict()
@@ -89,7 +89,7 @@ class _Formatter(__Formatter):
89
89
 
90
90
  class ColorizingFormatter(_Formatter):
91
91
  # Default color values
92
- level_colors: _Dict[int, _Tuple[str, ...]] = {
92
+ level_colors: _Mapping[int, _Tuple[str, ...]] = {
93
93
  DEBUG: ('lightblue',),
94
94
  INFO: ('green',),
95
95
  WARNING: ('lightyellow',),
@@ -102,8 +102,8 @@ class ColorizingFormatter(_Formatter):
102
102
  name_color = pathname_color = filename_color = module_color = func_name_color = thread_name_color = \
103
103
  message_color = tuple()
104
104
 
105
- def __init__(self, fmt: str = None, datefmt: str = None, style: str = '%', level_names: _Dict[int, str] = None,
106
- level_colors: _Dict[int, _Tuple[str]] = None,
105
+ def __init__(self, fmt: str = None, datefmt: str = None, style: str = '%', level_names: _Mapping[int, str] = None,
106
+ level_colors: _Mapping[int, _Tuple[str]] = None,
107
107
  time_color: _Tuple[str, ...] = None, name_color: _Tuple[str, ...] = None,
108
108
  pathname_color: _Tuple[str, ...] = None, filename_color: _Tuple[str, ...] = None,
109
109
  module_color: _Tuple[str, ...] = None, func_name_color: _Tuple[str, ...] = None,
@@ -111,40 +111,40 @@ class ColorizingFormatter(_Formatter):
111
111
  super().__init__(fmt=fmt, datefmt=datefmt, style=style, level_names=level_names)
112
112
  # Checks and sets colors
113
113
  if level_colors:
114
- if type(level_colors) is not dict:
115
- raise TypeError('`level_colors` must be a dictionary!')
114
+ if not isinstance(level_colors, _Mapping):
115
+ raise TypeError('`level_colors` must be a dictionary like object!')
116
116
  for level, color in level_colors.items():
117
117
  self.level_colors[level] = (_gc(*color),)
118
118
  if time_color:
119
- if type(time_color) is not tuple:
119
+ if not isinstance(time_color, tuple):
120
120
  raise TypeError('`time_color` must be a tuple!')
121
121
  self.time_color = time_color
122
122
  if name_color:
123
- if type(name_color) is not tuple:
123
+ if not isinstance(name_color, tuple):
124
124
  raise TypeError('`name_color` must be a tuple!')
125
125
  self.name_color = name_color
126
126
  if pathname_color:
127
- if type(pathname_color) is not tuple:
127
+ if not isinstance(pathname_color, tuple):
128
128
  raise TypeError('`pathname_color` must be a tuple!')
129
129
  self.pathname_color = pathname_color
130
130
  if filename_color:
131
- if type(filename_color) is not tuple:
131
+ if not isinstance(filename_color, tuple):
132
132
  raise TypeError('`filename_color` must be a tuple!')
133
133
  self.filename_color = filename_color
134
134
  if module_color:
135
- if type(module_color) is not tuple:
135
+ if not isinstance(module_color, tuple):
136
136
  raise TypeError('`module_color` must be a tuple!')
137
137
  self.module_color = module_color
138
138
  if func_name_color:
139
- if type(func_name_color) is not tuple:
139
+ if not isinstance(func_name_color, tuple):
140
140
  raise TypeError('`func_name_color` must be a tuple!')
141
141
  self.func_name_color = func_name_color
142
142
  if thread_name_color:
143
- if type(thread_name_color) is not tuple:
143
+ if not isinstance(thread_name_color, tuple):
144
144
  raise TypeError('`thread_name_color` must be a tuple!')
145
145
  self.thread_name_color = thread_name_color
146
146
  if message_color:
147
- if type(message_color) is not tuple:
147
+ if not isinstance(message_color, tuple):
148
148
  raise TypeError('`message_color` must be a tuple!')
149
149
  self.message_color = message_color
150
150
 
@@ -7,7 +7,7 @@ import types as _types
7
7
  import collections as _collections
8
8
  import dataclasses as _dataclasses
9
9
 
10
- from typing import Dict as _Dict, Union as _Union
10
+ from typing import Mapping as _Mapping, Union as _Union
11
11
  from pprint import PrettyPrinter as _PrettyPrinter
12
12
 
13
13
  from log21.Colors import get_colors as _gc
@@ -65,7 +65,7 @@ class _SafeKey:
65
65
 
66
66
 
67
67
  class PrettyPrinter(_PrettyPrinter):
68
- signs_colors: _Dict[str, str] = {
68
+ signs_colors: _Mapping[str, str] = {
69
69
  'square-brackets': _gc('LightCyan'),
70
70
  'curly-braces': _gc('LightBlue'),
71
71
  'parenthesis': _gc('LightGreen'),
@@ -75,7 +75,7 @@ class PrettyPrinter(_PrettyPrinter):
75
75
  'data': _gc('Green')
76
76
  }
77
77
 
78
- def __init__(self, indent=1, width=80, depth=None, stream=None, signs_colors: _Dict[str, str] = None, *,
78
+ def __init__(self, indent=1, width=80, depth=None, stream=None, signs_colors: _Mapping[str, str] = None, *,
79
79
  compact=False, sort_dicts=True, underscore_numbers=False, **kwargs):
80
80
  super().__init__(indent=indent, width=width, depth=depth, stream=stream, compact=compact, **kwargs)
81
81
  self._depth = depth
@@ -562,7 +562,7 @@ class PrettyPrinter(_PrettyPrinter):
562
562
  _dispatch[_collections.UserString.__repr__] = _pprint_user_string
563
563
 
564
564
 
565
- def pformat(obj, indent=1, width=80, depth=None, signs_colors: _Dict[str, str] = None, *, compact=False,
565
+ def pformat(obj, indent=1, width=80, depth=None, signs_colors: _Mapping[str, str] = None, *, compact=False,
566
566
  sort_dicts=True, underscore_numbers=False, **kwargs):
567
567
  """Format a Python object into a pretty-printed representation."""
568
568
  return PrettyPrinter(indent=indent, width=width, depth=depth, compact=compact, signs_colors=signs_colors,
@@ -3,7 +3,7 @@
3
3
 
4
4
  import shutil as _shutil
5
5
 
6
- from typing import Dict as _Dict, Any as _Any
6
+ from typing import Mapping as _Mapping, Any as _Any
7
7
 
8
8
  import log21 as _log21
9
9
  from log21.Logger import Logger as _Logger
@@ -42,7 +42,7 @@ class ProgressBar:
42
42
  def __init__(self, *args, width: int = None, show_percentage: bool = True, prefix: str = '|', suffix: str = '|',
43
43
  fill: str = '█', empty: str = ' ', format_: str = None, style: str = '%',
44
44
  new_line_when_complete: bool = True, colors: dict = None, no_color: bool = False,
45
- logger: '_log21.Logger' = _logger, additional_variables: _Dict[str, _Any] = None):
45
+ logger: '_log21.Logger' = _logger, additional_variables: _Mapping[str, _Any] = None):
46
46
  """
47
47
  :param args: Prevents the use of positional arguments
48
48
  :param width: The width of the progress bar
@@ -87,8 +87,8 @@ class ProgressBar:
87
87
  if colors and no_color:
88
88
  raise PermissionError('You cannot use `no_color` and `colors` parameters together!')
89
89
  if additional_variables:
90
- if not isinstance(additional_variables, dict):
91
- raise TypeError('`additional_variables` must be a dictionary')
90
+ if not isinstance(additional_variables, _Mapping):
91
+ raise TypeError('`additional_variables` must be a dictionary like object.')
92
92
  for key, value in additional_variables.items():
93
93
  if not isinstance(key, str):
94
94
  raise TypeError('`additional_variables` keys must be strings')
@@ -1,7 +1,7 @@
1
1
  # log21.TreePrint.py
2
2
  # CodeWriter21
3
3
 
4
- from typing import Union as _Union
4
+ from typing import Union as _Union, Mapping as _Mapping, Sequence as _Sequence
5
5
 
6
6
  from log21.Colors import get_colors as _gc
7
7
 
@@ -13,8 +13,8 @@ class TreePrint:
13
13
  'fruit': _gc('LightMagenta'),
14
14
  }
15
15
 
16
- def __init__(self, value: _Union[str, int], children: list = None, indent: int = 4, colors: dict = None,
17
- mode='-'):
16
+ def __init__(self, value: _Union[str, int], children: list = None, indent: int = 4,
17
+ colors: _Mapping[str, str] = None, mode='-'):
18
18
  self.value = str(value)
19
19
  if children:
20
20
  self._children = children
@@ -106,9 +106,9 @@ class TreePrint:
106
106
  return self._children[index]
107
107
 
108
108
  @staticmethod
109
- def add_to(node: 'TreePrint.Node', data: _Union[dict, list, str, int], indent: int = 4, colors: dict = None,
110
- mode='-'):
111
- if isinstance(data, dict):
109
+ def add_to(node: 'TreePrint.Node', data: _Union[_Mapping, _Sequence, str, int], indent: int = 4,
110
+ colors: _Mapping[str, str] = None, mode='-'):
111
+ if isinstance(data, _Mapping):
112
112
  if len(data) == 1:
113
113
  child = TreePrint.Node(list(data.keys())[0], indent=indent, colors=colors, mode=mode)
114
114
  TreePrint.Node.add_to(child, list(data.values())[0], indent=indent, colors=colors, mode=mode)
@@ -118,14 +118,14 @@ class TreePrint:
118
118
  child = TreePrint.Node(key, indent=indent, colors=colors, mode=mode)
119
119
  TreePrint.Node.add_to(child, value, indent=indent, colors=colors, mode=mode)
120
120
  node.add_child(child)
121
- elif isinstance(data, list):
121
+ elif isinstance(data, _Sequence):
122
122
  for value in data:
123
- if isinstance(value, dict):
123
+ if isinstance(value, _Mapping):
124
124
  for key, dict_value in value.items():
125
125
  child = TreePrint.Node(key, indent=indent, colors=colors, mode=mode)
126
126
  TreePrint.Node.add_to(child, dict_value, indent=indent, colors=colors, mode=mode)
127
127
  node.add_child(child)
128
- elif isinstance(value, list):
128
+ elif isinstance(value, _Sequence):
129
129
  child = TreePrint.Node('>', indent=indent, colors=colors, mode=mode)
130
130
  TreePrint.Node.add_to(child, value, indent=indent, colors=colors, mode=mode)
131
131
  node.add_child(child)
@@ -136,23 +136,24 @@ class TreePrint:
136
136
  child = TreePrint.Node(str(data), indent=indent, colors=colors, mode=mode)
137
137
  node.add_child(child)
138
138
 
139
- def __init__(self, data: _Union[dict, list, str, int], indent: int = 4, colors: dict = None, mode='-'):
139
+ def __init__(self, data: _Union[_Mapping, _Sequence, str, int], indent: int = 4,
140
+ colors: _Mapping[str, str] = None, mode='-'):
140
141
  self.indent = indent
141
142
  self.mode = mode
142
- if isinstance(data, dict):
143
+ if isinstance(data, _Mapping):
143
144
  if len(data) == 1:
144
145
  self.root = self.Node(list(data.keys())[0], indent=indent, colors=colors)
145
146
  self.add_to_root(list(data.values()), colors=colors)
146
147
  else:
147
148
  self.root = self.Node('root', indent=indent, colors=colors)
148
149
  self.add_to_root(data, colors=colors)
149
- elif isinstance(data, list):
150
+ elif isinstance(data, _Sequence):
150
151
  self.root = self.Node('root', indent=indent, colors=colors)
151
152
  self.add_to_root(data, colors=colors)
152
153
  else:
153
154
  self.root = self.Node(str(data), indent=indent, colors=colors)
154
155
 
155
- def add_to_root(self, data: _Union[dict, list, str, int], colors: dict = None):
156
+ def add_to_root(self, data: _Union[_Mapping, _Sequence, str, int], colors: _Mapping[str, str] = None):
156
157
  self.Node.add_to(self.root, data, indent=self.indent, colors=colors, mode=self.mode)
157
158
 
158
159
  def __str__(self, mode=None):
@@ -161,5 +162,6 @@ class TreePrint:
161
162
  return self.root.__str__(mode=mode)
162
163
 
163
164
 
164
- def tree_format(data: _Union[dict, list, str, int], indent: int = 4, mode='-', colors: dict = None):
165
+ def tree_format(data: _Union[_Mapping, _Sequence, str, int], indent: int = 4, mode='-',
166
+ colors: _Mapping[str, str] = None):
165
167
  return str(TreePrint(data, indent=indent, colors=colors, mode=mode))
@@ -5,7 +5,7 @@ import io as _io
5
5
  import os as _os
6
6
  import logging as _logging
7
7
 
8
- from typing import Union as _Union, Dict as _Dict, Type as _Type
8
+ from typing import Union as _Union, Mapping as _Mapping, Type as _Type, Tuple as _Tuple
9
9
 
10
10
  import log21.CrashReporter as CrashReporter
11
11
 
@@ -22,7 +22,7 @@ from log21.StreamHandler import ColorizingStreamHandler, StreamHandler
22
22
  from log21.Formatters import ColorizingFormatter, DecolorizingFormatter
23
23
  from log21.Colors import Colors, get_color, get_colors, ansi_escape, get_color_name, closest_color
24
24
 
25
- __version__ = "2.4.7"
25
+ __version__ = "2.5.0"
26
26
  __author__ = "CodeWriter21 (Mehrad Pooryoussof)"
27
27
  __github__ = "Https://GitHub.com/MPCodeWriter21/log21"
28
28
  __all__ = ['ColorizingStreamHandler', 'DecolorizingFileHandler', 'ColorizingFormatter', 'DecolorizingFormatter',
@@ -40,7 +40,8 @@ _logging.setLoggerClass(Logger)
40
40
 
41
41
  def _prepare_formatter(fmt: str = None, style: str = '%', datefmt: str = "%H:%M:%S", show_level: bool = True,
42
42
  show_time: bool = True, colorize_time_and_level: bool = True,
43
- level_names: _Dict[int, str] = None,
43
+ level_names: _Mapping[int, str] = None,
44
+ level_colors: _Mapping[int, _Tuple[str, ...]] = None,
44
45
  formatter_class: _Type[_logging.Formatter] = ColorizingFormatter):
45
46
  # Prepares a formatting if the fmt was None
46
47
  if not fmt:
@@ -51,8 +52,17 @@ def _prepare_formatter(fmt: str = None, style: str = '%', datefmt: str = "%H:%M:
51
52
  if show_time:
52
53
  fmt = "[%(asctime)s] " + fmt
53
54
  fmt = '\r' + fmt
55
+
56
+ if level_colors and not issubclass(formatter_class, ColorizingFormatter):
57
+ warning('`formatter_class` should be a subclass of ColorizingFormatter when used with level_colors.')
58
+ warning(f'Using `{formatter_class.__class__.__name__}` might lead to unexpected behaviour!')
59
+
54
60
  # Defines the formatter
55
- formatter = formatter_class(fmt, datefmt, style=style)
61
+ if level_colors:
62
+ formatter = formatter_class(fmt, datefmt, style=style, level_colors=level_colors)
63
+ else:
64
+ formatter = formatter_class(fmt, datefmt, style=style)
65
+
56
66
  if isinstance(formatter, Formatters._Formatter) and level_names:
57
67
  formatter.level_names = level_names
58
68
  if not colorize_time_and_level and isinstance(formatter, ColorizingFormatter):
@@ -66,7 +76,8 @@ def _prepare_formatter(fmt: str = None, style: str = '%', datefmt: str = "%H:%M:
66
76
  def get_logger(name: str = '', level: _Union[int, str] = NOTSET, show_time: bool = True,
67
77
  show_level: bool = True, colorize_time_and_level: bool = True, fmt: str = None,
68
78
  datefmt: str = "%H:%M:%S", style: str = '%', handle_carriage_return: bool = True,
69
- handle_new_line: bool = True, override=False, level_names: _Dict[int, str] = None,
79
+ handle_new_line: bool = True, override=False, level_names: _Mapping[int, str] = None,
80
+ level_colors: _Mapping[int, _Tuple[str, ...]] = None,
70
81
  file: _Union[_os.PathLike, str] = None) -> Logger:
71
82
  """
72
83
  Returns a logging.Logger with colorizing support.
@@ -125,7 +136,8 @@ def get_logger(name: str = '', level: _Union[int, str] = NOTSET, show_time: bool
125
136
  :param handle_new_line: bool = True: Places the NewLine characters at the beginning of the text before everything
126
137
  else
127
138
  :param override: bool = True: Overrides the logger attributes even if it already exists
128
- :param level_names: Dict[int, str] = None: You can specify custom level names.
139
+ :param level_names: Mapping[int, str] = None: You can specify custom level names.
140
+ :param level_colors: Mapping[int, Tuple[str, ...]] = None: You can specify custom level colors.
129
141
  :param file: Union[os.PathLike, str] = None: The file to log to
130
142
  :return: log21.Logger
131
143
  """
@@ -136,7 +148,8 @@ def get_logger(name: str = '', level: _Union[int, str] = NOTSET, show_time: bool
136
148
  logger = _manager.getLogger(name)
137
149
  if (not logger) or override:
138
150
  logger = Logger(name, level)
139
- formatter = _prepare_formatter(fmt, style, datefmt, show_level, show_time, colorize_time_and_level, level_names)
151
+ formatter = _prepare_formatter(fmt, style, datefmt, show_level, show_time, colorize_time_and_level,
152
+ level_names, level_colors)
140
153
 
141
154
  # Defines the handler
142
155
  handler = ColorizingStreamHandler(handle_carriage_return=handle_carriage_return,
@@ -158,7 +171,7 @@ def get_logger(name: str = '', level: _Union[int, str] = NOTSET, show_time: bool
158
171
  def get_logging_window(name: str = '', level: _Union[int, str] = NOTSET, show_time: bool = True,
159
172
  show_level: bool = True, colorize_time_and_level: bool = True, fmt: str = None,
160
173
  datefmt: str = "%H:%M:%S", style: str = '%', handle_carriage_return: bool = True,
161
- handle_new_line: bool = True, override=False, level_names: _Dict[int, str] = None,
174
+ handle_new_line: bool = True, override=False, level_names: _Mapping[int, str] = None,
162
175
  width: int = 80, height: int = 20, allow_shell: bool = False) -> LoggingWindow:
163
176
  """
164
177
  Returns a logging window.
@@ -207,7 +220,7 @@ def get_logging_window(name: str = '', level: _Union[int, str] = NOTSET, show_ti
207
220
  :param handle_new_line: bool = True: Places the NewLine characters at the beginning of the text before everything
208
221
  else
209
222
  :param override: bool = True: Overrides the logger attributes even if it already exists
210
- :param level_names: Dict[int, str] = None: You can specify custom level names.
223
+ :param level_names: Mapping[int, str] = None: You can specify custom level names.
211
224
  :param width: int = 80: The width of the window
212
225
  :param height: int = 20: The height of the window
213
226
  :param allow_shell: bool = False: Allow the user to use the shell
@@ -249,7 +262,7 @@ def getpass(*msg, args: tuple = (), end='', **kwargs):
249
262
  return logger.getpass(*msg, args=args, end=end, **kwargs)
250
263
 
251
264
 
252
- def pprint(obj, indent=1, width=80, depth=None, signs_colors: _Dict[str, str] = None, *, sort_dicts=True,
265
+ def pprint(obj, indent=1, width=80, depth=None, signs_colors: _Mapping[str, str] = None, *, sort_dicts=True,
253
266
  underscore_numbers=False, compact=False, end='\033[0m\n', **kwargs):
254
267
  logger = get_logger('log21.pprint', level=DEBUG, show_time=False, show_level=False)
255
268
  logger.print(pformat(obj=obj, indent=indent, width=width, depth=depth, signs_colors=signs_colors, compact=compact,
@@ -259,7 +272,7 @@ def pprint(obj, indent=1, width=80, depth=None, signs_colors: _Dict[str, str] =
259
272
  pretty_print = pprint
260
273
 
261
274
 
262
- def tree_print(obj, indent: int = 4, mode='-', colors: _Dict[str, str] = None, end='\033[0m\n', **kwargs):
275
+ def tree_print(obj, indent: int = 4, mode='-', colors: _Mapping[str, str] = None, end='\033[0m\n', **kwargs):
263
276
  logger = get_logger('log21.tree_print', level=DEBUG, show_time=False, show_level=False)
264
277
  logger.print(tree_format(obj, indent=indent, mode=mode, colors=colors), end=end, **kwargs)
265
278
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: log21
3
- Version: 2.4.7
3
+ Version: 2.5.0
4
4
  Summary: A simple logging package that helps you log colorized messages in Windows console.
5
5
  Home-page: https://github.com/MPCodeWriter21/log21
6
6
  Author: CodeWriter21(Mehrad Pooryoussof)
@@ -73,14 +73,12 @@ python setup.py install
73
73
  Changes
74
74
  -------
75
75
 
76
- ### 2.4.7
76
+ ### 2.5.0
77
77
 
78
- Added `extra_values` argument to `CrashReporter.Formatter` which will let you pass extra static or dynamic values to the
79
- report formatter.
80
- They can be used in the format string. For dynamic values you can pass a function that takes no
81
- arguments as the value.
78
+ Added `level_colors` argument to `log21.get_logger` function with will be passed to the formatter and allows
79
+ user to set custom level colors while making a new logger.
82
80
 
83
- [Full Changes Log](https://github.com/MPCodeWriter21/log21/blob/master/CHANGES-LOG.md)
81
+ [Full CHANGELOG](https://github.com/MPCodeWriter21/log21/blob/master/CHANGELOG.md)
84
82
 
85
83
 
86
84
  Usage Examples:
@@ -7,7 +7,7 @@ with open('README.md', 'r') as file:
7
7
  long_description = file.read()
8
8
 
9
9
  DESCRIPTION = 'A simple logging package that helps you log colorized messages in Windows console.'
10
- VERSION = '2.4.7'
10
+ VERSION = '2.5.0'
11
11
 
12
12
  setup(
13
13
  name='log21',
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes