Files
BDE/log.py
2016-10-03 13:32:43 +02:00

33 lines
647 B
Python

from time import time, strftime
loglevel = 7
def log (msg, _level = 3):
"""
Print message if in verbose mode.
"""
if _level <= loglevel:
file = open ("log.txt", "a")
file.write (strftime ("%Y-%m-%d %H:%M:%S "))
file.write (msg + "\n")
file.close ()
def strlog (instr):
"""
Converts String into readable format
"""
oustr = ''
for c in instr:
#if (ord (c) >= 33) & (ord (c) <= 127):
# oustr = oustr + c
#else:
oustr = oustr + " x%2X " %ord(c)
return oustr
def doublechar (i):
"""
build double char val out of int
"""
return chr (i % 256) + chr ((i >> 8) % 256)