Skip to content

Commit f3fea9c

Browse files
committed
removing resilient sink due to numerous issues. Considering other library as replacement.
1 parent f9175ac commit f3fea9c

File tree

1 file changed

+0
-36
lines changed

1 file changed

+0
-36
lines changed

dsg_lib/common_functions/logging_config.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
License: MIT
3232
"""
3333
import logging
34-
import os
35-
import time
3634
from pathlib import Path
3735
from uuid import uuid4
3836

@@ -215,43 +213,9 @@ def emit(self, record):
215213
logging.getLogger().setLevel(logging.NOTSET)
216214

217215

218-
class ResilientFileSink:
219-
def __init__(self, path, retry_count=5, retry_delay=1):
220-
self.path = path
221-
self.retry_count = retry_count
222-
self.retry_delay = retry_delay
223-
# Ensure the directory exists
224-
os.makedirs(os.path.dirname(path), exist_ok=True)
225-
226-
def __call__(self, message): # pragma: no cover
227-
attempt = 0
228-
while attempt < self.retry_count:
229-
try:
230-
# Open the file in append mode and write the message
231-
with open(self.path, 'a') as file:
232-
file.write(message)
233-
break # Exit the loop if write succeeds
234-
except Exception as e:
235-
attempt += 1
236-
time.sleep(self.retry_delay)
237-
if attempt == self.retry_count:
238-
print(f"Failed to log message after {self.retry_count} attempts: {e}")
239-
240-
241-
if file_sink:
242-
# Create an instance of ResilientFileSink if file_sink is True
243-
resilient_sink = ResilientFileSink(str(log_path))
244-
245-
# Append the ResilientFileSink instance to the handlers list
246-
basic_config_handlers.append(resilient_sink)
247-
248216
if intercept_standard_logging:
249217
# Append an InterceptHandler instance to the handlers list if intercept_standard_logging is True
250218
basic_config_handlers.append(InterceptHandler())
251219

252-
if len(basic_config_handlers) > 0:
253-
# Configure the root logger if there are any handlers specified
254-
logging.basicConfig(handlers=basic_config_handlers, level=logging_level.upper())
255-
256220
if len(basic_config_handlers) > 0:
257221
logging.basicConfig(handlers=basic_config_handlers, level=logging_level.upper())

0 commit comments

Comments
 (0)