Skip to content

Commit 0a37667

Browse files
authored
Merge pull request #34 from aarranz/feature/support-logging
Support logging
2 parents 8b6fcdf + 4bcda10 commit 0a37667

9 files changed

Lines changed: 98 additions & 6 deletions

File tree

1.2/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ ENV DEFAULT_THEME=wirecloud.defaulttheme
66
ENV FORWARDED_ALLOW_IPS=*
77
ENV DB_HOST=
88
ENV DB_PORT=5432
9+
ENV LOGLEVEL=info
910

1011
RUN apt-get update && \
1112
apt-get install -y libmemcached-dev gosu && \

1.2/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ services:
4646
- memcached
4747
environment:
4848
- DEBUG=False
49+
- LOGLEVEL=INFO
4950
# - DEFAULT_THEME=wirecloud.defaulttheme
5051
- DB_HOST=postgres
5152
- DB_PASSWORD=wirepass # Change this password!

1.2/docker-entrypoint.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,19 @@ case "$1" in
2727

2828
# allow the container to be started with `--user`
2929
if [ "$(id -u)" = '0' ]; then
30-
gosu wirecloud /usr/local/bin/gunicorn wirecloud_instance.wsgi:application --forwarded-allow-ips "${FORWARDED_ALLOW_IPS}" -w 2 -b :8000
30+
exec gosu wirecloud /usr/local/bin/gunicorn wirecloud_instance.wsgi:application \
31+
--forwarded-allow-ips "${FORWARDED_ALLOW_IPS}" \
32+
--workers 2 \
33+
--bind 0.0.0.0:8000 \
34+
--log-file - \
35+
--log-level ${LOGLEVEL}
3136
else
32-
/usr/local/bin/gunicorn wirecloud_instance.wsgi:application --forwarded-allow-ips "${FORWARDED_ALLOW_IPS}" -w 2 -b :8000
37+
exec /usr/local/bin/gunicorn wirecloud_instance.wsgi:application \
38+
--forwarded-allow-ips "${FORWARDED_ALLOW_IPS}" \
39+
--workers 2 \
40+
--bind 0.0.0.0:8000 \
41+
--log-file - \
42+
--log-level ${LOGLEVEL}
3343
fi
3444
;;
3545
esac

1.2/settings.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,37 @@
193193
)
194194

195195
DATA_UPLOAD_MAX_MEMORY_SIZE = 262144000
196+
197+
LOGGING = {
198+
'version': 1,
199+
'disable_existing_loggers': False,
200+
'filters': {
201+
'require_debug_false': {
202+
'()': 'django.utils.log.RequireDebugFalse'
203+
},
204+
'skip_unreadable_posts': {
205+
'()': 'wirecloud.commons.utils.log.SkipUnreadablePosts',
206+
}
207+
},
208+
'handlers': {
209+
'console': {
210+
'level': 'INFO',
211+
'class': 'logging.StreamHandler',
212+
},
213+
'mail_admins': {
214+
'level': 'ERROR',
215+
'filters': ['require_debug_false', 'skip_unreadable_posts'],
216+
'class': 'django.utils.log.AdminEmailHandler'
217+
}
218+
},
219+
'loggers': {
220+
'': {
221+
'handlers': ['console'],
222+
},
223+
'django.request': {
224+
'handlers': ['console', 'mail_admins'],
225+
'level': 'ERROR',
226+
'propagate': False,
227+
},
228+
}
229+
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ The following environment variables are also honored for configuring your WireCl
3030

3131
- `-e DEBUG=...` (defaults to "False", use "True" for running WireCloud in debug
3232
mode. Debug mode should be enabled for running WireCloud in standalone mode)
33+
- `-e LOGLEVEL=...` (defaults to "INFO")
3334
- `-e ALLOWED_HOSTS=...` (defaults to "*", whitespace whitespace-separated list
3435
of allowed hosts. See [django documentation][ALLOWED_HOSTS] for more
3536
details)

dev/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
ARG PYTHON_VERSION=3.6-stretch
32
FROM python:${PYTHON_VERSION}
43

@@ -17,7 +16,8 @@ MAINTAINER WireCloud Team <wirecloud@conwet.com>
1716

1817
ENV DEFAULT_THEME=wirecloud.defaulttheme \
1918
FORWARDED_ALLOW_IPS=* \
20-
DB_PORT=5432
19+
DB_PORT=5432 \
20+
LOGLEVEL=info
2121

2222
RUN apt-get update && \
2323
apt-get install -y libmemcached-dev gosu && \

dev/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ services:
4646
- memcached
4747
environment:
4848
- DEBUG=False
49+
- LOGLEVEL=INFO
4950
# - DEFAULT_THEME=wirecloud.defaulttheme
5051
- DB_HOST=postgres
5152
- DB_PASSWORD=wirepass # Change this password!

dev/docker-entrypoint.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,19 @@ case "$1" in
5454

5555
# allow the container to be started with `--user`
5656
if [ "$(id -u)" = '0' ]; then
57-
gosu wirecloud /usr/local/bin/gunicorn wirecloud_instance.wsgi:application --forwarded-allow-ips "${FORWARDED_ALLOW_IPS}" -w 2 -b :8000
57+
exec gosu wirecloud /usr/local/bin/gunicorn wirecloud_instance.wsgi:application \
58+
--forwarded-allow-ips "${FORWARDED_ALLOW_IPS}" \
59+
--workers 2 \
60+
--bind 0.0.0.0:8000 \
61+
--log-file - \
62+
--log-level ${LOGLEVEL}
5863
else
59-
/usr/local/bin/gunicorn wirecloud_instance.wsgi:application --forwarded-allow-ips "${FORWARDED_ALLOW_IPS}" -w 2 -b :8000
64+
exec /usr/local/bin/gunicorn wirecloud_instance.wsgi:application \
65+
--forwarded-allow-ips "${FORWARDED_ALLOW_IPS}" \
66+
--workers 2 \
67+
--bind 0.0.0.0:8000 \
68+
--log-file - \
69+
--log-level ${LOGLEVEL}
6070
fi
6171
;;
6272
esac

dev/settings.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,37 @@
194194
)
195195

196196
DATA_UPLOAD_MAX_MEMORY_SIZE = 262144000
197+
198+
LOGGING = {
199+
'version': 1,
200+
'disable_existing_loggers': False,
201+
'filters': {
202+
'require_debug_false': {
203+
'()': 'django.utils.log.RequireDebugFalse'
204+
},
205+
'skip_unreadable_posts': {
206+
'()': 'wirecloud.commons.utils.log.SkipUnreadablePosts',
207+
}
208+
},
209+
'handlers': {
210+
'console': {
211+
'level': 'INFO',
212+
'class': 'logging.StreamHandler',
213+
},
214+
'mail_admins': {
215+
'level': 'ERROR',
216+
'filters': ['require_debug_false', 'skip_unreadable_posts'],
217+
'class': 'django.utils.log.AdminEmailHandler'
218+
}
219+
},
220+
'loggers': {
221+
'': {
222+
'handlers': ['console'],
223+
},
224+
'django.request': {
225+
'handlers': ['console', 'mail_admins'],
226+
'level': 'ERROR',
227+
'propagate': False,
228+
},
229+
}
230+
}

0 commit comments

Comments
 (0)