File size: 751 Bytes
5374a2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
34
import os
from loguru import logger

# logger.remove()
# logger.add(sys.stdout, level="INFO")
# file_handler_id = None 
save_logging_file = None  

def save_logger(path: str):
    """
    Save the logging to a file.
    
    Args:
        path: The path to save the logging file
    """
    global save_logging_file
    save_logging_file = path

    parent_folder = os.path.dirname(path)
    os.makedirs(parent_folder, exist_ok=True)
    logger.add(path, encoding="utf-8", format="{time:YYYY-MM-DD HH:mm:ss} | {level} | {message}")

def get_log_file():
    """
    Get the path to the logging file.
    
    Returns:
        str: The path to the logging file
    """
    return save_logging_file 

__all__ = ["logger", "save_logger", "get_log_file"]