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)]
|
||||
trace_sampled: Annotated[bool | None, Field(alias="traceSampled", default=None)]
|
||||
source_location: Annotated[
|
||||
dict | None, Field(alias="sourceLocation", default=None)
|
||||
] # https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogEntrySourceLocation
|
||||
SourceLocation | None, Field(alias="sourceLocation", default=None)
|
||||
]
|
||||
split: Annotated[
|
||||
dict | None, Field(default=None)
|
||||
] # 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")]
|
||||
|
||||
|
||||
LogEntry = Annotated[
|
||||
Union[ProtoPayloadLogEntry, JsonPayloadLogEntry, TextPayloadLogEntry, BaseLogEntry],
|
||||
Field(),
|
||||
]
|
||||
|
||||
|
||||
class LogSeverity(str, Enum):
|
||||
# https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogSeverity
|
||||
DEFAULT = "DEFAULT"
|
||||
@ -69,10 +75,11 @@ class LogSeverity(str, Enum):
|
||||
EMERGENCY = "EMERGENCY"
|
||||
|
||||
|
||||
LogEntry = Annotated[
|
||||
Union[ProtoPayloadLogEntry, JsonPayloadLogEntry, TextPayloadLogEntry, BaseLogEntry],
|
||||
Field(),
|
||||
]
|
||||
class SourceLocation(BaseModel):
|
||||
# https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogEntrySourceLocation
|
||||
file: str
|
||||
line: str
|
||||
function: Annotated[str | None, Field(default=None)]
|
||||
|
||||
|
||||
def create_log_entry(entry: dict) -> LogEntry:
|
||||
|
Loading…
x
Reference in New Issue
Block a user