andreped commited on
Commit
27f2632
1 Parent(s): 59f797f

Added flush_logs method

Browse files
Files changed (1) hide show
  1. demo/src/logger.py +9 -2
demo/src/logger.py CHANGED
@@ -3,14 +3,14 @@ import sys
3
 
4
 
5
  def get_logger():
6
- logging.getLogger(__name__)
7
 
8
 
9
  def setup_logger():
10
  # clear log
11
  file_to_delete = open("log.txt", "w")
12
  file_to_delete.close()
13
-
14
  file_handler = logging.FileHandler(filename="log.txt")
15
  stdout_handler = logging.StreamHandler(stream=sys.stdout)
16
  handlers = [file_handler, stdout_handler]
@@ -28,3 +28,10 @@ def read_logs():
28
  sys.stdout.flush()
29
  with open("log.txt", "r") as f:
30
  return f.read()
 
 
 
 
 
 
 
 
3
 
4
 
5
  def get_logger():
6
+ return logging.getLogger(__name__)
7
 
8
 
9
  def setup_logger():
10
  # clear log
11
  file_to_delete = open("log.txt", "w")
12
  file_to_delete.close()
13
+
14
  file_handler = logging.FileHandler(filename="log.txt")
15
  stdout_handler = logging.StreamHandler(stream=sys.stdout)
16
  handlers = [file_handler, stdout_handler]
 
28
  sys.stdout.flush()
29
  with open("log.txt", "r") as f:
30
  return f.read()
31
+
32
+
33
+ def flush_logs():
34
+ sys.stdout.flush()
35
+ # clear log
36
+ file_to_delete = open("log.txt", "w")
37
+ file_to_delete.close()