Skip to content

prefect.logging.highlighters

LevelHighlighter

Bases: RegexHighlighter

Apply style to log levels.

Source code in src/prefect/logging/highlighters.py
 6
 7
 8
 9
10
11
12
13
14
15
16
class LevelHighlighter(RegexHighlighter):
    """Apply style to log levels."""

    base_style = "level."
    highlights = [
        r"(?P<debug_level>DEBUG)",
        r"(?P<info_level>INFO)",
        r"(?P<warning_level>WARNING)",
        r"(?P<error_level>ERROR)",
        r"(?P<critical_level>CRITICAL)",
    ]

NameHighlighter

Bases: RegexHighlighter

Apply style to names.

Source code in src/prefect/logging/highlighters.py
29
30
31
32
33
34
35
36
37
38
39
40
class NameHighlighter(RegexHighlighter):
    """Apply style to names."""

    base_style = "name."
    highlights = [
        # ?i means case insensitive
        # ?<= means find string right after the words: flow run
        r"(?i)(?P<flow_run_name>(?<=flow run) \'(.*?)\')",
        r"(?i)(?P<flow_name>(?<=flow) \'(.*?)\')",
        r"(?i)(?P<task_run_name>(?<=task run) \'(.*?)\')",
        r"(?i)(?P<task_name>(?<=task) \'(.*?)\')",
    ]

PrefectConsoleHighlighter

Bases: RegexHighlighter

Applies style from multiple highlighters.

Source code in src/prefect/logging/highlighters.py
55
56
57
58
59
60
61
62
63
64
class PrefectConsoleHighlighter(RegexHighlighter):
    """Applies style from multiple highlighters."""

    base_style = "log."
    highlights = (
        LevelHighlighter.highlights
        + UrlHighlighter.highlights
        + NameHighlighter.highlights
        + StateHighlighter.highlights
    )

StateHighlighter

Bases: RegexHighlighter

Apply style to states.

Source code in src/prefect/logging/highlighters.py
43
44
45
46
47
48
49
50
51
52
class StateHighlighter(RegexHighlighter):
    """Apply style to states."""

    base_style = "state."
    highlights = [
        rf"(?P<{state.value.lower()}_state>{state.value.title()})"
        for state in StateType
    ] + [
        r"(?P<cached_state>Cached)(?=\(type=COMPLETED\))"  # Highlight only "Cached"
    ]

UrlHighlighter

Bases: RegexHighlighter

Apply style to urls.

Source code in src/prefect/logging/highlighters.py
19
20
21
22
23
24
25
26
class UrlHighlighter(RegexHighlighter):
    """Apply style to urls."""

    base_style = "url."
    highlights = [
        r"(?P<web_url>(https|http|ws|wss):\/\/[0-9a-zA-Z\$\-\_\+\!`\(\)\,\.\?\/\;\:\&\=\%\#]*)",
        r"(?P<local_url>(file):\/\/[0-9a-zA-Z\$\-\_\+\!`\(\)\,\.\?\/\;\:\&\=\%\#]*)",
    ]