Add more logging context.

This commit is contained in:
kenkeiras 2017-10-01 20:46:48 +02:00
parent 6278cc43f7
commit 2f76cdc260
3 changed files with 57 additions and 44 deletions

View file

@ -41,8 +41,15 @@ class OrgModeSession:
def __init__(self, fname):
self.f = open(fname, 'wt')
self.level = 0
self.dirty = False
def annotate(self, annotation):
if self.dirty:
self.f.write("{indentation} {data}\n".format(
indentation='*' * (self.level + 2),
data="---"))
self.dirty = False
self.f.write("{indentation} {data}\n".format(
indentation=' ' * (self.level + 2 + 1),
data=annotation))
@ -51,6 +58,7 @@ class OrgModeSession:
self.f.write("{indentation} {data}\n".format(
indentation='*' * (self.level + 1),
data=string))
self.dirty = False
return LevelContext(self.inc_level, self.dec_level)
@ -59,6 +67,7 @@ class OrgModeSession:
def dec_level(self):
self.level -= 1
self.dirty = True
def close(self):
self.f.close()