Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
yinjiaqi authored and yinjiaqi committed Jan 2, 2025
1 parent 497e282 commit 7bed55e
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions python/tests/test_log_set_log_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,25 @@ def test_set_log_config_raise_error(self):
)

def test_rolling_with_time(self):
logger = logging.getLogger('CustomLogger')
logger.setLevel(logging.DEBUG)
handler = SizeAndTimeRotatingFileHandler(
filename ='test.log',
when='S',
interval=1,
max_bytes=1024*100*1024,
backup_count=10,
total_size_limit=1024*300*1024
)
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
time_msgs = ['S', 'M', 'H', 'D', 'MIDNIGHT']
for time_msg in time_msgs:
logger = logging.getLogger('CustomLogger')
logger.setLevel(logging.DEBUG)
handler = SizeAndTimeRotatingFileHandler(
filename ='test.log',
when=time_msg,
interval=1,
max_bytes=1024*100*1024,
backup_count=10,
total_size_limit=1024*300*1024
)
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)

for i in range(3):
logger.info("This is a test log message.")
time.sleep(1)
for _ in range(2):
logger.info("This is a test log message.")
time.sleep(0.1)

def test_rolling_with_size(self):
logger = logging.getLogger('CustomLogger')
Expand Down

0 comments on commit 7bed55e

Please sign in to comment.