Skip to content

Instantly share code, notes, and snippets.

@dawn110110
Created March 2, 2013 13:55
Show Gist options
  • Save dawn110110/5071107 to your computer and use it in GitHub Desktop.
Save dawn110110/5071107 to your computer and use it in GitHub Desktop.
Use tonado's LogFormatter out of tornado. just use it as an ordinary LogFormatter, of cource tornado has to be installed.
# use tornado's formatter out of tornado
try:
from tornado.options import _LogFormatter as Fmt # tornado 2.2
except:
from tornado.log import LogFormatter as Fmt # toando 2.4
class TornadoFormatter(Fmt):
''' require toanado installed
usuage:
use it as an ordinary LogFormatter
'''
def __init__(self, *args, **kargs):
TornadoFormatter.setterm()
Fmt.__init__(self, *args, **kargs)
@classmethod
def setterm(cls):
if hasattr(cls, '_setterm_called'):
pass
else:
import curses
curses.setupterm()
cls._setterm_called = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment