Ezhil commited on
Commit
35b0731
·
1 Parent(s): 7dfc74f

Motified changes

Browse files
Files changed (2) hide show
  1. Dockerfile +2 -0
  2. logger.py +25 -11
Dockerfile CHANGED
@@ -4,6 +4,8 @@ FROM python:3.11
4
  # Set the working directory in the container
5
  WORKDIR /app
6
 
 
 
7
 
8
  # Copy the application files
9
  COPY . .
 
4
  # Set the working directory in the container
5
  WORKDIR /app
6
 
7
+ # Ensure logs directory exists and set proper permissions
8
+ RUN mkdir -p /app/logs && chmod -R 777 /app/logs
9
 
10
  # Copy the application files
11
  COPY . .
logger.py CHANGED
@@ -1,19 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import logging
2
  import os
3
 
4
- # Create logs directory if it doesn't exist
5
- if not os.path.exists("logs"):
6
- os.makedirs("logs")
7
 
8
  # Configure logging
9
  logging.basicConfig(
 
10
  level=logging.INFO,
11
- format="%(asctime)s - %(levelname)s - %(message)s",
12
- handlers=[
13
- logging.FileHandler("logs/app.log"), # Log to file
14
- logging.StreamHandler() # Log to console
15
- ],
16
  )
17
-
18
- # Get logger instance
19
- logger = logging.getLogger("world_population")
 
1
+ # import logging
2
+ # import os
3
+
4
+ # # Create logs directory if it doesn't exist
5
+ # if not os.path.exists("logs"):
6
+ # os.makedirs("logs")
7
+
8
+ # # Configure logging
9
+ # logging.basicConfig(
10
+ # level=logging.INFO,
11
+ # format="%(asctime)s - %(levelname)s - %(message)s",
12
+ # handlers=[
13
+ # logging.FileHandler("logs/app.log"), # Log to file
14
+ # logging.StreamHandler() # Log to console
15
+ # ],
16
+ # )
17
+
18
+ # # Get logger instance
19
+ # logger = logging.getLogger("world_population")
20
+
21
+
22
  import logging
23
  import os
24
 
25
+ # Ensure the logs directory exists
26
+ os.makedirs("/app/logs", exist_ok=True)
 
27
 
28
  # Configure logging
29
  logging.basicConfig(
30
+ filename="/app/logs/app.log", # Ensure the path is correct
31
  level=logging.INFO,
32
+ format="%(asctime)s - %(levelname)s - %(message)s"
 
 
 
 
33
  )