1# -*- coding: utf-8 -*- 
    2# Copyright 2025 Google LLC 
    3# 
    4# Licensed under the Apache License, Version 2.0 (the "License"); 
    5# you may not use this file except in compliance with the License. 
    6# You may obtain a copy of the License at 
    7# 
    8#     http://www.apache.org/licenses/LICENSE-2.0 
    9# 
    10# Unless required by applicable law or agreed to in writing, software 
    11# distributed under the License is distributed on an "AS IS" BASIS, 
    12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
    13# See the License for the specific language governing permissions and 
    14# limitations under the License. 
    15# 
    16from __future__ import annotations 
    17 
    18from typing import MutableMapping, MutableSequence 
    19 
    20from google.logging.type import log_severity_pb2  # type: ignore 
    21from google.protobuf import duration_pb2  # type: ignore 
    22from google.protobuf import timestamp_pb2  # type: ignore 
    23import proto  # type: ignore 
    24 
    25__protobuf__ = proto.module( 
    26    package="google.appengine.logging.v1", 
    27    manifest={ 
    28        "LogLine", 
    29        "SourceLocation", 
    30        "SourceReference", 
    31        "RequestLog", 
    32    }, 
    33) 
    34 
    35 
    36class LogLine(proto.Message): 
    37    r"""Application log line emitted while processing a request. 
    38 
    39    Attributes: 
    40        time (google.protobuf.timestamp_pb2.Timestamp): 
    41            Approximate time when this log entry was 
    42            made. 
    43        severity (google.logging.type.log_severity_pb2.LogSeverity): 
    44            Severity of this log entry. 
    45        log_message (str): 
    46            App-provided log message. 
    47        source_location (google.cloud.appengine_logging_v1.types.SourceLocation): 
    48            Where in the source code this log message was 
    49            written. 
    50    """ 
    51 
    52    time: timestamp_pb2.Timestamp = proto.Field( 
    53        proto.MESSAGE, 
    54        number=1, 
    55        message=timestamp_pb2.Timestamp, 
    56    ) 
    57    severity: log_severity_pb2.LogSeverity = proto.Field( 
    58        proto.ENUM, 
    59        number=2, 
    60        enum=log_severity_pb2.LogSeverity, 
    61    ) 
    62    log_message: str = proto.Field( 
    63        proto.STRING, 
    64        number=3, 
    65    ) 
    66    source_location: "SourceLocation" = proto.Field( 
    67        proto.MESSAGE, 
    68        number=4, 
    69        message="SourceLocation", 
    70    ) 
    71 
    72 
    73class SourceLocation(proto.Message): 
    74    r"""Specifies a location in a source code file. 
    75 
    76    Attributes: 
    77        file (str): 
    78            Source file name. Depending on the runtime 
    79            environment, this might be a simple name or a 
    80            fully-qualified name. 
    81        line (int): 
    82            Line within the source file. 
    83        function_name (str): 
    84            Human-readable name of the function or method being invoked, 
    85            with optional context such as the class or package name. 
    86            This information is used in contexts such as the logs 
    87            viewer, where a file and line number are less meaningful. 
    88            The format can vary by language. For example: 
    89            ``qual.if.ied.Class.method`` (Java), ``dir/package.func`` 
    90            (Go), ``function`` (Python). 
    91    """ 
    92 
    93    file: str = proto.Field( 
    94        proto.STRING, 
    95        number=1, 
    96    ) 
    97    line: int = proto.Field( 
    98        proto.INT64, 
    99        number=2, 
    100    ) 
    101    function_name: str = proto.Field( 
    102        proto.STRING, 
    103        number=3, 
    104    ) 
    105 
    106 
    107class SourceReference(proto.Message): 
    108    r"""A reference to a particular snapshot of the source tree used 
    109    to build and deploy an application. 
    110 
    111    Attributes: 
    112        repository (str): 
    113            Optional. A URI string identifying the 
    114            repository. Example: 
    115            "https://github.com/GoogleCloudPlatform/kubernetes.git". 
    116        revision_id (str): 
    117            The canonical and persistent identifier of 
    118            the deployed revision. Example (git): 
    119            "0035781c50ec7aa23385dc841529ce8a4b70db1b". 
    120    """ 
    121 
    122    repository: str = proto.Field( 
    123        proto.STRING, 
    124        number=1, 
    125    ) 
    126    revision_id: str = proto.Field( 
    127        proto.STRING, 
    128        number=2, 
    129    ) 
    130 
    131 
    132class RequestLog(proto.Message): 
    133    r"""Complete log information about a single HTTP request to an 
    134    App Engine application. 
    135 
    136    Attributes: 
    137        app_id (str): 
    138            Application that handled this request. 
    139        module_id (str): 
    140            Module of the application that handled this 
    141            request. 
    142        version_id (str): 
    143            Version of the application that handled this 
    144            request. 
    145        request_id (str): 
    146            Globally unique identifier for a request, 
    147            which is based on the request start time. 
    148            Request IDs for requests which started later 
    149            will compare greater as strings than those for 
    150            requests which started earlier. 
    151        ip (str): 
    152            Origin IP address. 
    153        start_time (google.protobuf.timestamp_pb2.Timestamp): 
    154            Time when the request started. 
    155        end_time (google.protobuf.timestamp_pb2.Timestamp): 
    156            Time when the request finished. 
    157        latency (google.protobuf.duration_pb2.Duration): 
    158            Latency of the request. 
    159        mega_cycles (int): 
    160            Number of CPU megacycles used to process 
    161            request. 
    162        method (str): 
    163            Request method. Example: ``"GET"``, ``"HEAD"``, ``"PUT"``, 
    164            ``"POST"``, ``"DELETE"``. 
    165        resource (str): 
    166            Contains the path and query portion of the URL that was 
    167            requested. For example, if the URL was 
    168            "http://example.com/app?name=val", the resource would be 
    169            "/app?name=val". The fragment identifier, which is 
    170            identified by the ``#`` character, is not included. 
    171        http_version (str): 
    172            HTTP version of request. Example: ``"HTTP/1.1"``. 
    173        status (int): 
    174            HTTP response status code. Example: 200, 404. 
    175        response_size (int): 
    176            Size in bytes sent back to client by request. 
    177        referrer (str): 
    178            Referrer URL of request. 
    179        user_agent (str): 
    180            User agent that made the request. 
    181        nickname (str): 
    182            The logged-in user who made the request. 
    183 
    184            Most likely, this is the part of the user's email before the 
    185            ``@`` sign. The field value is the same for different 
    186            requests from the same user, but different users can have 
    187            similar names. This information is also available to the 
    188            application via the App Engine Users API. 
    189 
    190            This field will be populated starting with App Engine 
    191            1.9.21. 
    192        url_map_entry (str): 
    193            File or class that handled the request. 
    194        host (str): 
    195            Internet host and port number of the resource 
    196            being requested. 
    197        cost (float): 
    198            An indication of the relative cost of serving 
    199            this request. 
    200        task_queue_name (str): 
    201            Queue name of the request, in the case of an 
    202            offline request. 
    203        task_name (str): 
    204            Task name of the request, in the case of an 
    205            offline request. 
    206        was_loading_request (bool): 
    207            Whether this was a loading request for the 
    208            instance. 
    209        pending_time (google.protobuf.duration_pb2.Duration): 
    210            Time this request spent in the pending 
    211            request queue. 
    212        instance_index (int): 
    213            If the instance processing this request 
    214            belongs to a manually scaled module, then this 
    215            is the 0-based index of the instance. Otherwise, 
    216            this value is -1. 
    217        finished (bool): 
    218            Whether this request is finished or active. 
    219        first (bool): 
    220            Whether this is the first ``RequestLog`` entry for this 
    221            request. If an active request has several ``RequestLog`` 
    222            entries written to Stackdriver Logging, then this field will 
    223            be set for one of them. 
    224        instance_id (str): 
    225            An identifier for the instance that handled 
    226            the request. 
    227        line (MutableSequence[google.cloud.appengine_logging_v1.types.LogLine]): 
    228            A list of log lines emitted by the 
    229            application while serving this request. 
    230        app_engine_release (str): 
    231            App Engine release version. 
    232        trace_id (str): 
    233            Stackdriver Trace identifier for this 
    234            request. 
    235        trace_sampled (bool): 
    236            If true, the value in the 'trace_id' field was sampled for 
    237            storage in a trace backend. 
    238        source_reference (MutableSequence[google.cloud.appengine_logging_v1.types.SourceReference]): 
    239            Source code for the application that handled 
    240            this request. There can be more than one source 
    241            reference per deployed application if source 
    242            code is distributed among multiple repositories. 
    243    """ 
    244 
    245    app_id: str = proto.Field( 
    246        proto.STRING, 
    247        number=1, 
    248    ) 
    249    module_id: str = proto.Field( 
    250        proto.STRING, 
    251        number=37, 
    252    ) 
    253    version_id: str = proto.Field( 
    254        proto.STRING, 
    255        number=2, 
    256    ) 
    257    request_id: str = proto.Field( 
    258        proto.STRING, 
    259        number=3, 
    260    ) 
    261    ip: str = proto.Field( 
    262        proto.STRING, 
    263        number=4, 
    264    ) 
    265    start_time: timestamp_pb2.Timestamp = proto.Field( 
    266        proto.MESSAGE, 
    267        number=6, 
    268        message=timestamp_pb2.Timestamp, 
    269    ) 
    270    end_time: timestamp_pb2.Timestamp = proto.Field( 
    271        proto.MESSAGE, 
    272        number=7, 
    273        message=timestamp_pb2.Timestamp, 
    274    ) 
    275    latency: duration_pb2.Duration = proto.Field( 
    276        proto.MESSAGE, 
    277        number=8, 
    278        message=duration_pb2.Duration, 
    279    ) 
    280    mega_cycles: int = proto.Field( 
    281        proto.INT64, 
    282        number=9, 
    283    ) 
    284    method: str = proto.Field( 
    285        proto.STRING, 
    286        number=10, 
    287    ) 
    288    resource: str = proto.Field( 
    289        proto.STRING, 
    290        number=11, 
    291    ) 
    292    http_version: str = proto.Field( 
    293        proto.STRING, 
    294        number=12, 
    295    ) 
    296    status: int = proto.Field( 
    297        proto.INT32, 
    298        number=13, 
    299    ) 
    300    response_size: int = proto.Field( 
    301        proto.INT64, 
    302        number=14, 
    303    ) 
    304    referrer: str = proto.Field( 
    305        proto.STRING, 
    306        number=15, 
    307    ) 
    308    user_agent: str = proto.Field( 
    309        proto.STRING, 
    310        number=16, 
    311    ) 
    312    nickname: str = proto.Field( 
    313        proto.STRING, 
    314        number=40, 
    315    ) 
    316    url_map_entry: str = proto.Field( 
    317        proto.STRING, 
    318        number=17, 
    319    ) 
    320    host: str = proto.Field( 
    321        proto.STRING, 
    322        number=20, 
    323    ) 
    324    cost: float = proto.Field( 
    325        proto.DOUBLE, 
    326        number=21, 
    327    ) 
    328    task_queue_name: str = proto.Field( 
    329        proto.STRING, 
    330        number=22, 
    331    ) 
    332    task_name: str = proto.Field( 
    333        proto.STRING, 
    334        number=23, 
    335    ) 
    336    was_loading_request: bool = proto.Field( 
    337        proto.BOOL, 
    338        number=24, 
    339    ) 
    340    pending_time: duration_pb2.Duration = proto.Field( 
    341        proto.MESSAGE, 
    342        number=25, 
    343        message=duration_pb2.Duration, 
    344    ) 
    345    instance_index: int = proto.Field( 
    346        proto.INT32, 
    347        number=26, 
    348    ) 
    349    finished: bool = proto.Field( 
    350        proto.BOOL, 
    351        number=27, 
    352    ) 
    353    first: bool = proto.Field( 
    354        proto.BOOL, 
    355        number=42, 
    356    ) 
    357    instance_id: str = proto.Field( 
    358        proto.STRING, 
    359        number=28, 
    360    ) 
    361    line: MutableSequence["LogLine"] = proto.RepeatedField( 
    362        proto.MESSAGE, 
    363        number=29, 
    364        message="LogLine", 
    365    ) 
    366    app_engine_release: str = proto.Field( 
    367        proto.STRING, 
    368        number=38, 
    369    ) 
    370    trace_id: str = proto.Field( 
    371        proto.STRING, 
    372        number=39, 
    373    ) 
    374    trace_sampled: bool = proto.Field( 
    375        proto.BOOL, 
    376        number=43, 
    377    ) 
    378    source_reference: MutableSequence["SourceReference"] = proto.RepeatedField( 
    379        proto.MESSAGE, 
    380        number=41, 
    381        message="SourceReference", 
    382    ) 
    383 
    384 
    385__all__ = tuple(sorted(__protobuf__.manifest))