Google Cloud Appengine Logging API client library providing protobuf message classes for App Engine request logs, log lines, and source references.
npx @tessl/cli install tessl/pypi-google-cloud-appengine-logging@1.6.0A Python protocol buffer library providing message classes for Google Cloud App Engine Logging API. This package defines data structures for App Engine request logs, log lines, and source references without providing service clients for making API calls.
pip install google-cloud-appengine-loggingfrom google.cloud.appengine_logging import (
LogLine,
RequestLog,
SourceLocation,
SourceReference,
__version__
)Alternative import from versioned module:
from google.cloud.appengine_logging_v1 import (
LogLine,
RequestLog,
SourceLocation,
SourceReference,
__version__
)from google.cloud.appengine_logging import LogLine, RequestLog, SourceLocation, SourceReference
from google.protobuf.timestamp_pb2 import Timestamp
from google.logging.type.log_severity_pb2 import LogSeverity
# Create a log line with source location
source_location = SourceLocation(
file="main.py",
line=42,
function_name="process_request"
)
log_line = LogLine(
time=Timestamp(),
severity=LogSeverity.INFO,
log_message="Processing user request",
source_location=source_location
)
# Create a source reference for deployment tracking
source_ref = SourceReference(
repository="https://github.com/myorg/myapp.git",
revision_id="abc123def456789"
)
# Create a comprehensive request log
request_log = RequestLog(
app_id="my-app",
module_id="default",
version_id="v1.0.0",
request_id="req_12345",
ip="192.168.1.1",
method="GET",
resource="/api/users",
http_version="HTTP/1.1",
status=200,
response_size=1024,
user_agent="Mozilla/5.0",
line=[log_line],
source_reference=[source_ref]
)
# Access request log properties
print(f"Request {request_log.request_id} to {request_log.resource}")
print(f"Status: {request_log.status}, Size: {request_log.response_size} bytes")Application log line emitted while processing a request, containing timestamp, severity, message, and source location information.
class LogLine(proto.Message):
"""Application log line emitted while processing a request.
Attributes:
time (google.protobuf.timestamp_pb2.Timestamp): Approximate time when this log entry was made
severity (google.logging.type.log_severity_pb2.LogSeverity): Severity of this log entry
log_message (str): App-provided log message
source_location (SourceLocation): Where in the source code this log message was written
"""
time: "google.protobuf.timestamp_pb2.Timestamp"
severity: "google.logging.type.log_severity_pb2.LogSeverity"
log_message: str
source_location: "SourceLocation"Specifies a location in a source code file with file name, line number, and function context.
class SourceLocation(proto.Message):
"""Specifies a location in a source code file.
Attributes:
file (str): Source file name. Depending on the runtime environment, this might be a simple name or a fully-qualified name
line (int): Line within the source file
function_name (str): Human-readable name of the function or method being invoked, with optional context such as the class or package name
"""
file: str
line: int
function_name: strReference to a particular snapshot of the source tree used to build and deploy an application.
class SourceReference(proto.Message):
"""A reference to a particular snapshot of the source tree used to build and deploy an application.
Attributes:
repository (str): Optional. A URI string identifying the repository. Example: "https://github.com/GoogleCloudPlatform/kubernetes.git"
revision_id (str): The canonical and persistent identifier of the deployed revision. Example (git): "0035781c50ec7aa23385dc841529ce8a4b70db1b"
"""
repository: str
revision_id: strComplete log information about a single HTTP request to an App Engine application, containing comprehensive request and response metadata.
class RequestLog(proto.Message):
"""Complete log information about a single HTTP request to an App Engine application.
Attributes:
app_id (str): Application that handled this request
module_id (str): Module of the application that handled this request
version_id (str): Version of the application that handled this request
request_id (str): Globally unique identifier for a request, which is based on the request start time
ip (str): Origin IP address
start_time (google.protobuf.timestamp_pb2.Timestamp): Time when the request started
end_time (google.protobuf.timestamp_pb2.Timestamp): Time when the request finished
latency (google.protobuf.duration_pb2.Duration): Latency of the request
mega_cycles (int): Number of CPU megacycles used to process request
method (str): Request method. Example: "GET", "HEAD", "PUT", "POST", "DELETE"
resource (str): Contains the path and query portion of the URL that was requested
http_version (str): HTTP version of request. Example: "HTTP/1.1"
status (int): HTTP response status code. Example: 200, 404
response_size (int): Size in bytes sent back to client by request
referrer (str): Referrer URL of request
user_agent (str): User agent that made the request
nickname (str): The logged-in user who made the request
url_map_entry (str): File or class that handled the request
host (str): Internet host and port number of the resource being requested
cost (float): An indication of the relative cost of serving this request
task_queue_name (str): Queue name of the request, in the case of an offline request
task_name (str): Task name of the request, in the case of an offline request
was_loading_request (bool): Whether this was a loading request for the instance
pending_time (google.protobuf.duration_pb2.Duration): Time this request spent in the pending request queue
instance_index (int): If the instance processing this request belongs to a manually scaled module, then this is the 0-based index of the instance. Otherwise, this value is -1
finished (bool): Whether this request is finished or active
first (bool): Whether this is the first RequestLog entry for this request
instance_id (str): An identifier for the instance that handled the request
line (MutableSequence[LogLine]): A list of log lines emitted by the application while serving this request
app_engine_release (str): App Engine release version
trace_id (str): Stackdriver Trace identifier for this request
trace_sampled (bool): If true, the value in the 'trace_id' field was sampled for storage in a trace backend
source_reference (MutableSequence[SourceReference]): Source code for the application that handled this request. There can be more than one source reference per deployed application if source code is distributed among multiple repositories
"""
app_id: str
module_id: str
version_id: str
request_id: str
ip: str
start_time: "google.protobuf.timestamp_pb2.Timestamp"
end_time: "google.protobuf.timestamp_pb2.Timestamp"
latency: "google.protobuf.duration_pb2.Duration"
mega_cycles: int
method: str
resource: str
http_version: str
status: int
response_size: int
referrer: str
user_agent: str
nickname: str
url_map_entry: str
host: str
cost: float
task_queue_name: str
task_name: str
was_loading_request: bool
pending_time: "google.protobuf.duration_pb2.Duration"
instance_index: int
finished: bool
first: bool
instance_id: str
line: "MutableSequence[LogLine]"
app_engine_release: str
trace_id: str
trace_sampled: bool
source_reference: "MutableSequence[SourceReference]"Package version information for compatibility checking and debugging.
__version__: str = "1.6.2"This package uses the following external protobuf types that must be imported separately:
# From google.protobuf
from google.protobuf.timestamp_pb2 import Timestamp
from google.protobuf.duration_pb2 import Duration
# From google.logging.type
from google.logging.type.log_severity_pb2 import LogSeverity
# Protocol buffer framework
import proto
# For type annotations
from typing import MutableSequenceThe LogSeverity enum from google.logging.type.log_severity_pb2 includes:
DEFAULT (0): The log entry has no assigned severity levelDEBUG (100): Debug or trace informationINFO (200): Routine informationNOTICE (300): Notice informationWARNING (400): Warning informationERROR (500): Error informationCRITICAL (600): Critical informationALERT (700): Alert informationEMERGENCY (800): Emergency information