Spaces:
Sleeping
Sleeping
Ezhil
commited on
Commit
·
fe4c053
1
Parent(s):
2e22948
few modification in looger file and dockerfile
Browse files- Dockerfile +1 -0
- logger.py +28 -4
Dockerfile
CHANGED
|
@@ -8,6 +8,7 @@ COPY . /app
|
|
| 8 |
# Ensure logs directory exists and set proper permissions
|
| 9 |
RUN mkdir -p /app/logs && chmod -R 777 /app/logs
|
| 10 |
|
|
|
|
| 11 |
# Copy the application files
|
| 12 |
|
| 13 |
|
|
|
|
| 8 |
# Ensure logs directory exists and set proper permissions
|
| 9 |
RUN mkdir -p /app/logs && chmod -R 777 /app/logs
|
| 10 |
|
| 11 |
+
|
| 12 |
# Copy the application files
|
| 13 |
|
| 14 |
|
logger.py
CHANGED
|
@@ -1,8 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import logging
|
| 2 |
import os
|
| 3 |
|
| 4 |
-
# Define
|
| 5 |
-
LOG_DIR = "
|
| 6 |
LOG_FILE = os.path.join(LOG_DIR, "backend.log")
|
| 7 |
|
| 8 |
# Ensure the logs directory exists
|
|
@@ -13,7 +38,7 @@ logging.basicConfig(
|
|
| 13 |
format="%(asctime)s - %(levelname)s - %(message)s",
|
| 14 |
level=logging.INFO,
|
| 15 |
handlers=[
|
| 16 |
-
logging.FileHandler(LOG_FILE), # Use
|
| 17 |
logging.StreamHandler() # Print logs to the console
|
| 18 |
]
|
| 19 |
)
|
|
@@ -23,5 +48,4 @@ logger = logging.getLogger(__name__)
|
|
| 23 |
if __name__ == "__main__":
|
| 24 |
logger.info("Logger is set up correctly!")
|
| 25 |
|
| 26 |
-
#
|
| 27 |
|
|
|
|
| 1 |
+
# import logging
|
| 2 |
+
# import os
|
| 3 |
+
|
| 4 |
+
# # Define absolute path for logs
|
| 5 |
+
# LOG_DIR = "/app/logs"
|
| 6 |
+
# LOG_FILE = os.path.join(LOG_DIR, "backend.log")
|
| 7 |
+
|
| 8 |
+
# # Ensure the logs directory exists
|
| 9 |
+
# os.makedirs(LOG_DIR, exist_ok=True)
|
| 10 |
+
|
| 11 |
+
# # Configure logging settings
|
| 12 |
+
# logging.basicConfig(
|
| 13 |
+
# format="%(asctime)s - %(levelname)s - %(message)s",
|
| 14 |
+
# level=logging.INFO,
|
| 15 |
+
# handlers=[
|
| 16 |
+
# logging.FileHandler(LOG_FILE), # Use absolute path
|
| 17 |
+
# logging.StreamHandler() # Print logs to the console
|
| 18 |
+
# ]
|
| 19 |
+
# )
|
| 20 |
+
|
| 21 |
+
# logger = logging.getLogger(__name__)
|
| 22 |
+
|
| 23 |
+
# if __name__ == "__main__":
|
| 24 |
+
# logger.info("Logger is set up correctly!")
|
| 25 |
+
|
| 26 |
import logging
|
| 27 |
import os
|
| 28 |
|
| 29 |
+
# Define relative path for logs
|
| 30 |
+
LOG_DIR = "logs"
|
| 31 |
LOG_FILE = os.path.join(LOG_DIR, "backend.log")
|
| 32 |
|
| 33 |
# Ensure the logs directory exists
|
|
|
|
| 38 |
format="%(asctime)s - %(levelname)s - %(message)s",
|
| 39 |
level=logging.INFO,
|
| 40 |
handlers=[
|
| 41 |
+
logging.FileHandler(LOG_FILE), # Use relative path
|
| 42 |
logging.StreamHandler() # Print logs to the console
|
| 43 |
]
|
| 44 |
)
|
|
|
|
| 48 |
if __name__ == "__main__":
|
| 49 |
logger.info("Logger is set up correctly!")
|
| 50 |
|
|
|
|
| 51 |
|