Skip to content

Commit

Permalink
refactor: modify codes as review suggests
Browse files Browse the repository at this point in the history
  • Loading branch information
ysde committed Mar 6, 2021
1 parent ae0fca5 commit 93be238
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions google/cloud/logging_v2/handlers/_helpers.py
Expand Up @@ -33,7 +33,7 @@
_PROTOCOL_HEADER = "SERVER_PROTOCOL"


def format_stackdriver_json(record, message, json_ensure_ascii):
def format_stackdriver_json(record, message):
"""Helper to format a LogRecord in in Stackdriver fluentd format.
Returns:
Expand All @@ -48,7 +48,7 @@ def format_stackdriver_json(record, message, json_ensure_ascii):
"severity": record.levelname,
}

return json.dumps(payload, ensure_ascii=json_ensure_ascii)
return json.dumps(payload, ensure_ascii=False)


def get_request_data_from_flask():
Expand Down
5 changes: 2 additions & 3 deletions google/cloud/logging_v2/handlers/container_engine.py
Expand Up @@ -31,7 +31,7 @@ class ContainerEngineHandler(logging.StreamHandler):
(GKE) fluentd plugin, so that metadata such as log level are properly set.
"""

def __init__(self, *, name=None, stream=None, json_ensure_ascii=True):
def __init__(self, *, name=None, stream=None):
"""
Args:
name (Optional[str]): The name of the custom log in Cloud Logging.
Expand All @@ -40,7 +40,6 @@ def __init__(self, *, name=None, stream=None, json_ensure_ascii=True):
"""
super(ContainerEngineHandler, self).__init__(stream=stream)
self.name = name
self.json_ensure_ascii = json_ensure_ascii

def format(self, record):
"""Format the message into JSON expected by fluentd.
Expand All @@ -52,4 +51,4 @@ def format(self, record):
str: A JSON string formatted for GKE fluentd.
"""
message = super(ContainerEngineHandler, self).format(record)
return format_stackdriver_json(record, message, self.json_ensure_ascii)
return format_stackdriver_json(record, message)

0 comments on commit 93be238

Please sign in to comment.