Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
course-discovery
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
course-discovery
Commits
f647a04d
Commit
f647a04d
authored
Nov 18, 2015
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move from using the get_logger_config to allowing the LOGGING variable to be configured by ansible
parent
b14fb546
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
119 deletions
+49
-119
edx_course_discovery/settings/base.py
+47
-0
edx_course_discovery/settings/local.py
+0
-3
edx_course_discovery/settings/production.py
+2
-2
edx_course_discovery/settings/test.py
+0
-2
edx_course_discovery/settings/utils.py
+0
-112
No files found.
edx_course_discovery/settings/base.py
View file @
f647a04d
...
...
@@ -175,3 +175,50 @@ LOGIN_REDIRECT_URL = '/admin/'
# OPENEDX-SPECIFIC CONFIGURATION
PLATFORM_NAME
=
'Your Platform Name Here'
# END OPENEDX-SPECIFIC CONFIGURATION
# Set up logging for development use (logging to stdout)
LOGGING
=
{
'version'
:
1
,
'disable_existing_loggers'
:
False
,
'formatters'
:
{
'standard'
:
{
'format'
:
'
%(asctime)
s
%(levelname)
s
%(process)
d '
'[
%(name)
s]
%(filename)
s:
%(lineno)
d -
%(message)
s'
,
},
},
'handlers'
:
{
'console'
:
{
'level'
:
'INFO'
,
'class'
:
'logging.StreamHandler'
,
'formatter'
:
'standard'
,
'stream'
:
'ext://sys.stdout'
,
},
},
'loggers'
:
{
'django'
:
{
'handlers'
:
[
'console'
],
'propagate'
:
True
,
'level'
:
'INFO'
},
'requests'
:
{
'handlers'
:
[
'console'
],
'propagate'
:
True
,
'level'
:
'WARNING'
},
'factory'
:
{
'handlers'
:
[
'console'
],
'propagate'
:
True
,
'level'
:
'WARNING'
},
'django.request'
:
{
'handlers'
:
[
'console'
],
'propagate'
:
True
,
'level'
:
'WARNING'
},
''
:
{
'handlers'
:
[
'console'
],
'level'
:
'DEBUG'
,
'propagate'
:
False
},
}
}
edx_course_discovery/settings/local.py
View file @
f647a04d
from
edx_course_discovery.settings.base
import
*
from
edx_course_discovery.settings.utils
import
get_logger_config
DEBUG
=
True
...
...
@@ -56,8 +55,6 @@ SOCIAL_AUTH_EDX_OIDC_ID_TOKEN_DECRYPTION_KEY = SOCIAL_AUTH_EDX_OIDC_SECRET
ENABLE_AUTO_AUTH
=
True
LOGGING
=
get_logger_config
(
debug
=
DEBUG
,
dev_env
=
True
,
local_loglevel
=
'DEBUG'
)
#####################################################################
# Lastly, see if the developer has any local overrides.
if
os
.
path
.
isfile
(
join
(
dirname
(
abspath
(
__file__
)),
'private.py'
)):
...
...
edx_course_discovery/settings/production.py
View file @
f647a04d
...
...
@@ -2,7 +2,7 @@ from os import environ
import
yaml
from
edx_course_discovery.settings.base
import
*
from
edx_course_discovery.settings.utils
import
get_env_setting
,
get_logger_config
from
edx_course_discovery.settings.utils
import
get_env_setting
DEBUG
=
False
...
...
@@ -10,7 +10,7 @@ TEMPLATE_DEBUG = DEBUG
ALLOWED_HOSTS
=
[
'*'
]
LOGGING
=
get_logger_config
(
)
LOGGING
=
environ
.
get
(
'LOGGING'
,
LOGGING
)
CONFIG_FILE
=
get_env_setting
(
'EDX_COURSE_DISCOVERY_CFG'
)
with
open
(
CONFIG_FILE
)
as
f
:
...
...
edx_course_discovery/settings/test.py
View file @
f647a04d
import
os
from
edx_course_discovery.settings.base
import
*
from
edx_course_discovery.settings.utils
import
get_logger_config
# TEST SETTINGS
...
...
@@ -16,7 +15,6 @@ NOSE_ARGS = [
'--logging-level=DEBUG'
,
]
LOGGING
=
get_logger_config
(
debug
=
False
,
dev_env
=
True
,
local_loglevel
=
'DEBUG'
)
# END TEST SETTINGS
...
...
edx_course_discovery/settings/utils.py
View file @
f647a04d
from
os
import
environ
,
path
import
platform
import
sys
from
logging.handlers
import
SysLogHandler
...
...
@@ -14,114 +13,3 @@ def get_env_setting(setting):
error_msg
=
"Set the [
%
s] env variable!"
%
setting
raise
ImproperlyConfigured
(
error_msg
)
def
get_logger_config
(
log_dir
=
'/var/tmp'
,
logging_env
=
"no_env"
,
edx_filename
=
"edx.log"
,
dev_env
=
False
,
debug
=
False
,
local_loglevel
=
'INFO'
,
service_variant
=
'edx_course_discovery'
):
"""
Return the appropriate logging config dictionary. You should assign the
result of this to the LOGGING var in your settings.
If dev_env is set to true logging will not be done via local rsyslogd,
instead, application logs will be dropped in log_dir.
"edx_filename" is ignored unless dev_env is set to true since otherwise logging is handled by rsyslogd.
"""
# Revert to INFO if an invalid string is passed in
if
local_loglevel
not
in
[
'DEBUG'
,
'INFO'
,
'WARNING'
,
'ERROR'
,
'CRITICAL'
]:
local_loglevel
=
'INFO'
hostname
=
platform
.
node
()
.
split
(
"."
)[
0
]
syslog_format
=
(
"[service_variant={service_variant}]"
"[
%(name)
s][env:{logging_env}]
%(levelname)
s "
"[{hostname}
%(process)
d] [
%(filename)
s:
%(lineno)
d] "
"-
%(message)
s"
)
.
format
(
service_variant
=
service_variant
,
logging_env
=
logging_env
,
hostname
=
hostname
)
if
debug
:
handlers
=
[
'console'
]
else
:
handlers
=
[
'local'
]
logger_config
=
{
'version'
:
1
,
'disable_existing_loggers'
:
False
,
'formatters'
:
{
'standard'
:
{
'format'
:
'
%(asctime)
s
%(levelname)
s
%(process)
d '
'[
%(name)
s]
%(filename)
s:
%(lineno)
d -
%(message)
s'
,
},
'syslog_format'
:
{
'format'
:
syslog_format
},
'raw'
:
{
'format'
:
'
%(message)
s'
},
},
'handlers'
:
{
'console'
:
{
'level'
:
'DEBUG'
if
debug
else
'INFO'
,
'class'
:
'logging.StreamHandler'
,
'formatter'
:
'standard'
,
'stream'
:
sys
.
stdout
,
},
},
'loggers'
:
{
'django'
:
{
'handlers'
:
handlers
,
'propagate'
:
True
,
'level'
:
'INFO'
},
'requests'
:
{
'handlers'
:
handlers
,
'propagate'
:
True
,
'level'
:
'WARNING'
},
'factory'
:
{
'handlers'
:
handlers
,
'propagate'
:
True
,
'level'
:
'WARNING'
},
'django.request'
:
{
'handlers'
:
handlers
,
'propagate'
:
True
,
'level'
:
'WARNING'
},
''
:
{
'handlers'
:
handlers
,
'level'
:
'DEBUG'
,
'propagate'
:
False
},
}
}
if
dev_env
:
edx_file_loc
=
path
.
join
(
log_dir
,
edx_filename
)
logger_config
[
'handlers'
]
.
update
({
'local'
:
{
'class'
:
'logging.handlers.RotatingFileHandler'
,
'level'
:
local_loglevel
,
'formatter'
:
'standard'
,
'filename'
:
edx_file_loc
,
'maxBytes'
:
1024
*
1024
*
2
,
'backupCount'
:
5
,
},
})
else
:
logger_config
[
'handlers'
]
.
update
({
'local'
:
{
'level'
:
local_loglevel
,
'class'
:
'logging.handlers.SysLogHandler'
,
# Use a different address for Mac OS X
'address'
:
'/var/run/syslog'
if
sys
.
platform
==
"darwin"
else
'/dev/log'
,
'formatter'
:
'syslog_format'
,
'facility'
:
SysLogHandler
.
LOG_LOCAL0
,
},
})
return
logger_config
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment