18 from typing
import Dict, Any, Tuple
19 from typing_extensions
import Self
24 from .severity
import LogSeverity
25 from .utils
import colorMessage
26 from ..utils
import mathematicalRound
32 Represents a single Coretex console log
38 severity : LogSeverity
42 def __init__(self, severity: LogSeverity, message: str) ->
None:
43 self.
timestamptimestamp = mathematicalRound(time.time(), 6)
45 self.
messagemessage = colorMessage(severity, message)
47 def encode(self) -> Dict[str, Any]:
50 "severity": self.
severityseverity.value,
56 def parse(cls, value: str) -> Tuple[Self, str]:
58 jsonLog = json.loads(value)
60 if not isinstance(jsonLog, dict):
66 return cls(
LogSeverity(jsonLog[
"severity"]), jsonLog[
"message"].rstrip()), jsonLog[
"message"]
68 return cls(LogSeverity.info, value.rstrip()), value