Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/google/cloud/logging_v2/handlers/transports/base.py: 75%
8 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-08 06:45 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-08 06:45 +0000
1# Copyright 2016 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
15"""Module containing base class for logging transport."""
17from google.cloud.logging_v2.logger import _GLOBAL_RESOURCE
20class Transport(object):
21 """Base class for Google Cloud Logging handler transports.
23 Subclasses of :class:`Transport` must have constructors that accept a
24 client and name object, and must override :meth:`send`.
25 """
27 def __init__(self, client, name, resource=_GLOBAL_RESOURCE, **kwargs):
28 """
29 Args:
30 client (~logging_v2.client.Client):
31 The Logging client.
32 name (str): The name of the lgoger.
33 resource (Optional[Resource|dict]): The default monitored resource to associate
34 with logs when not specified
35 """
36 super().__init__()
38 def send(self, record, message, **kwargs):
39 """Transport send to be implemented by subclasses.
41 Args:
42 record (logging.LogRecord): Python log record that the handler was called with.
43 message (str or dict): The message from the ``LogRecord`` after being
44 formatted by the associated log formatters.
45 kwargs: Additional optional arguments for the logger
46 """
47 raise NotImplementedError
49 def flush(self):
50 """Submit any pending log records.
52 For blocking/sync transports, this is a no-op.
53 """