# Path: google/cloud/logging_v2/handlers/_helpers.py
# def get_request_data():
#     """Helper to get http_request and trace data from supported web
#     frameworks (currently supported: Flask and Django).
# 
#     Returns:
#         Tuple[Optional[dict], Optional[str], Optional[str], bool]:
#             Data related to the current http request, trace_id, span_id, and trace_sampled
#             for the request. All fields will be None if a http request isn't found.
#     """
#     checkers = (
#         get_request_data_from_django,
#         get_request_data_from_flask,
#     )
# 
#     for checker in checkers:
#         http_request, trace_id, span_id, trace_sampled = checker()
#         if http_request is not None:
#             return http_request, trace_id, span_id, trace_sampled
# 
#     return None, None, None, False
# 
# Path: google/cloud/logging_v2/handlers/_monitored_resources.py
# def _create_app_engine_resource():
#     """Create a standardized App Engine resource.
#     Returns:
#         google.cloud.logging.Resource
#     """
#     zone = retrieve_metadata_server(_ZONE_ID)
#     project = retrieve_metadata_server(_PROJECT_NAME)
#     resource = Resource(
#         type="gae_app",
#         labels={
#             "project_id": project,
#             "module_id": os.environ.get(_GAE_SERVICE_ENV, ""),
#             "version_id": os.environ.get(_GAE_VERSION_ENV, ""),
#             "zone": zone if zone else "",
#         },
#     )
#     return resource
# 
# Path: google/cloud/logging_v2/handlers/transports/background_thread.py
# class BackgroundThreadTransport(Transport):
#     """Asynchronous transport that uses a background thread."""
# 
#     def __init__(
#         self,
#         client,
#         name,
#         *,
#         grace_period=_DEFAULT_GRACE_PERIOD,
#         batch_size=_DEFAULT_MAX_BATCH_SIZE,
#         max_latency=_DEFAULT_MAX_LATENCY,
#         resource=_GLOBAL_RESOURCE,
#         **kwargs,
#     ):
#         """
#         Args:
#             client (~logging_v2.client.Client):
#                 The Logging client.
#             name (str): The name of the lgoger.
#             grace_period (Optional[float]): The amount of time to wait for pending logs to
#                 be submitted when the process is shutting down.
#             batch_size (Optional[int]): The maximum number of items to send at a time in the
#                 background thread.
#             max_latency (Optional[float]): The amount of time to wait for new logs before
#                 sending a new batch. It is strongly recommended to keep this smaller
#                 than the grace_period. This means this is effectively the longest
#                 amount of time the background thread will hold onto log entries
#                 before sending them to the server.
#             resource (Optional[Resource|dict]): The default monitored resource to associate
#                 with logs when not specified
#         """
#         self.client = client
#         logger = self.client.logger(name, resource=resource)
#         self.worker = _Worker(
#             logger,
#             grace_period=grace_period,
#             max_batch_size=batch_size,
#             max_latency=max_latency,
#         )
#         self.worker.start()
# 
#     def send(self, record, message, **kwargs):
#         """Overrides Transport.send().
# 
#         Args:
#             record (logging.LogRecord): Python log record that the handler was called with.
#             message (str or dict): The message from the ``LogRecord`` after being
#                 formatted by the associated log formatters.
#             kwargs: Additional optional arguments for the logger
#         """
#         self.worker.enqueue(record, message, **kwargs)
# 
#     def flush(self):
#         """Submit any pending log records."""
#         self.worker.flush()


import logging
import os
import warnings
from google.cloud.logging_v2.handlers._helpers import get_request_data
from google.cloud.logging_v2.handlers._monitored_resources import (
    _create_app_engine_resource,
)
from google.cloud.logging_v2.handlers.transports import BackgroundThreadTransport
        Args:
            client (~logging_v2.client.Client): The authenticated
                Google Cloud Logging client for this handler to use.
            name (Optional[str]): Name for the logger.
            transport (Optional[~logging_v2.transports.Transport]):
                The transport class. It should be a subclass
                of :class:`.Transport`. If unspecified,
                :class:`.BackgroundThreadTransport` will be used.
            stream (Optional[IO]): Stream to be used by the handler.

        """
        super(AppEngineHandler, self).__init__(stream)
        self.name = name
        self.client = client
        self.transport = transport(client, name)
        self.project_id = os.environ.get(
            _GAE_PROJECT_ENV_FLEX, os.environ.get(_GAE_PROJECT_ENV_STANDARD, "")
        )
        self.module_id = os.environ.get(_GAE_SERVICE_ENV, "")
        self.version_id = os.environ.get(_GAE_VERSION_ENV, "")
        self.resource = self.get_gae_resource()

        warnings.warn(_DEPRECATION_MSG, DeprecationWarning)

    def get_gae_resource(self):
        """Return the GAE resource using the environment variables.

        Returns:
            google.cloud.logging_v2.resource.Resource: Monitored resource for GAE.
        """

# Path: google/cloud/logging_v2/handlers/_helpers.py
# def get_request_data():
#     """Helper to get http_request and trace data from supported web
#     frameworks (currently supported: Flask and Django).
# 
#     Returns:
#         Tuple[Optional[dict], Optional[str], Optional[str], bool]:
#             Data related to the current http request, trace_id, span_id, and trace_sampled
#             for the request. All fields will be None if a http request isn't found.
#     """
#     checkers = (
#         get_request_data_from_django,
#         get_request_data_from_flask,
#     )
# 
#     for checker in checkers:
#         http_request, trace_id, span_id, trace_sampled = checker()
#         if http_request is not None:
#             return http_request, trace_id, span_id, trace_sampled
# 
#     return None, None, None, False
# 
# Path: google/cloud/logging_v2/handlers/_monitored_resources.py
# def _create_app_engine_resource():
#     """Create a standardized App Engine resource.
#     Returns:
#         google.cloud.logging.Resource
#     """
#     zone = retrieve_metadata_server(_ZONE_ID)
#     project = retrieve_metadata_server(_PROJECT_NAME)
#     resource = Resource(
#         type="gae_app",
#         labels={
#             "project_id": project,
#             "module_id": os.environ.get(_GAE_SERVICE_ENV, ""),
#             "version_id": os.environ.get(_GAE_VERSION_ENV, ""),
#             "zone": zone if zone else "",
#         },
#     )
#     return resource
# 
# Path: google/cloud/logging_v2/handlers/transports/background_thread.py
# class BackgroundThreadTransport(Transport):
#     """Asynchronous transport that uses a background thread."""
# 
#     def __init__(
#         self,
#         client,
#         name,
#         *,
#         grace_period=_DEFAULT_GRACE_PERIOD,
#         batch_size=_DEFAULT_MAX_BATCH_SIZE,
#         max_latency=_DEFAULT_MAX_LATENCY,
#         resource=_GLOBAL_RESOURCE,
#         **kwargs,
#     ):
#         """
#         Args:
#             client (~logging_v2.client.Client):
#                 The Logging client.
#             name (str): The name of the lgoger.
#             grace_period (Optional[float]): The amount of time to wait for pending logs to
#                 be submitted when the process is shutting down.
#             batch_size (Optional[int]): The maximum number of items to send at a time in the
#                 background thread.
#             max_latency (Optional[float]): The amount of time to wait for new logs before
#                 sending a new batch. It is strongly recommended to keep this smaller
#                 than the grace_period. This means this is effectively the longest
#                 amount of time the background thread will hold onto log entries
#                 before sending them to the server.
#             resource (Optional[Resource|dict]): The default monitored resource to associate
#                 with logs when not specified
#         """
#         self.client = client
#         logger = self.client.logger(name, resource=resource)
#         self.worker = _Worker(
#             logger,
#             grace_period=grace_period,
#             max_batch_size=batch_size,
#             max_latency=max_latency,
#         )
#         self.worker.start()
# 
#     def send(self, record, message, **kwargs):
#         """Overrides Transport.send().
# 
#         Args:
#             record (logging.LogRecord): Python log record that the handler was called with.
#             message (str or dict): The message from the ``LogRecord`` after being
#                 formatted by the associated log formatters.
#             kwargs: Additional optional arguments for the logger
#         """
#         self.worker.enqueue(record, message, **kwargs)
# 
#     def flush(self):
#         """Submit any pending log records."""
#         self.worker.flush()


# Path: google/cloud/logging_v2/handlers/app_engine.py
import logging
import os
import warnings
from google.cloud.logging_v2.handlers._helpers import get_request_data
from google.cloud.logging_v2.handlers._monitored_resources import (
    _create_app_engine_resource,
)
from google.cloud.logging_v2.handlers.transports import BackgroundThreadTransport

        Args:
            client (~logging_v2.client.Client): The authenticated
                Google Cloud Logging client for this handler to use.
            name (Optional[str]): Name for the logger.
            transport (Optional[~logging_v2.transports.Transport]):
                The transport class. It should be a subclass
                of :class:`.Transport`. If unspecified,
                :class:`.BackgroundThreadTransport` will be used.
            stream (Optional[IO]): Stream to be used by the handler.

        """
        super(AppEngineHandler, self).__init__(stream)
        self.name = name
        self.client = client
        self.transport = transport(client, name)
        self.project_id = os.environ.get(
            _GAE_PROJECT_ENV_FLEX, os.environ.get(_GAE_PROJECT_ENV_STANDARD, "")
        )
        self.module_id = os.environ.get(_GAE_SERVICE_ENV, "")
        self.version_id = os.environ.get(_GAE_VERSION_ENV, "")
        self.resource = self.get_gae_resource()

        warnings.warn(_DEPRECATION_MSG, DeprecationWarning)

    def get_gae_resource(self):
        """Return the GAE resource using the environment variables.

        Returns:
            google.cloud.logging_v2.resource.Resource: Monitored resource for GAE.
        """

        return _create_app_engine_resource()