File tree Expand file tree Collapse file tree 7 files changed +52
-4
lines changed Expand file tree Collapse file tree 7 files changed +52
-4
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ DB_PORT=5432
5
5
DB_NAME = term_db
6
6
DB_USER = sadilar
7
7
DB_PASSWORD = sadilar
8
- LOGGING_FILE = logs/ debug.log
8
+ LOGGING_FILE = debug.log
9
9
LOGGING_HANDLERS_LEVEL = INFO
10
10
LOGGING_LOGGERS_LEVEL = INFO
11
11
LOGGING_LOGGERS_DJANGO_LEVEL = INFO
Original file line number Diff line number Diff line change @@ -16,8 +16,7 @@ db.sqlite3
16
16
db.sqlite3-journal
17
17
media
18
18
19
- # macOS template
20
- # General
19
+ # General Files
21
20
.DS_Store
22
21
.AppleDouble
23
22
.LSOverride
30
29
ENV /
31
30
env.bak /
32
31
venv.bak /
32
+
33
+ # folders
33
34
app /static_files /
34
35
/app /documents /
35
36
app /media /
36
37
/app /logging /
38
+ /logging /
Original file line number Diff line number Diff line change @@ -112,3 +112,7 @@ dev-quick-install:
112
112
@make load-fixtures
113
113
echo " Creating superuser"
114
114
@make create-super-user
115
+
116
+ shell :
117
+ clear
118
+ docker exec -it sadilar-terminology-web bash
Original file line number Diff line number Diff line change @@ -37,3 +37,11 @@ https://django-simple-history.readthedocs.io/en/latest/
37
37
### environment variables
38
38
39
39
please use .env.example as example
40
+
41
+
42
+ ## Production
43
+
44
+ Docker Volumes for production:
45
+
46
+ /media
47
+ /logs
Original file line number Diff line number Diff line change 164
164
165
165
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
166
166
167
+ LOGGING_FOLDER_DEFAULT = os .path .abspath (os .path .join ("/logging/" ))
168
+
169
+ # Check if the application is under testing
170
+ if "test" in sys .argv :
171
+ DEBUG = False
172
+ else :
173
+ DEBUG = True
167
174
168
175
if DEBUG :
169
176
LOGGING = {
190
197
"file" : {
191
198
"level" : os .environ .get ("LOGGING_HANDLERS_LEVEL" , "WARNING" ),
192
199
"class" : "logging.FileHandler" ,
193
- "filename" : os .environ .get ("LOGGING_FILE" , "logging/debug.log" ),
200
+ "filename" : os .path .join (
201
+ LOGGING_FOLDER_DEFAULT , os .environ .get ("LOGGING_FILE" , "debug.log" )
202
+ ),
194
203
"formatter" : "verbose" ,
195
204
},
196
205
},
Original file line number Diff line number Diff line change
1
+ import logging
2
+ import os
3
+ import sys
4
+
5
+ from django .test import TestCase
6
+
7
+
8
+ class LoggingTest (TestCase ):
9
+ def setUp (self ):
10
+ LOGGING_FOLDER_DEFAULT = os .path .abspath (os .path .join ("/logging/" ))
11
+ self .logger = logging .getLogger ("django" )
12
+ self .log_file = os .path .join (LOGGING_FOLDER_DEFAULT , "debug.log" )
13
+
14
+ def test_log_file_created (self ):
15
+ """Test if the log file is created."""
16
+ self .logger .error ("This is a test error message." )
17
+
18
+ self .assertTrue (os .path .exists (self .log_file ))
19
+
20
+ def test_log_message (self ):
21
+ """Test if the log message is written to the file."""
22
+ with open (self .log_file , "r" ) as f :
23
+ content = f .read ()
24
+ self .assertIn ("This is a test error message." , content )
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ services:
22
22
command : python manage.py runserver 0.0.0.0:8000
23
23
volumes :
24
24
- ./app:/app
25
+ - ./logging:/logging
25
26
ports :
26
27
- " 8000:8000"
27
28
depends_on :
You can’t perform that action at this time.
0 commit comments