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
03a9be7e
Commit
03a9be7e
authored
May 21, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add newrelic handler, rather than custom function to log exceptions
parent
4fe22be5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
17 deletions
+27
-17
djangoapps/courseware/views.py
+6
-7
envs/logsettings.py
+7
-3
lib/newrelic_logging/__init__.py
+14
-0
lib/util/errors.py
+0
-7
No files found.
djangoapps/courseware/views.py
View file @
03a9be7e
...
...
@@ -19,7 +19,6 @@ from lxml import etree
from
module_render
import
render_module
,
make_track_function
,
I4xSystem
from
models
import
StudentModule
from
student.models
import
UserProfile
from
util.errors
import
record_exception
from
util.views
import
accepts
from
multicourse
import
multicourse_settings
...
...
@@ -114,7 +113,7 @@ def render_section(request, section):
try
:
dom
=
content_parser
.
section_file
(
user
,
section
,
coursename
)
except
:
record_exception
(
log
,
"Unable to parse courseware xml"
)
log
.
exception
(
"Unable to parse courseware xml"
)
return
render_to_response
(
'courseware-error.html'
,
{})
context
=
{
...
...
@@ -133,7 +132,7 @@ def render_section(request, section):
try
:
module
=
render_module
(
user
,
request
,
dom
,
module_object_preload
)
except
:
record_exception
(
log
,
"Unable to load module"
)
log
.
exception
(
"Unable to load module"
)
context
.
update
({
'init'
:
''
,
'content'
:
render_to_string
(
"module-error.html"
,
{}),
...
...
@@ -182,7 +181,7 @@ def index(request, course=None, chapter="Using the System", section="Hints"):
try
:
dom
=
content_parser
.
course_file
(
user
,
course
)
# also pass course to it, for course-specific XML path
except
:
record_exception
(
log
,
"Unable to parse courseware xml"
)
log
.
exception
(
"Unable to parse courseware xml"
)
return
render_to_response
(
'courseware-error.html'
,
{})
dom_module
=
dom
.
xpath
(
"//course[@name=$course]/chapter[@name=$chapter]//section[@name=$section]/*[1]"
,
...
...
@@ -211,7 +210,7 @@ def index(request, course=None, chapter="Using the System", section="Hints"):
try
:
module
=
render_module
(
user
,
request
,
module
,
module_object_preload
)
except
:
record_exception
(
log
,
"Unable to load module"
)
log
.
exception
(
"Unable to load module"
)
context
.
update
({
'init'
:
''
,
'content'
:
render_to_string
(
"module-error.html"
,
{}),
...
...
@@ -256,7 +255,7 @@ def modx_dispatch(request, module=None, dispatch=None, id=None):
try
:
xml
=
content_parser
.
module_xml
(
request
.
user
,
module
,
'id'
,
id
,
coursename
)
except
:
record_exception
(
log
,
"Unable to load module during ajax call"
)
log
.
exception
(
"Unable to load module during ajax call"
)
if
accepts
(
request
,
'text/html'
):
return
render_to_response
(
"module-error.html"
,
{})
else
:
...
...
@@ -276,7 +275,7 @@ def modx_dispatch(request, module=None, dispatch=None, id=None):
id
,
state
=
oldstate
)
except
:
record_exception
(
log
,
"Unable to load module instance during ajax call"
)
log
.
exception
(
"Unable to load module instance during ajax call"
)
if
accepts
(
request
,
'text/html'
):
return
render_to_response
(
"module-error.html"
,
{})
else
:
...
...
envs/logsettings.py
View file @
03a9be7e
...
...
@@ -29,7 +29,7 @@ def get_logger_config(log_dir,
"
%(process)
d] [
%(filename)
s:
%(lineno)
d] -
%(message)
s"
)
.
format
(
logging_env
=
logging_env
,
hostname
=
hostname
)
handlers
=
[
'console'
]
if
debug
else
[
'console'
,
'syslogger'
]
handlers
=
[
'console'
]
if
debug
else
[
'console'
,
'syslogger'
,
'newrelic'
]
return
{
'version'
:
1
,
...
...
@@ -60,6 +60,11 @@ def get_logger_config(log_dir,
'filename'
:
tracking_file_loc
,
'formatter'
:
'raw'
,
},
'newrelic'
:
{
'level'
:
'ERROR'
,
'class'
:
'newrelic_logging.NewRelicHandler'
,
'formatter'
:
'raw'
,
}
},
'loggers'
:
{
'django'
:
{
...
...
@@ -83,4 +88,4 @@ def get_logger_config(log_dir,
'propagate'
:
False
},
}
}
\ No newline at end of file
}
lib/newrelic_logging/__init__.py
0 → 100644
View file @
03a9be7e
import
newrelic.agent
import
logging
class
NewRelicHandler
(
logging
.
Handler
):
def
emit
(
self
,
record
):
if
record
.
exc_info
is
not
None
:
params
=
record
.
__dict__
params
[
'log_message'
]
=
record
.
getMessage
()
newrelic
.
agent
.
record_exception
(
*
record
.
exc_info
,
params
=
params
)
lib/util/errors.py
deleted
100644 → 0
View file @
4fe22be5
import
newrelic.agent
import
sys
def
record_exception
(
logger
,
msg
,
params
=
{},
ignore_errors
=
[]):
logger
.
exception
(
msg
)
newrelic
.
agent
.
record_exception
(
*
sys
.
exc_info
())
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