Commits

Marco Lui  committed 756ffc1

added a demonstration of decorator and context manager interfaces

  • Participants
  • Parent commits 16d90bc

Comments (0)

Files changed (1)

File src/consoleLog/__init__.py

     log.log('Postprocessing step')
     sl(1.0)
     log.finish()
+
+def extended_demo():
+    import time
+    log = consoleLog.ConsoleLogger()
+
+    @log.with_log("Let's have some eggs")
+    def eggs():
+        log.log("eggs")
+        for i in range(5):
+            spam()
+
+    @log.with_log
+    def spam():
+        time.sleep(0.5)
+        log.log("spam")
+
+    with log.level('Level 0'):
+        pass
+    with log.level('Level 1'):
+        log.log('message at level 1')
+        with log.level('Level 2'):
+            log.log('message at level 2')
+            eggs()