Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx-platform
Commits
7ffa71d4
Commit
7ffa71d4
authored
Mar 24, 2012
by
David Ormsbee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move logging config to separate file
parent
942bfd23
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
95 additions
and
90 deletions
+95
-90
settings2/common.py
+3
-90
settings2/dev.py
+5
-0
settings2/logsettings.py
+87
-0
No files found.
settings2/common.py
View file @
7ffa71d4
...
...
@@ -22,15 +22,14 @@ Longer TODO:
3. We need to handle configuration for multiple courses. This could be as
multiple sites, but we do need a way to map their data assets.
"""
import
os
import
platform
import
sys
import
tempfile
import
djcelery
from
path
import
path
from
askbotsettings
import
LIVESETTINGS_OPTIONS
from
askbotsettings
import
*
# this is where LIVESETTINGS_OPTIONS comes from
import
logsettings
################################### FEATURES ###################################
COURSEWARE_ENABLED
=
True
...
...
@@ -126,6 +125,7 @@ SITE_NAME = "localhost:8000"
CSRF_COOKIE_DOMAIN
=
'127.0.0.1'
HTTPS
=
'on'
ROOT_URLCONF
=
'mitx.urls'
IGNORABLE_404_ENDS
=
(
'favicon.ico'
)
# Email
EMAIL_BACKEND
=
'django.core.mail.backends.console.EmailBackend'
...
...
@@ -161,93 +161,6 @@ LANGUAGE_CODE = 'en' # http://www.i18nguy.com/unicode/language-identifiers.html
USE_I18N
=
True
USE_L10N
=
True
################################### LOGGING ####################################
# Might want to rewrite this to use logger code and push more things to the root
# logger.
pid
=
os
.
getpid
()
# So we can log which process is creating the log
hostname
=
platform
.
node
()
.
split
(
"."
)[
0
]
LOG_DIR
=
"/tmp"
SYSLOG_ADDRESS
=
(
'syslog.m.i4x.org'
,
514
)
TRACKING_LOG_FILE
=
LOG_DIR
+
"/tracking_{0}.log"
.
format
(
pid
)
handlers
=
[
'console'
]
# FIXME: re-enable syslogger later
# if not DEBUG:
# handlers.append('syslogger')
LOGGING_ENV
=
"dev"
# override this in different environments
LOGGING
=
{
'version'
:
1
,
'disable_existing_loggers'
:
True
,
'formatters'
:
{
'standard'
:
{
'format'
:
'
%(asctime)
s
%(levelname)
s
%(process)
d [
%(name)
s]
%(filename)
s:
%(lineno)
d -
%(message)
s'
,
},
'syslog_format'
:
{
'format'
:
'[
%(name)
s][env:'
+
LOGGING_ENV
+
']
%(levelname)
s ['
+
\
hostname
+
'
%(process)
d] [
%(filename)
s:
%(lineno)
d] -
%(message)
s'
,
},
'raw'
:
{
'format'
:
'
%(message)
s'
,
}
},
'handlers'
:
{
'console'
:
{
'level'
:
'DEBUG'
if
DEBUG
else
'INFO'
,
'class'
:
'logging.StreamHandler'
,
'formatter'
:
'standard'
,
'stream'
:
sys
.
stdout
,
},
'console_err'
:
{
'level'
:
'ERROR'
,
'class'
:
'logging.StreamHandler'
,
'formatter'
:
'standard'
,
'stream'
:
sys
.
stderr
,
},
'syslogger'
:
{
'level'
:
'INFO'
,
'class'
:
'logging.handlers.SysLogHandler'
,
'address'
:
SYSLOG_ADDRESS
,
'formatter'
:
'syslog_format'
,
},
'tracking'
:
{
'level'
:
'DEBUG'
,
'class'
:
'logging.handlers.WatchedFileHandler'
,
'filename'
:
TRACKING_LOG_FILE
,
'formatter'
:
'raw'
,
},
'mail_admins'
:
{
'level'
:
'ERROR'
,
'class'
:
'django.utils.log.AdminEmailHandler'
,
},
},
'loggers'
:
{
'django'
:
{
'handlers'
:
handlers
+
[
'mail_admins'
],
'propagate'
:
True
,
'level'
:
'INFO'
},
'tracking'
:
{
'handlers'
:
[
'tracking'
],
'level'
:
'DEBUG'
,
'propagate'
:
False
,
},
'root'
:
{
'handlers'
:
handlers
,
'level'
:
'DEBUG'
,
'propagate'
:
False
},
'mitx'
:
{
'handlers'
:
handlers
,
'level'
:
'DEBUG'
,
'propagate'
:
False
},
}
}
#################################### AWS #######################################
# S3BotoStorage insists on a timeout for uploaded assets. We should make it
# permanent instead, but rather than trying to figure out exactly where that
...
...
settings2/dev.py
View file @
7ffa71d4
...
...
@@ -12,6 +12,11 @@ from common import *
DEBUG
=
True
TEMPLATE_DEBUG
=
True
LOGGING
=
logsettings
.
get_logger_config
(
ENV_ROOT
/
"log"
,
logging_env
=
"dev"
,
tracking_filename
=
"tracking.log"
,
debug
=
True
)
DATABASES
=
{
'default'
:
{
'ENGINE'
:
'django.db.backends.sqlite3'
,
...
...
settings2/logsettings.py
0 → 100644
View file @
7ffa71d4
import
os
import
os.path
import
platform
import
sys
def
get_logger_config
(
log_dir
,
logging_env
=
"no_env"
,
tracking_filename
=
None
,
syslog_addr
=
None
,
debug
=
False
):
"""Return the appropriate logging config dictionary. You should assign the
result of this to the LOGGING var in your settings. The reason it's done
this way instead of registering directly is because I didn't want to worry
about resetting the logging state if this is called multiple times when
settings are extended."""
# If we're given an explicit place to put tracking logs, we do that (say for
# debugging). However, logging is not safe for multiple processes hitting
# the same file. So if it's left blank, we dynamically create the filename
# based on the PID of this worker process.
if
tracking_filename
:
tracking_file_loc
=
os
.
path
.
join
(
log_dir
,
tracking_filename
)
else
:
pid
=
os
.
getpid
()
# So we can log which process is creating the log
tracking_file_loc
=
os
.
path
.
join
(
log_dir
,
"tracking_{0}.log"
.
format
(
pid
))
hostname
=
platform
.
node
()
.
split
(
"."
)[
0
]
syslog_format
=
(
"[
%(name)
s][env:{logging_env}]
%(levelname)
s [{hostname} "
+
"
%(process)
d] [
%(filename)
s:
%(lineno)
d] -
%(message)
s"
)
.
format
(
logging_env
=
logging_env
,
hostname
=
hostname
)
handlers
=
[
'console'
]
if
debug
else
[
'syslog'
]
return
{
'version'
:
1
,
'disable_existing_loggers'
:
True
,
'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
,
},
'syslogger'
:
{
'level'
:
'INFO'
,
'class'
:
'logging.handlers.SysLogHandler'
,
'address'
:
syslog_addr
,
'formatter'
:
'syslog_format'
,
},
'tracking'
:
{
'level'
:
'DEBUG'
,
'class'
:
'logging.handlers.WatchedFileHandler'
,
'filename'
:
tracking_file_loc
,
'formatter'
:
'raw'
,
},
},
'loggers'
:
{
'django'
:
{
'handlers'
:
handlers
,
'propagate'
:
True
,
'level'
:
'INFO'
},
'tracking'
:
{
'handlers'
:
[
'tracking'
],
'level'
:
'DEBUG'
,
'propagate'
:
False
,
},
'root'
:
{
'handlers'
:
handlers
,
'level'
:
'DEBUG'
,
'propagate'
:
False
},
'mitx'
:
{
'handlers'
:
handlers
,
'level'
:
'DEBUG'
,
'propagate'
:
False
},
}
}
\ No newline at end of file
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