Python 2.7 has reached end of support
and will be
deprecated
on January 31, 2026. After deprecation, you won't be able to deploy Python 2.7
applications, even if your organization previously used an organization policy to
re-enable deployments of legacy runtimes. Your existing Python
2.7 applications will continue to run and receive traffic after their
deprecation date. We recommend that
you
migrate to the latest supported version of Python.
Stay organized with collections
Save and categorize content based on your preferences.
google.appengine.api.logservice.logsutil module
Summary
Utility methods for working with logs.
Contents
- class google.appengine.api.logservice.logsutil.LoggingRecord(level, created, message, source_location)source
-
Bases: object
A record with all logging information.
A record that came through the Python logging infrastructure that has various
metadata in addition to the message itself.
Note: the record may also come from stderr or logservice.write if the message
matches the classic format used by streaming logservice.
- google.appengine.api.logservice.logsutil.ParseLogEntry(entry)source
Parses a single log entry emitted by app_logging.AppLogsHandler.
Parses a log entry of the form LOG <level> <timestamp> <message> where the
level is in the range [0, 4]. If the entry is not of that form, take the whole
entry to be the message. Null characters in the entry are replaced by
newlines.
Parametersentry – The log entry to parse.
ReturnsA (timestamp, level, message, source_location) tuple.
- google.appengine.api.logservice.logsutil.ParseLogs(logs)source
Parses a str containing newline separated log entries.
Parses a series of log entries in the form LOG <level> <timestamp> <message>
where the level is in the range [0, 4]. Null characters in the entry are
replaced by newlines.
Parameterslogs – A string containing the log entries.
ReturnsA list of (timestamp, level, message, source_location) tuples.
- google.appengine.api.logservice.logsutil.RecordFromLine(line)source
Create the correct type of record based on what the line looks like.
With the classic streaming API, we did not distinguish between a message
that came through the logging infrastructure and one that came through stderr
or logservice.write but had been written to look like it came from logging.
Note that this code does not provide 100% accuracy with the old stream
service. In the past, they could have written:
sys.stderr.write(‘LOG %d %d’ % (level, time))
sys.stderr.write(‘ %s’ % message)
and that would have magically turned into a single full record. Trying to
handle every single corner case seems like a poor use of time.
Parametersline – a single line written to stderr or logservice.write.
ReturnsThe appropriate type of record.
- google.appengine.api.logservice.logsutil.RequestID()source
-
Returns the ID of the current request assigned by App Engine.
- class google.appengine.api.logservice.logsutil.StderrRecord(message)source
-
Bases: object
A record with just a message.
A record that came from stderr or logservice.write where only a message
is available.
- google.appengine.api.logservice.logsutil.Stripnl(message)source
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-06-16 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-16 UTC."],[[["\u003cp\u003eThe \u003ccode\u003egoogle.appengine.api.logservice.logsutil\u003c/code\u003e module provides utility methods for processing log data within the Google App Engine environment.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eLoggingRecord\u003c/code\u003e class represents a log entry from the Python logging infrastructure, including metadata like level, timestamp, message, and source location.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eParseLogEntry\u003c/code\u003e function parses a single log entry into a tuple of timestamp, level, message, and source location, handling different log entry formats and replacing null characters.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eParseLogs\u003c/code\u003e function processes a string containing multiple newline-separated log entries, returning a list of parsed log entry tuples.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eRecordFromLine\u003c/code\u003e function distinguishes between messages from the logging infrastructure versus those from \u003ccode\u003estderr\u003c/code\u003e or \u003ccode\u003elogservice.write\u003c/code\u003e, creating an appropriate log record type, and \u003ccode\u003eStderrRecord\u003c/code\u003e represents a log entry from the latter source, with just a message.\u003c/p\u003e\n"]]],[],null,[]]