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.

33 lines
750B

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