Adding a function to clean up log files
This commit is contained in:
parent
fe25701659
commit
f75d61d70b
@ -1,4 +1,4 @@
|
|||||||
from log import log
|
from log import log, cleanLogs
|
||||||
from timeOperations import isInboundShipmentPlanWithinSpecifiedDelta
|
from timeOperations import isInboundShipmentPlanWithinSpecifiedDelta
|
||||||
from amazonAPI import getAccessToken, getInboundShipmentData, getInboundShipmentPlans, getInboundShipmentPlan, getProductName
|
from amazonAPI import getAccessToken, getInboundShipmentData, getInboundShipmentPlans, getInboundShipmentPlan, getProductName
|
||||||
from sentNotifications import isInboundShipmentPlanIDInSentNotifications, updateSentNotifications
|
from sentNotifications import isInboundShipmentPlanIDInSentNotifications, updateSentNotifications
|
||||||
@ -42,4 +42,5 @@ def parseInboundShipmentPlans():
|
|||||||
updateSentNotifications(inboundShipmentPlanID)
|
updateSentNotifications(inboundShipmentPlanID)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
cleanLogs()
|
||||||
parseInboundShipmentPlans()
|
parseInboundShipmentPlans()
|
9
log.py
9
log.py
@ -1,4 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
def log(log_message, level):
|
def log(log_message, level):
|
||||||
@ -23,4 +25,9 @@ def log(log_message, level):
|
|||||||
|
|
||||||
logger.addHandler(file_handler)
|
logger.addHandler(file_handler)
|
||||||
|
|
||||||
log_message_types[level](log_message)
|
log_message_types[level](log_message)
|
||||||
|
|
||||||
|
def cleanLogs():
|
||||||
|
for filename in sorted(os.listdir('logs/'))[:-5]:
|
||||||
|
filenameWithPath = os.path.join('logs/', filename)
|
||||||
|
os.remove(filenameWithPath)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user