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)
|
base = os.path.dirname(__file__).strip("api")
|
||||||
login_logger.setLevel(logging.INFO)
|
log_path = os.path.join(base, "logs")
|
||||||
submission_logger.setLevel(logging.INFO)
|
if not os.path.exists(log_path):
|
||||||
|
os.mkdir(log_path)
|
||||||
|
|
||||||
base = os.path.dirname(__file__).strip("api")
|
log_handler = logging.handlers.RotatingFileHandler(os.path.join(log_path, name + ".log"))
|
||||||
log_path = os.path.join(base, "logs")
|
new_logger.addHandler(log_handler)
|
||||||
|
for importer, modname, ispkg in pkgutil.walk_packages(path="../api"):
|
||||||
|
create_logger(modname)
|
||||||
|
|
||||||
if not os.path.exists(log_path):
|
def log(logname, level, message):
|
||||||
os.mkdir(log_path)
|
logger = logging.getLogger(logname)
|
||||||
|
message = "[%s] %s" % (datetime.datetime.now().strftime("%m/%d/%Y %X"), message)
|
||||||
# logs = [os.path.join(log_path, "registrations.log"), os.path.join(log_path, "logins.log"), os.path.join(log_path, "submissions.log")]
|
logger.log(level, message)
|
||||||
logs = map(lambda x: os.path.join(log_path, x + ".log"), \
|
|
||||||
[ "registrations", "logins", "submissions", "create_team" ])
|
|
||||||
|
|
||||||
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)
|
|
||||||
message = "[%s] %s" % (datetime.datetime.now().strftime("%m/%d/%Y %X"), 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