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 17d6a26

Browse filesBrowse files
author
Helen Koike
committed
Logging: s/print/logging.info/
The function print sends the output to stdout disturbing the output of the application. Use logging instead which sends the logs to stderr by default or to the destination configured by the aplication.
1 parent 696b307 commit 17d6a26
Copy full SHA for 17d6a26

File tree

Expand file treeCollapse file tree

1 file changed

+5
-6
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-6
lines changed

‎logging/google/cloud/logging/handlers/transports/background_thread.py

Copy file name to clipboardExpand all lines: logging/google/cloud/logging/handlers/transports/background_thread.py
+5-6Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
Uses a background worker to log to Stackdriver Logging asynchronously.
1818
"""
1919

20-
from __future__ import print_function
21-
2220
import atexit
2321
import logging
2422
import threading
@@ -195,7 +193,7 @@ def stop(self, grace_period=None):
195193
self._queue.put_nowait(_WORKER_TERMINATOR)
196194

197195
if grace_period is not None:
198-
print('Waiting up to %d seconds.' % (grace_period,))
196+
logging.info('Waiting up to %d seconds.' % (grace_period,))
199197

200198
self._thread.join(timeout=grace_period)
201199

@@ -214,14 +212,15 @@ def _main_thread_terminated(self):
214212
return
215213

216214
if not self._queue.empty():
217-
print(
215+
logging.info(
218216
'Program shutting down, attempting to send %d queued log '
219217
'entries to Stackdriver Logging...' % (self._queue.qsize(),))
220218

221219
if self.stop(self._grace_period):
222-
print('Sent all pending logs.')
220+
logging.info('Sent all pending logs.')
223221
else:
224-
print('Failed to send %d pending logs.' % (self._queue.qsize(),))
222+
logging.info(
223+
'Failed to send %d pending logs.' % (self._queue.qsize(),))
225224

226225
def enqueue(self, record, message, resource=None, labels=None):
227226
"""Queues a log entry to be written by the background thread.

0 commit comments

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