Config
Configuration.
Classes⚓︎
Config
dataclass
⚓︎
tail-jsonl config.
Source code in tail_jsonl/config.py
@dataclass
class Config:
"""`tail-jsonl` config."""
styles: Styles = field(default_factory=Styles)
keys: Keys = field(default_factory=Keys)
debug: bool = False
@classmethod
def from_dict(cls, data: dict) -> Config: # type: ignore[type-arg]
"""Return Self instance."""
return cls(
styles=styles_from_dict(data.get('styles', {})),
keys=Keys.from_dict(data.get('keys', {})),
debug=data.get('debug', False),
)
Functions⚓︎
from_dict
classmethod
⚓︎
from_dict(data)
Return Self instance.
Source code in tail_jsonl/config.py
@classmethod
def from_dict(cls, data: dict) -> Config: # type: ignore[type-arg]
"""Return Self instance."""
return cls(
styles=styles_from_dict(data.get('styles', {})),
keys=Keys.from_dict(data.get('keys', {})),
debug=data.get('debug', False),
)
Keys
dataclass
⚓︎
Special Keys.
Source code in tail_jsonl/config.py
@dataclass
class Keys:
"""Special Keys."""
# TODO: Are these dotted keys properly parsed?
timestamp: list[str] = field(default_factory=lambda: ['timestamp', 'time', 'record.time.repr'])
level: list[str] = field(default_factory=lambda: ['level', 'levelname', 'record.level.name'])
message: list[str] = field(default_factory=lambda: ['event', 'message', 'msg', 'record.message'])
on_own_line: list[str] = field(default_factory=lambda: ['text', 'exception', 'error.stack'])
@classmethod
def from_dict(cls, data: dict) -> Keys: # type: ignore[type-arg]
"""Return Self instance."""
return cls(**data)
Functions⚓︎
styles_from_dict ⚓︎
styles_from_dict(data)
Return Self instance.
Source code in tail_jsonl/config.py
def styles_from_dict(data: dict) -> Styles: # type: ignore[type-arg]
"""Return Self instance."""
if colors := (data.pop('colors', None) or None):
colors = Colors(**colors)
return Styles(**data, colors=colors)