Skip to content

logging_config

framewise_meet_client.logging_config

configure_logging(level='INFO', log_file=None)

Configure logging for the application.

Parameters:

Name Type Description Default
level str

Log level string (DEBUG, INFO, WARNING, ERROR, CRITICAL)

'INFO'
log_file Optional[str]

Optional file path to write logs to

None
Source code in framewise_meet_client/logging_config.py
 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
35
36
def configure_logging(level: str = "INFO", log_file: Optional[str] = None):
    """Configure logging for the application.

    Args:
        level: Log level string (DEBUG, INFO, WARNING, ERROR, CRITICAL)
        log_file: Optional file path to write logs to
    """
    # Get the numeric level
    numeric_level = getattr(logging, level.upper(), None)
    if not isinstance(numeric_level, int):
        raise ValueError(f"Invalid log level: {level}")

    # Create handlers
    handlers = [logging.StreamHandler(sys.stdout)]

    if log_file:
        handlers.append(logging.FileHandler(log_file))

    # Configure logging
    logging.basicConfig(
        level=numeric_level,
        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
        handlers=handlers
    )

    # Set more restrictive levels for some verbose libraries
    logging.getLogger('websockets').setLevel(max(numeric_level, logging.INFO))
    logging.getLogger('asyncio').setLevel(max(numeric_level, logging.INFO))

    logging.info(f"Logging configured with level {level}")

    return logging.getLogger()