Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6843a3a

Browse filesBrowse files
fix: Add submodule imports for handlers to logging alias (#117)
1 parent e704f28 commit 6843a3a
Copy full SHA for 6843a3a

File tree

Expand file treeCollapse file tree

4 files changed

+112
-1
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+112
-1
lines changed
+27Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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.
14+
15+
"""Python :mod:`logging` handlers for Google Cloud Logging."""
16+
17+
from google.cloud.logging_v2.handlers.app_engine import AppEngineHandler
18+
from google.cloud.logging_v2.handlers.container_engine import ContainerEngineHandler
19+
from google.cloud.logging_v2.handlers.handlers import CloudLoggingHandler
20+
from google.cloud.logging_v2.handlers.handlers import setup_logging
21+
22+
__all__ = [
23+
"AppEngineHandler",
24+
"CloudLoggingHandler",
25+
"ContainerEngineHandler",
26+
"setup_logging",
27+
]
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2017 Google LLC All Rights Reserved.
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.
14+
15+
from google.cloud.logging_v2.handlers.middleware.request import RequestMiddleware
16+
17+
__all__ = ["RequestMiddleware"]
+28Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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.
14+
15+
"""Transport classes for Python logging integration.
16+
Currently two options are provided, a synchronous transport that makes
17+
an API call for each log statement, and an asynchronous handler that
18+
sends the API using a :class:`~google.cloud.logging.logger.Batch` object in
19+
the background.
20+
"""
21+
22+
from google.cloud.logging_v2.handlers.transports.base import Transport
23+
from google.cloud.logging_v2.handlers.transports.sync import SyncTransport
24+
from google.cloud.logging_v2.handlers.transports.background_thread import (
25+
BackgroundThreadTransport,
26+
)
27+
28+
__all__ = ["BackgroundThreadTransport", "SyncTransport", "Transport"]

‎tests/unit/test_logging_shim.py

Copy file name to clipboardExpand all lines: tests/unit/test_logging_shim.py
+40-1Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
class TestLoggingShim(unittest.TestCase):
20-
def test_shim_matches_logging_v2(self):
20+
def test_root_shim_matches_logging_v2(self):
2121
from google.cloud import logging
2222
from google.cloud import logging_v2
2323

@@ -26,4 +26,43 @@ def test_shim_matches_logging_v2(self):
2626
for name in logging.__all__:
2727
found = getattr(logging, name)
2828
expected = getattr(logging_v2, name)
29+
if name == "handlers":
30+
# handler has separate shim
31+
self.assertTrue(found)
32+
self.assertIs(type(found), type(expected))
33+
else:
34+
# other attributes should be identical
35+
self.assertIs(found, expected)
36+
37+
def test_handler_shim_matches_logging_v2(self):
38+
from google.cloud.logging import handlers
39+
from google.cloud.logging_v2 import handlers as handlers_2
40+
41+
self.assertEqual(handlers.__all__, handlers_2.__all__)
42+
43+
for name in handlers.__all__:
44+
found = getattr(handlers, name)
45+
expected = getattr(handlers_2, name)
46+
self.assertIs(found, expected)
47+
48+
def test_middleware_shim_matches_logging_v2(self):
49+
from google.cloud.logging.handlers import middleware
50+
from google.cloud.logging_v2.handlers import middleware as middleware_2
51+
52+
self.assertEqual(middleware.__all__, middleware_2.__all__)
53+
54+
for name in middleware.__all__:
55+
found = getattr(middleware, name)
56+
expected = getattr(middleware_2, name)
57+
self.assertIs(found, expected)
58+
59+
def test_transports_shim_matches_logging_v2(self):
60+
from google.cloud.logging.handlers import transports
61+
from google.cloud.logging_v2.handlers import transports as transports_2
62+
63+
self.assertEqual(transports.__all__, transports_2.__all__)
64+
65+
for name in transports.__all__:
66+
found = getattr(transports, name)
67+
expected = getattr(transports_2, name)
2968
self.assertIs(found, expected)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.