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

pantsbuild / pants / 23838324561

01 Apr 2026 07:59AM UTC coverage: 60.966% (-31.9%) from 92.907%
23838324561

Pull #23204

github

web-flow
Merge fd6066932 into 0c78ceb96
Pull Request #23204: Port ScalarField, AsyncFieldMixin and friends to rust

8 of 12 new or added lines in 2 files covered. (66.67%)

19216 existing lines in 560 files now uncovered.

39119 of 64165 relevant lines covered (60.97%)

0.96 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✔
UNCOV
48
        if not isinstance(other, LogLevel):
×
49
            return NotImplemented
×
UNCOV
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