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.
 
 
 
 
 

36 lines
828 B

  1. # -*- coding: utf-8 -*-
  2. """Debug and logging functions."""
  3. from __future__ import print_function
  4. from flask import g, request
  5. import logging
  6. from rophako.settings import Config
  7. class LogHandler(logging.Handler):
  8. """A custom logging handler."""
  9. def emit(self, record):
  10. # The initial log line, which has the $prefix$ in it.
  11. line = self.format(record)
  12. # Is the user logged in?
  13. name = "-nobody-"
  14. line = line.replace('$prefix$', '')
  15. print(line)
  16. # Set up the logger.
  17. logger = logging.getLogger("rophako")
  18. handler = LogHandler()
  19. handler.setFormatter(logging.Formatter("[%(asctime)s] [%(levelname)s] $prefix$%(message)s"))
  20. logger.addHandler(handler)
  21. # Log level.
  22. if Config.site.debug == "true":
  23. logger.setLevel(logging.DEBUG)
  24. else:
  25. logger.setLevel(logging.INFO)