fix: rotate wecker.log to prevent unbounded growth
This commit is contained in:
@@ -6,14 +6,18 @@ import random
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import fcntl
|
import fcntl
|
||||||
|
from logging.handlers import RotatingFileHandler
|
||||||
|
|
||||||
from common import PID_FILE
|
from common import PID_FILE
|
||||||
|
|
||||||
# Configure logging
|
# Configure logging with rotation to avoid unbounded growth on the SD card.
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
level=logging.INFO,
|
level=logging.INFO,
|
||||||
format="%(asctime)s - %(message)s",
|
format="%(asctime)s - %(message)s",
|
||||||
handlers=[logging.FileHandler("wecker.log"), logging.StreamHandler()],
|
handlers=[
|
||||||
|
RotatingFileHandler("wecker.log", maxBytes=1_000_000, backupCount=3),
|
||||||
|
logging.StreamHandler(),
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user