blob: 28b1366f889c6c51683553d5bddd28ba147f94fe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
import inspect
import sys
def log_level():
frames = inspect.stack()
level = 0
for i in frames[ 3: ]:
if i[0].f_locals.has_key( '__log__' ):
level = level + i[0].f_locals[ '__log__' ]
return level
def stdlog( message ):
sys.stderr.write( '# ' + ' ' * log_level() + message + '\n' )
sys.stderr.flush()
log = stdlog
|