add more logs
This commit is contained in:
parent
dea6de5cf3
commit
19a475199a
3 changed files with 25 additions and 32 deletions
|
@ -18,7 +18,7 @@ server {
|
||||||
default_type text/html;
|
default_type text/html;
|
||||||
try_files /index.html /index.html;
|
try_files /index.html /index.html;
|
||||||
}
|
}
|
||||||
location ~^/admin/(problems)$ {
|
location ~^/admin/(problems|settings|stats|teams)$ {
|
||||||
default_type text/html;
|
default_type text/html;
|
||||||
try_files /index.html /index.html;
|
try_files /index.html /index.html;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,9 @@ import datetime
|
||||||
import logging
|
import logging
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
import os
|
import os
|
||||||
|
import pkgutil
|
||||||
|
|
||||||
|
import api
|
||||||
|
|
||||||
NOTSET = 0
|
NOTSET = 0
|
||||||
DEBUG = 10
|
DEBUG = 10
|
||||||
|
@ -11,33 +14,21 @@ ERROR = 40
|
||||||
CRITICAL = 50
|
CRITICAL = 50
|
||||||
|
|
||||||
def initialize_logs():
|
def initialize_logs():
|
||||||
registration_logger = logging.getLogger("registrations")
|
def create_logger(name):
|
||||||
login_logger = logging.getLogger("logins")
|
new_logger = logging.getLogger(name)
|
||||||
submission_logger = logging.getLogger("submissions")
|
new_logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
registration_logger.setLevel(logging.INFO)
|
|
||||||
login_logger.setLevel(logging.INFO)
|
|
||||||
submission_logger.setLevel(logging.INFO)
|
|
||||||
|
|
||||||
base = os.path.dirname(__file__).strip("api")
|
base = os.path.dirname(__file__).strip("api")
|
||||||
log_path = os.path.join(base, "logs")
|
log_path = os.path.join(base, "logs")
|
||||||
|
|
||||||
if not os.path.exists(log_path):
|
if not os.path.exists(log_path):
|
||||||
os.mkdir(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")]
|
log_handler = logging.handlers.RotatingFileHandler(os.path.join(log_path, name + ".log"))
|
||||||
logs = map(lambda x: os.path.join(log_path, x + ".log"), \
|
new_logger.addHandler(log_handler)
|
||||||
[ "registrations", "logins", "submissions", "create_team" ])
|
for importer, modname, ispkg in pkgutil.walk_packages(path="../api"):
|
||||||
|
create_logger(modname)
|
||||||
|
|
||||||
registration_log = logging.handlers.RotatingFileHandler(logs[0], maxBytes=10000)
|
def log(logname, level, message):
|
||||||
login_log = logging.handlers.RotatingFileHandler(logs[1], maxBytes=10000)
|
logger = logging.getLogger(logname)
|
||||||
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)
|
|
||||||
message = "[%s] %s" % (datetime.datetime.now().strftime("%m/%d/%Y %X"), message)
|
message = "[%s] %s" % (datetime.datetime.now().strftime("%m/%d/%Y %X"), message)
|
||||||
logger.log(level, message)
|
logger.log(level, message)
|
|
@ -1,7 +1,5 @@
|
||||||
<style>
|
<style>
|
||||||
.editable {
|
.editable {
|
||||||
display: inline-block;
|
|
||||||
padding: 15px;
|
|
||||||
outline: none;
|
outline: none;
|
||||||
border: 1px solid rgba(0, 0, 0, 0);
|
border: 1px solid rgba(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
@ -22,8 +20,12 @@
|
||||||
<div class="jumbotron">
|
<div class="jumbotron">
|
||||||
<center>
|
<center>
|
||||||
<div ng-show="team['in_team']==true">
|
<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>
|
<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="editable" contenteditable>{{ team['school'] || 'Add School' }}</span></h4>
|
<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>
|
||||||
<div ng-show="team['in_team']!=true">
|
<div ng-show="team['in_team']!=true">
|
||||||
<h1><span class="padded">{{ team['teamname'] }}</span></h1>
|
<h1><span class="padded">{{ team['teamname'] }}</span></h1>
|
||||||
|
|
Loading…
Reference in a new issue