Page Speed Optimization Libraries  1.3.25.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Protected Member Functions
net_instaweb::LogRecord Class Reference

#include "log_record.h"

List of all members.

Public Member Functions

 LogRecord (AbstractMutex *mutex)
void LogAppliedRewriter (const char *rewriter_id)
GoogleString AppliedRewritersString ()
RewriterInfo * NewRewriterInfo (const char *rewriter_id)
void SetRewriterLoggingStatus (RewriterInfo *rewriter_info, int status)
virtual LoggingInfo * logging_info ()
void SetIsHtml (bool is_html)
 Atomically sets is_html_response in the logging proto.
int AddPropertyCohortInfo (const GoogleString &cohort)
 Adds a new cohort info with the given cohort name and returns its index.
void AddFoundPropertyToCohortInfo (int index, const GoogleString &property)
void SetCacheStatusForCohortInfo (int index, bool found, int key_state)
void SetDeviceAndCacheTypeForCohortInfo (int index, int device_type, int cache_type)
void SetBlinkRequestFlow (int flow)
void SetIsOriginalResourceCacheable (bool cacheable)
void SetTimingRequestStartMs (int64 ms)
void SetTimingHeaderFetchMs (int64 ms)
void SetTimingFetchMs (int64 ms)
int64 GetTimingFetchMs ()
void SetTimingProcessingTimeMs (int64 ms)
void UpdateTimingInfoWithFetchStartTime (int64 start_time_ms)
void SetBlinkInfo (const GoogleString &user_agent)
 Override SetBlinkInfoImpl if necessary.
void LogImageRewriteActivity (const char *id, int status, bool is_image_inlined, bool is_critical_image, bool try_low_res_src_insertion, bool low_res_src_inserted, int low_res_data_size)
 Log a RewriterInfo for the image rewrite filter.
void LogJsDisableFilter (const char *id, int status, bool has_pagespeed_no_defer)
bool WriteLog ()
AbstractMutexmutex ()
void SetRewriterInfoMaxSize (int x)

Protected Member Functions

 LogRecord ()
void set_mutex (AbstractMutex *m)
virtual void LogAppliedRewriterImpl (const char *rewriter_id)
virtual RewriterInfo * NewRewriterInfoImpl (const char *rewriter_id, int status)
virtual void SetBlinkInfoImpl (const GoogleString &user_agent)
 Implements setting Blink-specific log information; base impl is a no-op.
virtual bool WriteLogImpl ()

Detailed Description

This class is a wrapper around a protobuf used to collect logging information. It also provides a simple aggregation mechanism for collecting the ids of applied rewriters.

Care and feeding of log records: (1) All logging must be done through log records. No class should have static members of any logging proto class. Log records can either create the logging protos, or will take ownership of them. (2) All access and manipulation of log data must be guarded by the log record's mutex. Commonly repeated logging operations should be factored into functions in this class (and be so guarded therein). (3) In most cases, log records should be created and owned by request contexts. Subclasses may wrap some other type of protobuf; they must still provide access to a LogRecord instance, however.


Constructor & Destructor Documentation

Construct a LogRecord with a new LoggingInfo proto and caller- supplied mutex. This class takes ownership of the mutex.

Non-initializing default constructor for subclasses. Subclasses that invoke this constructor should implement and call their own initializer that instantiates the wrapped logging proto and calls set_mutex with a valid Mutex object.


Member Function Documentation

void net_instaweb::LogRecord::AddFoundPropertyToCohortInfo ( int  index,
const GoogleString property 
)

Updates the cohort info at the specified index, to include the given property in the last of properties found in the cache.

For compatibility with older logging methods, returns a comma-joined string concatenating the sorted coalesced rewriter ids of APPLIED_OK entries in the rewriter_info array. Each id will appear once in the string if any number of successful rewrites for that id have been logged.

void net_instaweb::LogRecord::LogAppliedRewriter ( const char *  rewriter_id)

Log a rewriter (identified by an id string) as having been sucessfully applied to the request being logged.

virtual void net_instaweb::LogRecord::LogAppliedRewriterImpl ( const char *  rewriter_id) [protected, virtual]

Implementation methods for subclasses to override. Implements logging an applied rewriter.

virtual LoggingInfo* net_instaweb::LogRecord::logging_info ( ) [virtual]

Return the LoggingInfo proto wrapped by this class. Calling code must guard any reads and writes to this using mutex().

Return the mutex associated with this instance. Calling code should guard reads and writes of LogRecords

RewriterInfo* net_instaweb::LogRecord::NewRewriterInfo ( const char *  rewriter_id)

Create a new rewriter logging submessage for |rewriter_id|, returning a pointer to it for later access. Note that this can return NULL if the size of rewriter_info has grown too large. It is the caller's responsibility to handle this safely.

Mutex-guarded log mutation convenience methods. The rule of thumb is that if a single-field update to a logging proto occurs multiple times, it should be factored out into a method on this class.

void net_instaweb::LogRecord::SetCacheStatusForCohortInfo ( int  index,
bool  found,
int  key_state 
)

Updates the cohort info at the specified index, to indicate whether it was a cache hit.

void net_instaweb::LogRecord::SetDeviceAndCacheTypeForCohortInfo ( int  index,
int  device_type,
int  cache_type 
)

Updates the cohort info at the specified index with the device and cache type.

Sets the maximum number of RewriterInfo submessages that can accumulate in the LoggingInfo proto wrapped by this class.

void net_instaweb::LogRecord::SetRewriterLoggingStatus ( RewriterInfo *  rewriter_info,
int  status 
)

Sets status on a RewriterInfo with updates to AppliedRewriters. Calling code must lock mutex().

Sets time_to_start_fetch_ms in the TimingInfo submessage as an offset from timing_info.request_start_ms (|start_time_ms| is an absolute time value and is converted into the offset). If request_start_ms is unset, this is a silent no-op. This may be called several times in sucession, for example in the case of retried fetches. In that case, if time_to_start_fetch_ms has already been set in the log record, this is again a silent no-op.

Mutex-guarded log-writing operations. Derived classes should override Impl methods. Returns false if the log write attempt failed.

virtual bool net_instaweb::LogRecord::WriteLogImpl ( ) [inline, protected, virtual]

Implements writing a log, base implementation is a no-op. Returns false if writing failed.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines