Added fallback logging option for Sublime Text
This commit is contained in:
parent
f9f870dec4
commit
d287a84950
1 changed files with 12 additions and 3 deletions
|
@ -5,6 +5,13 @@ from inspect import stack
|
||||||
from sys import stderr
|
from sys import stderr
|
||||||
from sys import stdout
|
from sys import stdout
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
import sublime
|
||||||
|
print_fallback = True
|
||||||
|
except ImportError:
|
||||||
|
print_fallback = False
|
||||||
|
|
||||||
# Formatting
|
# Formatting
|
||||||
BOLD = "\033[1m"
|
BOLD = "\033[1m"
|
||||||
HIDDEN = "\033[2m"
|
HIDDEN = "\033[2m"
|
||||||
|
@ -63,9 +70,11 @@ def print_out(message, color, file):
|
||||||
module = getmodule(i[0]).__name__
|
module = getmodule(i[0]).__name__
|
||||||
else:
|
else:
|
||||||
module = getmodule(stack_[2][0]).__name__
|
module = getmodule(stack_[2][0]).__name__
|
||||||
print("[%s] %s: %s%s\033[0m" % (strftime("%H:%M:%S"), module, color, message), file=file)
|
if not print_fallback:
|
||||||
file.flush()
|
print("[%s] %s: %s%s\033[0m" % (strftime("%H:%M:%S"), module, color, message), file=file)
|
||||||
|
file.flush()
|
||||||
|
else:
|
||||||
|
print("[%s] %s: %s" % (strftime("%H:%M:%S"), module, message))
|
||||||
|
|
||||||
def info(message, color=""):
|
def info(message, color=""):
|
||||||
print_out(message, color, stdout)
|
print_out(message, color, stdout)
|
||||||
|
|
Reference in a new issue