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.

IsBlank()source
IsComplete()source
Tuple()source
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.

Parameters

entry -- The log entry to parse.

Returns

A (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.

Parameters

logs -- A string containing the log entries.

Returns

A 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 throught 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.

Parameters

line -- a single line written to stderr or logservice.write.

Returns

The 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.

IsBlank()source
IsComplete()source
Tuple()source
created
level
source_location
google.appengine.api.logservice.logsutil.Stripnl(message)source

Send feedback about...

App Engine standard environment for Python