add more logs

This commit is contained in:
Michael Zhang 2016-01-12 22:41:59 -06:00
parent dea6de5cf3
commit 19a475199a
3 changed files with 25 additions and 32 deletions

View file

@ -18,7 +18,7 @@ server {
default_type text/html;
try_files /index.html /index.html;
}
location ~^/admin/(problems)$ {
location ~^/admin/(problems|settings|stats|teams)$ {
default_type text/html;
try_files /index.html /index.html;
}

View file

@ -2,6 +2,9 @@ import datetime
import logging
import logging.handlers
import os
import pkgutil
import api
NOTSET = 0
DEBUG = 10
@ -11,33 +14,21 @@ ERROR = 40
CRITICAL = 50
def initialize_logs():
registration_logger = logging.getLogger("registrations")
login_logger = logging.getLogger("logins")
submission_logger = logging.getLogger("submissions")
registration_logger.setLevel(logging.INFO)
login_logger.setLevel(logging.INFO)
submission_logger.setLevel(logging.INFO)
def create_logger(name):
new_logger = logging.getLogger(name)
new_logger.setLevel(logging.INFO)
base = os.path.dirname(__file__).strip("api")
log_path = os.path.join(base, "logs")
if not os.path.exists(log_path):
os.mkdir(log_path)
# logs = [os.path.join(log_path, "registrations.log"), os.path.join(log_path, "logins.log"), os.path.join(log_path, "submissions.log")]
logs = map(lambda x: os.path.join(log_path, x + ".log"), \
[ "registrations", "logins", "submissions", "create_team" ])
log_handler = logging.handlers.RotatingFileHandler(os.path.join(log_path, name + ".log"))
new_logger.addHandler(log_handler)
for importer, modname, ispkg in pkgutil.walk_packages(path="../api"):
create_logger(modname)
registration_log = logging.handlers.RotatingFileHandler(logs[0], maxBytes=10000)
login_log = logging.handlers.RotatingFileHandler(logs[1], maxBytes=10000)
submission_log = logging.handlers.RotatingFileHandler(logs[2], maxBytes=10000)
registration_logger.addHandler(registration_log)
login_logger.addHandler(login_log)
submission_logger.addHandler(submission_log)
def log(log, level, message):
logger = logging.getLogger(log)
def log(logname, level, message):
logger = logging.getLogger(logname)
message = "[%s] %s" % (datetime.datetime.now().strftime("%m/%d/%Y %X"), message)
logger.log(level, message)

View file

@ -1,7 +1,5 @@
<style>
.editable {
display: inline-block;
padding: 15px;
outline: none;
border: 1px solid rgba(0, 0, 0, 0);
}
@ -22,8 +20,12 @@
<div class="jumbotron">
<center>
<div ng-show="team['in_team']==true">
<h1><span data-toggle="tooltip" data-placement="top" title="Click to edit team name." id="teamname_edit" class="editable" contenteditable>{{ team['teamname'] }}</span></h1>
<h4><i class="fa fa-fw fa-university"></i> <span data-toggle="tooltip" data-placement="top" title="Click to edit school." id="school_edit" class="editable" contenteditable>{{ team['school'] || 'Add School' }}</span></h4>
<h1><span data-toggle="tooltip" data-placement="top" title="Click to edit team name." id="teamname_edit" class="padded editable" contenteditable>{{ team['teamname'] }}</span></h1>
<h4><i class="fa fa-fw fa-university"></i> <span data-toggle="tooltip" data-placement="top" title="Click to edit school." id="school_edit" class="padded editable" contenteditable>{{ team['school'] || 'Add School' }}</span></h4>
<div class="badge">
<i class="fa fa-fw fa-flag"></i>
I'm in the team!
</div>
</div>
<div ng-show="team['in_team']!=true">
<h1><span class="padded">{{ team['teamname'] }}</span></h1>