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

pantsbuild / pants / 23068140808

13 Mar 2026 07:56PM UTC coverage: 52.677% (-40.3%) from 92.932%
23068140808

Pull #23170

github

web-flow
Merge e8ca01cfa into f07276df6
Pull Request #23170: Debug reapi test cache misses

31687 of 60153 relevant lines covered (52.68%)

1.05 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
2✔
5

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

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

13

14
@total_ordering
2✔
15
class LogLevel(Enum):
2✔
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)
2✔
24
    DEBUG = ("debug", logging.DEBUG)
2✔
25
    INFO = ("info", logging.INFO)
2✔
26
    WARN = ("warn", logging.WARN)
2✔
27
    ERROR = ("error", logging.ERROR)
2✔
28

29
    _level: int
2✔
30

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

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

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

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

47
    def __lt__(self, other):
2✔
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