2010-05-02 00:03:45 +02:00
|
|
|
import sys, os
|
|
|
|
|
2010-05-02 06:52:06 +02:00
|
|
|
logprefix = ''
|
2010-05-02 08:14:20 +02:00
|
|
|
verbose = 0
|
2010-05-02 06:52:06 +02:00
|
|
|
|
2010-05-02 00:03:45 +02:00
|
|
|
def log(s):
|
2010-05-16 23:55:46 +02:00
|
|
|
try:
|
|
|
|
sys.stdout.flush()
|
|
|
|
sys.stderr.write(logprefix + s)
|
|
|
|
sys.stderr.flush()
|
|
|
|
except IOError:
|
|
|
|
# this could happen if stderr gets forcibly disconnected, eg. because
|
|
|
|
# our tty closes. That sucks, but it's no reason to abort the program.
|
|
|
|
pass
|
2010-05-02 08:14:20 +02:00
|
|
|
|
|
|
|
def debug1(s):
|
|
|
|
if verbose >= 1:
|
|
|
|
log(s)
|
|
|
|
|
|
|
|
def debug2(s):
|
|
|
|
if verbose >= 2:
|
|
|
|
log(s)
|
2010-05-02 08:23:42 +02:00
|
|
|
|
2010-05-08 07:30:34 +02:00
|
|
|
def debug3(s):
|
|
|
|
if verbose >= 3:
|
|
|
|
log(s)
|
|
|
|
|
2010-05-02 08:23:42 +02:00
|
|
|
|
|
|
|
class Fatal(Exception):
|
|
|
|
pass
|