Page Speed Optimization Libraries
1.13.35.1
|
#include "log_record.h"
Public Member Functions | |
AbstractLogRecord (AbstractMutex *mutex) | |
GoogleString | AppliedRewritersString () |
RewriterInfo * | NewRewriterInfo (const char *rewriter_id) |
void | SetRewriterLoggingStatus (const char *rewriter_id, RewriterApplication::Status status) |
void | SetRewriterLoggingStatus (const char *rewriter_id, const GoogleString &url, RewriterApplication::Status status) |
void | LogRewriterHtmlStatus (const char *rewriter_id, RewriterHtmlApplication::Status status) |
void | LogRewriterApplicationStatus (const char *rewriter_id, RewriterApplication::Status status) |
virtual LoggingInfo * | logging_info ()=0 |
void | LogImageBackgroundRewriteActivity (RewriterApplication::Status status, const GoogleString &url, const char *id, int original_size, int optimized_size, bool is_recompressed, ImageType original_image_type, ImageType optimized_image_type, bool is_resized, int original_width, int original_height, bool is_resized_using_rendered_dimensions, int resized_width, int resized_height) |
void | SetIsHtml (bool is_html) |
Atomically sets is_html_response in the logging proto. | |
virtual void | AddFoundPropertyToCohortInfo (int page_type, const GoogleString &cohort, const GoogleString &property)=0 |
virtual void | AddRetrievedPropertyToCohortInfo (int page_type, const GoogleString &cohort, const GoogleString &property)=0 |
virtual void | SetCacheStatusForCohortInfo (int page_type, const GoogleString &cohort, bool found, int key_state)=0 |
Updates the cohort info to update the cache key state. | |
void | SetIsOriginalResourceCacheable (bool cacheable) |
virtual void | LogImageRewriteActivity (const char *id, const GoogleString &url, RewriterApplication::Status status, bool is_image_inlined, bool is_critical_image, bool is_url_rewritten, int size, bool try_low_res_src_insertion, bool low_res_src_inserted, ImageType low_res_image_type, int low_res_data_size)=0 |
Log a RewriterInfo for the image rewrite filter. | |
void | LogJsDisableFilter (const char *id, bool has_pagespeed_no_defer) |
void | LogLazyloadFilter (const char *id, RewriterApplication::Status status, bool is_blacklisted, bool is_critical) |
bool | WriteLog () |
AbstractMutex * | mutex () |
void | SetRewriterInfoMaxSize (int x) |
void | SetAllowLoggingUrls (bool allow_logging_urls) |
void | SetLogUrlIndices (bool log_url_indices) |
void | SetNumHtmlCriticalImages (int num_html_critical_images) |
Sets the number of critical images in HTML. | |
void | SetNumCssCriticalImages (int num_css_critical_images) |
Sets the number of critical images in CSS. | |
virtual void | SetImageStats (int num_img_tags, int num_inlined_img_tags, int num_critical_images_used)=0 |
Sets image related statistics. | |
virtual void | SetResourceCounts (int num_external_css, int num_scripts)=0 |
Sets the number of external resources on an HTML page. | |
void | SetCriticalCssInfo (int critical_inlined_bytes, int original_external_bytes, int overhead_bytes) |
Sets critical CSS related byte counts (all uncompressed). | |
virtual void | LogDeviceInfo (int device_type, bool supports_image_inlining, bool supports_lazyload_images, bool supports_critical_images_beacon, bool supports_deferjs, bool supports_webp_in_place, bool supports_webp_rewritten_urls, bool supports_webplossless_alpha, bool is_bot)=0 |
Log information related to the user agent and device making the request. | |
void | LogIsXhr (bool is_xhr) |
Log whether the request is an XmlHttpRequest. | |
virtual void | SetBackgroundRewriteInfo (bool log_urls, bool log_url_indices, int max_rewrite_info_log_size) |
Sets initial information for background rewrite log. | |
virtual void | SetTimingInfo (const RequestTimingInfo &timing_info) |
Set timing information in the logging implementation. | |
Protected Member Functions | |
virtual bool | WriteLogImpl ()=0 |
RewriterInfo * | SetRewriterLoggingStatusHelper (const char *rewriter_id, const GoogleString &url, RewriterApplication::Status status) |
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 LoggingInfo instance, however.
|
explicit |
Construct a AbstractLogRecord with a new LoggingInfo proto and caller- supplied mutex. This class takes ownership of the mutex.
|
pure virtual |
Updated the cohort info to set the found to true for the given property.
Implemented in net_instaweb::LogRecord.
|
pure virtual |
Updated the cohort info to set the retrieved to true for the given property.
Implemented in net_instaweb::LogRecord.
GoogleString net_instaweb::AbstractLogRecord::AppliedRewritersString | ( | ) |
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.
|
pure virtual |
Implemented in net_instaweb::LogRecord.
void net_instaweb::AbstractLogRecord::LogImageBackgroundRewriteActivity | ( | RewriterApplication::Status | status, |
const GoogleString & | url, | ||
const char * | id, | ||
int | original_size, | ||
int | optimized_size, | ||
bool | is_recompressed, | ||
ImageType | original_image_type, | ||
ImageType | optimized_image_type, | ||
bool | is_resized, | ||
int | original_width, | ||
int | original_height, | ||
bool | is_resized_using_rendered_dimensions, | ||
int | resized_width, | ||
int | resized_height | ||
) |
Log image rewriting activity, which may not finish when the request processing is done. The outcome is a new log record with request type set to "BACKGROUND_REWRITE".
void net_instaweb::AbstractLogRecord::LogJsDisableFilter | ( | const char * | id, |
bool | has_pagespeed_no_defer | ||
) |
void net_instaweb::AbstractLogRecord::LogRewriterApplicationStatus | ( | const char * | rewriter_id, |
RewriterApplication::Status | status | ||
) |
Log the status of a rewriter application on a resource.
void net_instaweb::AbstractLogRecord::LogRewriterHtmlStatus | ( | const char * | rewriter_id, |
RewriterHtmlApplication::Status | status | ||
) |
Log the HTML level status for a filter. This should be called only once per filter, at the point where it is determined the filter is either active or not.
|
inline |
Return the mutex associated with this instance. Calling code should guard reads and writes of AbstractLogRecords
RewriterInfo* net_instaweb::AbstractLogRecord::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.
void net_instaweb::AbstractLogRecord::SetAllowLoggingUrls | ( | bool | allow_logging_urls | ) |
Sets whether urls should be logged. This could potentially generate a lot of logs data, so this should be switched on only for debugging.
void net_instaweb::AbstractLogRecord::SetIsOriginalResourceCacheable | ( | bool | cacheable | ) |
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::AbstractLogRecord::SetLogUrlIndices | ( | bool | log_url_indices | ) |
Sets whether URL indices should be logged for every rewriter application or not.
void net_instaweb::AbstractLogRecord::SetRewriterInfoMaxSize | ( | int | x | ) |
Sets the maximum number of RewriterInfo submessages that can accumulate in the LoggingInfo proto wrapped by this class.
void net_instaweb::AbstractLogRecord::SetRewriterLoggingStatus | ( | const char * | rewriter_id, |
RewriterApplication::Status | status | ||
) |
Creates a new rewriter logging submessage for |rewriter_id|, and sets status it.
|
inline |
Creates a new rewriter logging submessage for |rewriter_id|, sets status and the url index.
|
protected |
Helper function which creates a new rewriter logging submessage for |rewriter_id|, sets status and the url index. It is intended to be called only inside logging code.
bool net_instaweb::AbstractLogRecord::WriteLog | ( | ) |
Mutex-guarded log-writing operations. Derived classes should override *Impl methods. Returns false if the log write attempt failed.
|
protectedpure virtual |
Implements writing a log, base implementation is a no-op. Returns false if writing failed.
Implemented in net_instaweb::CopyOnWriteLogRecord, and net_instaweb::LogRecord.