Add more logging context.
This commit is contained in:
parent
6278cc43f7
commit
2f76cdc260
3 changed files with 57 additions and 44 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue