A Python content management system designed for kirsle.net featuring a blog, comments and photo albums.
https://rophako.kirsle.net/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
790 B
35 lines
790 B
# -*- coding: utf-8 -*-
|
|
|
|
"""Debug and logging functions."""
|
|
|
|
from __future__ import print_function
|
|
|
|
from flask import g, request
|
|
import logging
|
|
|
|
import config
|
|
|
|
class LogHandler(logging.Handler):
|
|
"""A custom logging handler."""
|
|
|
|
def emit(self, record):
|
|
# The initial log line, which has the $prefix$ in it.
|
|
line = self.format(record)
|
|
|
|
# Is the user logged in?
|
|
name = "-nobody-"
|
|
|
|
line = line.replace('$prefix$', '')
|
|
print(line)
|
|
|
|
# Set up the logger.
|
|
logger = logging.getLogger("rophako")
|
|
handler = LogHandler()
|
|
handler.setFormatter(logging.Formatter("[%(asctime)s] [%(levelname)s] $prefix$%(message)s"))
|
|
logger.addHandler(handler)
|
|
|
|
# Log level.
|
|
if config.DEBUG:
|
|
logger.setLevel(logging.DEBUG)
|
|
else:
|
|
logger.setLevel(logging.INFO) |