Google APIs Client Library for C++
|
Specialized HttpScribe that produces JSON transcripts. More...
#include "client/transport/json_scribe.h"
Public Member Functions | |
JsonScribe (HttpScribeCensor *censor, DataWriter *writer, bool compact=true) | |
Constructor. | |
virtual | ~JsonScribe () |
Standard destructor. | |
virtual void | Checkpoint () |
Implements base Checkpoint method. | |
Static Public Attributes | |
static const char | kStartTime [] |
static const char | kMaxSnippet [] |
static const char | kEndTime [] |
static const char | kMessages [] |
The JSON object tag for the message sequence. | |
static const char | kMethod [] |
static const char | kUrl [] |
static const char | kHttpCode [] |
The HTTP response code, if any (int). | |
static const char | kStatusCode [] |
The transport util::Status::error_code value (int). | |
static const char | kStatusMessage [] |
The transport util::Status::error_message value (string). | |
static const char | kSendMicros [] |
Timestamp request was sent in microseconds since the epoch (int64). | |
static const char | kResponseMicros [] |
Timestamp response was received in microseconds since the epoch (int64). | |
static const char | kErrorMicros [] |
Timestamp of transport error in microseconds since the epoch (int64). | |
static const char | kRequest [] |
static const char | kResponse [] |
static const char | kPayload [] |
These are fields within the request and response dictionaries. | |
static const char | kPayloadSize [] |
static const char | kPayloadCensored [] |
static const char | kHeaders [] |
Protected Member Functions | |
virtual Entry * | NewEntry (const HttpRequest *request) |
Returns an entry that produces the individual JSON transcript for the request. |
Specialized HttpScribe that produces JSON transcripts.
The scribe writes JSON directly to the writer. It does not proovide an interactive interface to interpret the JSON it is writing. In order to see the events, you must look at the writer.
The implementation of this class may stream directly to the writer, in which case it may not be well-formed if it did not finish properly (e.g. it is still scribing or the process crashed). If that is the case, you may need to append the closing brackets and braces to make it well formed if you wish to read it back as json.
The transcript has the following JSON structure: { kStartTime : datetime kMaxSnippet: int64 kMessages : [ { kUrl : string kHttpCode : int # none or 0 if no response kStatusCode : int # transport error, if any kStatusMessage : string # transport error, if any kRequest : { kHeaders : [ string : string # name, value pairs string : string ] kBytes : string kSize : int64 kCensored : bool } kResponse : { (same as request but for response data) } ] kEndTime : datetime }
The individual fields are documented as class constants. Each constant also documents the JSON format for the values.
JsonScribe | ( | HttpScribeCensor * | censor, |
DataWriter * | writer, | ||
bool | compact = true |
||
) |
Constructor.
[in] | censor | The caller retains ownership. |
[in] | writer | Ownership is passed to the scribe. This writer will store the transcript. |
[in] | compact | If truen then write compact json, otherwise stylized. |
virtual ~JsonScribe | ( | ) | [virtual] |
Standard destructor.
This will finish the JSON and flush the writer to make a well formed JSON document transcript.
virtual void Checkpoint | ( | ) | [virtual] |
Implements base Checkpoint method.
Implements HttpScribe.
virtual Entry* NewEntry | ( | const HttpRequest * | request | ) | [protected, virtual] |
Returns an entry that produces the individual JSON transcript for the request.
Implements HttpEntryScribe.
const char kEndTime[] [static] |
const char kErrorMicros[] [static] |
Timestamp of transport error in microseconds since the epoch (int64).
const char kHeaders[] [static] |
const char kHttpCode[] [static] |
The HTTP response code, if any (int).
If this tag is not present, or the value is 0, then a response was not received. This could be because of a transport error in which case the kStatusCode and kStatusMessage fields should be present. Otherwise it means that a response was not yet recorded for whatever reason including the transcript was finished before the request completed.
const char kMaxSnippet[] [static] |
const char kMessages[] [static] |
The JSON object tag for the message sequence.
The message sequence is a JSON array object where each element in the array is a flat dictionary containing the per-request attributes.
const char kMethod[] [static] |
const char kPayload[] [static] |
These are fields within the request and response dictionaries.
const char kPayloadCensored[] [static] |
const char kPayloadSize[] [static] |
const char kRequest[] [static] |
const char kResponse[] [static] |
const char kResponseMicros[] [static] |
Timestamp response was received in microseconds since the epoch (int64).
const char kSendMicros[] [static] |
Timestamp request was sent in microseconds since the epoch (int64).
const char kStartTime[] [static] |
const char kStatusCode[] [static] |
The transport util::Status::error_code value (int).
An error here indicates a transport error when sending the request. The response was either never received or the request was never sent.
Note that the status codes that specific errors produce is not yet well defined so may change from release to release. The StatusMessage will be of more value if you are physically inspecting these messages.
A value of 0 indicates everything was ok. This is the only well defined value that will not change in future releases. If this field is not present, then the transport status is assumed to be OK.
const char kStatusMessage[] [static] |
The transport util::Status::error_message value (string).
If this is present and not empty then it gives an explanation for the transport status. This is usually an error but not necessarily. The kStatusCode field will indicate whether it is ok or not.
The message values are intended to be human readable and may change from release to release.
const char kUrl[] [static] |