Skip to content

Commit

Permalink
Add examples of Logger-based logging to demo.py
Browse files Browse the repository at this point in the history
  • Loading branch information
mrahtz committed Sep 15, 2019
1 parent c4025aa commit 4391b64
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions demo.py
@@ -1,7 +1,11 @@
#!/usr/bin/env python
import time

import easy_tf_log

# Logging using the global logger

# Will log to automatically-created 'logs' directory
for i in range(10):
easy_tf_log.tflog('foo', i)
for j in range(10, 20):
Expand All @@ -13,3 +17,18 @@
easy_tf_log.tflog('baz', k)
for l in range(5):
easy_tf_log.tflog('qux', l, step=(10 * l))

# Logging using a Logger object

logger = easy_tf_log.Logger(log_dir='logs3')

for i in range(10):
logger.log_key_value('quux', i)

logger.log_list_stats('quuz', [1, 2, 3, 4, 5])

logger.measure_rate('corge', 10)
time.sleep(1)
logger.measure_rate('corge', 20) # Logged rate: (20 - 10) / 1
time.sleep(2)
logger.measure_rate('corge', 30) # Logged rate: (30 - 20) / 2

0 comments on commit 4391b64

Please sign in to comment.