Content-Length: 325238 | pFad | http://github.com/googleapis/google-cloud-python/commit/17d6a26eaefa2343dba33b614d7d2c2c1e47a08e

C1 Logging: s/print/logging.info/ · googleapis/google-cloud-python@17d6a26 · GitHub
Skip to content

Commit 17d6a26

Browse 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

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

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

Lines 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)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/googleapis/google-cloud-python/commit/17d6a26eaefa2343dba33b614d7d2c2c1e47a08e

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy