File size: 421 Bytes
5682a2c
 
 
 
 
 
 
 
 
 
2c19a19
 
 
 
 
 
5682a2c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import logging
from typing import Optional


def get_logger(name: Optional[str] = None, level: str = "INFO") -> logging.Logger:
    if name is None:
        name = "sam2-playground"
    logger = logging.getLogger(name)
    logger.setLevel(level.upper())

    if not logger.handlers:
        handler = logging.StreamHandler()
        handler.setLevel(level.upper())

        logger.addHandler(handler)

    return logger