File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -75,13 +75,15 @@ def do_something_later(key, amount):
7575from __future__ import unicode_literals
7676
7777import datetime
78+ import logging
7879import os
7980import pickle
8081import types
8182
8283from google .cloud import tasks_v2
8384from google .protobuf import timestamp_pb2
8485
86+ _DEFAULT_LOG_LEVEL = logging .INFO
8587_DEFAULT_URL = '/_tasks/deferred'
8688_DEFAULT_QUEUE = 'default'
8789
@@ -102,6 +104,17 @@ class InvalidTaskError(Error):
102104 """The parameters, headers, or method of the task is invalid."""
103105
104106
107+ def set_log_level (log_level ): # pragma: no cover
108+ """Sets the log level deferred will log to in normal circumstances.
109+
110+ Args:
111+ log_level: one of logging log levels, e.g. logging.DEBUG,
112+ logging.INFO, etc.
113+ """
114+ global _DEFAULT_LOG_LEVEL
115+ _DEFAULT_LOG_LEVEL = log_level
116+
117+
105118def run (data ):
106119 """Unpickle and execute a task.
107120
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ def abort(status):
3636 for k , v in six .iteritems (environ )
3737 if k .upper ().startswith ('HTTP_X_APPENGINE_' )
3838 ]
39- logger .info ( ', ' .join (headers ))
39+ logger .log ( deferred . _DEFAULT_LOG_LEVEL , ', ' .join (headers ))
4040
4141 content_length = int (environ .get ('CONTENT_LENGTH' , 0 ))
4242 data = environ ['wsgi.input' ].read (content_length )
You can’t perform that action at this time.
0 commit comments