python-printr 3.5__tar.gz → 3.7__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-printr
3
- Version: 3.5
3
+ Version: 3.7
4
4
  Summary: printr
5
5
  Home-page: https://github.com/xjxckk/python-printr/
6
6
  Download-URL: https://github.com/xjxckk/python-printr/archive/refs/tags/v0.1.tar.gz
@@ -3,12 +3,13 @@ from pathlib import Path
3
3
  from datetime import datetime
4
4
 
5
5
  class logger:
6
- def __init__(self, log_filepath=None, max_lines=5_000_000, level='info', name=None, log_to_file=True):
6
+ def __init__(self, log_filepath=None, max_lines=100_000, level='info', name=None, log_to_file=True):
7
7
  filename = Path(sys.argv[0]).stem
8
8
  self.filename = filename
9
9
  if not log_filepath:
10
10
  log_filepath = f'{os.getcwd()}/{filename}.txt'
11
11
  self.log_filepath = log_filepath
12
+ backup_log_filepath = log_filepath.replace('.txt', '_2.txt')
12
13
  self.max_lines = max_lines
13
14
  self.log_to_file = log_to_file
14
15
 
@@ -71,6 +72,7 @@ class logger:
71
72
  if number_of_lines > self.max_lines:
72
73
  self.logger.info('Resetting log file')
73
74
  self.log_file.close()
75
+ os.rename(self.log_filepath, backup_log_filepath)
74
76
  log_file = logging.FileHandler(self.log_filepath, mode='w', encoding='utf-8')
75
77
  log_format = logging.Formatter(fmt=self.indent + '%(levelname)s - %(asctime)s.%(msecs)03d - Line %(lineno)s: %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
76
78
  log_file.setFormatter(log_format)
@@ -92,10 +94,10 @@ class logger:
92
94
  def warning(self, *items):
93
95
  self.log(*items, level='warning')
94
96
 
95
- def current_time(self, *items, level='info'):
97
+ def current_time(self, *items, level='info', beautify=True):
96
98
  current_time = datetime.now()
97
99
  current_time = current_time.strftime('%H:%M:%S:%f') + ':'
98
- self.log(current_time, *items, level=level)
100
+ self.log(current_time, *items, level=level, beautify=beautify)
99
101
 
100
102
  def set_indent(self, indent=' - '):
101
103
  if self.log_to_file:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-printr
3
- Version: 3.5
3
+ Version: 3.7
4
4
  Summary: printr
5
5
  Home-page: https://github.com/xjxckk/python-printr/
6
6
  Download-URL: https://github.com/xjxckk/python-printr/archive/refs/tags/v0.1.tar.gz
@@ -3,7 +3,7 @@ from setuptools import setup
3
3
  setup(
4
4
  name = 'python-printr',
5
5
  packages = ['printr'],
6
- version = '3.5',
6
+ version = '3.7',
7
7
  install_requires=['coloredlogs'],
8
8
  description = 'printr',
9
9
  url = 'https://github.com/xjxckk/python-printr/',
File without changes
File without changes
File without changes