Add a schema for source location.
This commit is contained in:
parent
c6f417f323
commit
f91d6774ca
@ -28,8 +28,8 @@ class BaseLogEntry(BaseModel):
|
|||||||
span_id: Annotated[str | None, Field(alias="spanId", default=None)]
|
span_id: Annotated[str | None, Field(alias="spanId", default=None)]
|
||||||
trace_sampled: Annotated[bool | None, Field(alias="traceSampled", default=None)]
|
trace_sampled: Annotated[bool | None, Field(alias="traceSampled", default=None)]
|
||||||
source_location: Annotated[
|
source_location: Annotated[
|
||||||
dict | None, Field(alias="sourceLocation", default=None)
|
SourceLocation | None, Field(alias="sourceLocation", default=None)
|
||||||
] # https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogEntrySourceLocation
|
]
|
||||||
split: Annotated[
|
split: Annotated[
|
||||||
dict | None, Field(default=None)
|
dict | None, Field(default=None)
|
||||||
] # https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogSplit
|
] # https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogSplit
|
||||||
@ -56,6 +56,12 @@ class JsonPayloadLogEntry(BaseLogEntry):
|
|||||||
json_payload: Annotated[dict, Field(alias="jsonPayload")]
|
json_payload: Annotated[dict, Field(alias="jsonPayload")]
|
||||||
|
|
||||||
|
|
||||||
|
LogEntry = Annotated[
|
||||||
|
Union[ProtoPayloadLogEntry, JsonPayloadLogEntry, TextPayloadLogEntry, BaseLogEntry],
|
||||||
|
Field(),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class LogSeverity(str, Enum):
|
class LogSeverity(str, Enum):
|
||||||
# https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogSeverity
|
# https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogSeverity
|
||||||
DEFAULT = "DEFAULT"
|
DEFAULT = "DEFAULT"
|
||||||
@ -69,10 +75,11 @@ class LogSeverity(str, Enum):
|
|||||||
EMERGENCY = "EMERGENCY"
|
EMERGENCY = "EMERGENCY"
|
||||||
|
|
||||||
|
|
||||||
LogEntry = Annotated[
|
class SourceLocation(BaseModel):
|
||||||
Union[ProtoPayloadLogEntry, JsonPayloadLogEntry, TextPayloadLogEntry, BaseLogEntry],
|
# https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogEntrySourceLocation
|
||||||
Field(),
|
file: str
|
||||||
]
|
line: str
|
||||||
|
function: Annotated[str | None, Field(default=None)]
|
||||||
|
|
||||||
|
|
||||||
def create_log_entry(entry: dict) -> LogEntry:
|
def create_log_entry(entry: dict) -> LogEntry:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user