File size: 729 Bytes
272ebb9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18907b9
 
 
 
 
 
272ebb9
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import sys
from src.envs import API

class Logger:
    def __init__(self, filename):
        self.terminal = sys.stdout
        self.log = open(filename, "a+")

    def write(self, message):
        self.terminal.write(message)
        self.log.write(message)
        
    def flush(self):
        self.terminal.flush()
        self.log.flush()
        
    def isatty(self):
        return False    

def read_logs():
    sys.stdout.flush()
    # API.upload_file(
    #    path_or_fileobj="output.log",
    #    path_in_repo="backend.log",
    #    repo_id="dicta-hebrew-llm-leaderboard/logs",
    #    repo_type="dataset",
    # )

    with open("output.log", "r") as f:
        return f.read()

LOGGER =  Logger("output.log")