Guest User

Untitled

a guest
Jan 11th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. # Add to any Python script to make logging fun and easy to look at
  2. def color_code(code): return '\x1b[%sm' % code
  3. def colorize(code, s): return '%s%s%s' % (
  4. color_code(code), str(s).replace(color_code(0), color_code(code)), color_code(0))
  5. def green(s): return colorize(32, s)
  6. def yellow(s): return colorize(33, s)
  7. def red(s): return colorize('1;31', s)
  8. def cyan(s): return colorize(36, s)
  9. def magenta(s): return colorize(35, s)
  10.  
  11. def info_log(s): print yellow(s)
  12. def success_log(s): print green(s)
  13. def error_log(s): print red(s)
  14. def debug_log(s):
  15. if DEBUG: print "%s%s" % (magenta('DEBUG: '), yellow(s))
Add Comment
Please, Sign In to add comment