dvlogger 2.0.4__tar.gz → 2.0.5__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.4
2
2
  Name: dvlogger
3
- Version: 2.0.4
3
+ Version: 2.0.5
4
4
  Summary: A custom logger with coloured output and uncaught exception logging. Supports threading and asyncio.
5
5
  Author-email: Pranav Mittal <pranavmittal611@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/mlpranav/dvlogger
@@ -1,4 +1,4 @@
1
- # dvlogger (v2.0.4)
1
+ # dvlogger (v2.0.5)
2
2
 
3
3
  ## Requirements
4
4
 
@@ -17,10 +17,10 @@
17
17
  import logging
18
18
  import dvlogger
19
19
 
20
- dvlogger.setup(level=logging.DEBUG, capture_warnings=True, exception_hook=True, use_tg_handler=False, use_file_handler=False, file_config=None, tg_config=None, log_prefix=None)
20
+ dvlogger.setup(level=logging.DEBUG, capture_warnings=True, exception_hook=True, use_tg_handler=False, use_file_handler=False, file_config=None, tg_config=None, log_prefix="Prod-Shard-G6")
21
21
 
22
22
  dvlogger.tg_send_file(FILE_PATH, 'file_name')
23
- dvlogger.tg_send_file(FILE_OBJECT, 'file_name', 'caption', is_error=True, log_prefix="Prod-Shard-G6")
23
+ dvlogger.tg_send_file(FILE_OBJECT, 'file_name', 'caption', is_error=True)
24
24
  ```
25
25
 
26
26
  ```
@@ -98,7 +98,7 @@ class CustomFormatter(logging.Formatter):
98
98
  return self.FORMATS[record.levelno].format(record)
99
99
 
100
100
  class TGHandler(logging.Handler):
101
- def setup(self, level, level_bypass_prefix, message_skip_prefix, bot_key, chat_id, thread_id, error_chat_id, error_thread_id, flush_interval):
101
+ def setup(self, level, level_bypass_prefix, message_skip_prefix, bot_key, chat_id, thread_id, error_chat_id, error_thread_id, flush_interval, log_prefix):
102
102
  self.level_filter = level
103
103
  self.level_bypass_prefix = level_bypass_prefix
104
104
  self.message_skip_prefix = message_skip_prefix
@@ -108,6 +108,7 @@ class TGHandler(logging.Handler):
108
108
  self.error_chat_id = error_chat_id
109
109
  self.error_thread_id = error_thread_id
110
110
  self.flush_interval = flush_interval / 1000.0
111
+ self.log_prefix = log_prefix
111
112
 
112
113
  for attr in ('chat_id', 'thread_id', 'error_chat_id', 'error_thread_id'):
113
114
  val = getattr(self, attr)
@@ -166,8 +167,8 @@ class TGHandler(logging.Handler):
166
167
  data = f'--{boundary}\r\nContent-Disposition: form-data; name="chat_id"\r\n\r\n{chat_id}\r\n'
167
168
  if thread_id is not None:
168
169
  data += f'--{boundary}\r\nContent-Disposition: form-data; name="message_thread_id"\r\n\r\n{thread_id}\r\n'
169
- if caption:
170
- data += f'--{boundary}\r\nContent-Disposition: form-data; name="caption"\r\n\r\n{caption}\r\n'
170
+ if caption or self.log_prefix:
171
+ data += f'--{boundary}\r\nContent-Disposition: form-data; name="caption"\r\n\r\n{self.log_prefix + " - " if self.log_prefix else ""}{caption}\r\n'
171
172
  data += (
172
173
  f'--{boundary}\r\n'
173
174
  f'Content-Disposition: form-data; name="document"; filename="{filename}"\r\n'
@@ -190,6 +191,8 @@ class TGHandler(logging.Handler):
190
191
  if is_error and self.error_chat_id is not None:
191
192
  chat_id = self.error_chat_id
192
193
  thread_id = self.error_thread_id
194
+ if caption is None:
195
+ caption = ''
193
196
 
194
197
  if isinstance(file, str):
195
198
  with open(file, 'rb') as f:
@@ -408,6 +411,7 @@ def setup(level=logging.DEBUG, capture_warnings=True, exception_hook=True, use_t
408
411
  tg_config.get('error_chat_id', None),
409
412
  tg_config.get('error_thread_id', None),
410
413
  tg_config.get('flush_interval', 5000),
414
+ log_prefix,
411
415
  )
412
416
  TG_HANDLER.setLevel(logging.DEBUG)
413
417
  TG_HANDLER.setFormatter(formatter)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dvlogger
3
- Version: 2.0.4
3
+ Version: 2.0.5
4
4
  Summary: A custom logger with coloured output and uncaught exception logging. Supports threading and asyncio.
5
5
  Author-email: Pranav Mittal <pranavmittal611@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/mlpranav/dvlogger
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "dvlogger"
7
- version = "2.0.4"
7
+ version = "2.0.5"
8
8
  description = "A custom logger with coloured output and uncaught exception logging. Supports threading and asyncio."
9
9
  authors = [
10
10
  {name = "Pranav Mittal", email = "pranavmittal611@gmail.com"},
File without changes
File without changes