Spaces:
Running
Running
taslim19
commited on
Commit
·
359b1eb
1
Parent(s):
393f601
fix: Re-enable file logging to /tmp directory
Browse files- DragMusic/logging.py +11 -0
DragMusic/logging.py
CHANGED
@@ -1,10 +1,21 @@
|
|
1 |
import logging
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
logging.basicConfig(
|
4 |
level=logging.INFO,
|
5 |
format="[%(asctime)s - %(levelname)s] - %(name)s - %(message)s",
|
6 |
datefmt="%d-%b-%y %H:%M:%S",
|
7 |
handlers=[
|
|
|
|
|
|
|
|
|
|
|
8 |
logging.StreamHandler(),
|
9 |
],
|
10 |
)
|
|
|
1 |
import logging
|
2 |
+
import os
|
3 |
+
from logging.handlers import RotatingFileHandler
|
4 |
+
|
5 |
+
# Ensure the /tmp directory exists
|
6 |
+
if not os.path.exists("/tmp"):
|
7 |
+
os.makedirs("/tmp")
|
8 |
|
9 |
logging.basicConfig(
|
10 |
level=logging.INFO,
|
11 |
format="[%(asctime)s - %(levelname)s] - %(name)s - %(message)s",
|
12 |
datefmt="%d-%b-%y %H:%M:%S",
|
13 |
handlers=[
|
14 |
+
RotatingFileHandler(
|
15 |
+
"/tmp/logs.txt",
|
16 |
+
maxBytes=5000000,
|
17 |
+
backupCount=10,
|
18 |
+
),
|
19 |
logging.StreamHandler(),
|
20 |
],
|
21 |
)
|