Skip to content

What is the difference between logger_tt.logger and logger_tt.getLogger(name)? #1

@rudaoshi

Description

@rudaoshi

First, let me express my appreciation to you for this wonderful logging library. It's my pleasure to be the author of the first issue.

logger_tt helps me a lot. But I meet a problem.

I used to think that logger_tt.getLogger(name) will get a logger with same behavior with the logger_tt.logger, since they are configured by a global setup_logging.

However, I find that they behaves differently. For example, in the multi-processing case, the logger_tt.logger will add the process name to the logger, while logger_tt.getLogger(name) does not.

The behavior seems a little strange to me since there is only one global configuration there.

And when I want to set another formatter to the logger obtained by logger_tt.getLogger(name), the formatter seems not working. The codes are as follows:

    logger = logger_tt.getLogger(name)

    FORMAT = "%(asctime)s [$BOLD%(name)-20s$RESET][%(levelname)-18s] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)"
    COLOR_FORMAT = formatter_message(FORMAT, True)

    color_formatter = ColoredFormatter(COLOR_FORMAT)

    for handler in logger.handlers:
        handler.setFormatter(color_formatter)

    return logger

Could you please help to look through this problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions