File size: 675 Bytes
7362797
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the Chameleon License found in the
# LICENSE file in the root directory of this source tree.

import logging
import types

from rich.logging import RichHandler


def configure_rich_logging():
    FORMAT = "%(message)s"
    logging.basicConfig(
        level=logging.INFO,
        handlers=[RichHandler(rich_tracebacks=True)],
        format=FORMAT,
        force=True,
    )


configure_rich_logging()


def get_logger(module: types.ModuleType) -> logging.Logger:
    """This forces logging.basicConfig to be called first."""
    logger = logging.getLogger(module)
    return logger