Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
cf210ea1
Commit
cf210ea1
authored
13 years ago
by
David Ormsbee
Browse files
Options
Downloads
Patches
Plain Diff
switch tracking to use logger
parent
fd79da9a
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
track/middleware.py
+5
-1
5 additions, 1 deletion
track/middleware.py
track/views.py
+6
-36
6 additions, 36 deletions
track/views.py
with
11 additions
and
37 deletions
track/middleware.py
+
5
−
1
View file @
cf210ea1
import
views
,
json
import
json
from
django.conf
import
settings
import
views
class
TrackMiddleware
:
def
process_request
(
self
,
request
):
...
...
This diff is collapsed.
Click to expand it.
track/views.py
+
6
−
36
View file @
cf210ea1
import
json
import
logging
import
os
# Create your views here.
from
django.http
import
HttpResponse
from
django.http
import
Http404
from
django.conf
import
settings
import
json
,
os
,
stat
import
tempfile
if
settings
.
TRACK_DIR
!=
None
:
directory
=
tempfile
.
mkdtemp
(
prefix
=
settings
.
TRACK_DIR
)
else
:
directory
=
None
logfile
=
None
file_index
=
0
log_index
=
0
filename
=
None
def
make_file
():
global
logfile
,
log_index
,
file_index
,
filename
if
logfile
!=
None
:
logfile
.
close
()
os
.
chmod
(
filename
,
stat
.
S_IRUSR
|
stat
.
S_IWUSR
|
\
stat
.
S_IRGRP
|
stat
.
S_IWGRP
|
\
stat
.
S_IROTH
)
filename
=
directory
+
"
/%05i
"
%
(
file_index
)
+
"
.trklog
"
logfile
=
open
(
filename
,
"
w
"
)
file_index
=
file_index
+
1
log_index
=
0
log
=
logging
.
getLogger
(
"
tracking
"
)
def
log_event
(
event
):
global
logfile
,
log_index
event_str
=
json
.
dumps
(
event
)
if
settings
.
TRACK_DIR
==
None
:
# print event
return
if
logfile
==
None
or
log_index
>=
settings
.
MAXLOG
:
make_file
()
logfile
.
write
(
event_str
[:
settings
.
TRACK_MAX_EVENT
]
+
'
\n
'
)
if
settings
.
DEBUG_TRACK_LOG
:
print
event_str
log_index
=
log_index
+
1
log
.
info
(
event_str
[:
settings
.
TRACK_MAX_EVENT
])
def
user_track
(
request
):
try
:
# TODO: Do the same for many of the optional META parameters
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment