• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pantsbuild / pants / 22740642519

05 Mar 2026 11:00PM UTC coverage: 52.677% (-40.3%) from 92.931%
22740642519

Pull #23157

github

web-flow
Merge 2aa18e6d4 into f0030f5e7
Pull Request #23157: [pants ng] Partition source files by config.

31678 of 60136 relevant lines covered (52.68%)

0.53 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.21
/src/python/pants/util/logging.py
1
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

4
from __future__ import annotations
1✔
5

6
import logging
1✔
7
from enum import Enum
1✔
8
from functools import total_ordering
1✔
9

10
# A custom log level for pants trace logging.
11
TRACE = 5
1✔
12

13

14
@total_ordering
1✔
15
class LogLevel(Enum):
1✔
16
    """Exposes an enum of the Python `logging` module's levels, with the addition of TRACE.
17

18
    NB: The `logging` module uses the opposite integer ordering of levels from Rust's `log` crate,
19
    but the ordering implementation of this enum inverts its comparison to make its ordering align
20
    with Rust's. That is, TRACE > DEBUG > INFO > WARN > ERROR
21
    """
22

23
    TRACE = ("trace", TRACE)
1✔
24
    DEBUG = ("debug", logging.DEBUG)
1✔
25
    INFO = ("info", logging.INFO)
1✔
26
    WARN = ("warn", logging.WARN)
1✔
27
    ERROR = ("error", logging.ERROR)
1✔
28

29
    _level: int
1✔
30

31
    def __new__(cls, value: str, level: int) -> LogLevel:
1✔
32
        member: LogLevel = object.__new__(cls)
1✔
33
        member._value_ = value
1✔
34
        member._level = level
1✔
35
        return member
1✔
36

37
    @property
1✔
38
    def level(self) -> int:
1✔
39
        return self._level
1✔
40

41
    def log(self, logger: logging.Logger, *args, **kwargs) -> None:
1✔
42
        logger.log(self._level, *args, **kwargs)
×
43

44
    def set_level_for(self, logger: logging.Logger):
1✔
45
        logger.setLevel(self.level)
1✔
46

47
    def __lt__(self, other):
1✔
48
        if not isinstance(other, LogLevel):
×
49
            return NotImplemented
×
50
        return self._level > other._level
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc