2121
2222import atexit
2323import logging
24+ import sys
2425import threading
2526import time
2627
@@ -195,7 +196,9 @@ def stop(self, grace_period=None):
195196 self ._queue .put_nowait (_WORKER_TERMINATOR )
196197
197198 if grace_period is not None :
198- print ('Waiting up to %d seconds.' % (grace_period ,))
199+ print (
200+ 'Waiting up to %d seconds.' % (grace_period ,),
201+ file = sys .stderr )
199202
200203 self ._thread .join (timeout = grace_period )
201204
@@ -216,12 +219,15 @@ def _main_thread_terminated(self):
216219 if not self ._queue .empty ():
217220 print (
218221 'Program shutting down, attempting to send %d queued log '
219- 'entries to Stackdriver Logging...' % (self ._queue .qsize (),))
222+ 'entries to Stackdriver Logging...' % (self ._queue .qsize (),),
223+ file = sys .stderr )
220224
221225 if self .stop (self ._grace_period ):
222- print ('Sent all pending logs.' )
226+ print ('Sent all pending logs.' , file = sys . stderr )
223227 else :
224- print ('Failed to send %d pending logs.' % (self ._queue .qsize (),))
228+ print (
229+ 'Failed to send %d pending logs.' % (self ._queue .qsize (),),
230+ file = sys .stderr )
225231
226232 def enqueue (self , record , message , resource = None , labels = None ):
227233 """Queues a log entry to be written by the background thread.
0 commit comments