Page Speed Optimization Libraries
1.2.24.1
|
#include "log_record.h"
Public Member Functions | |
LogRecord (AbstractMutex *mutex) | |
void | LogAppliedRewriter (const char *rewriter_id) |
void | Finalize () |
virtual LoggingInfo * | logging_info () |
void | SetBlinkRequestFlow (int flow) |
void | SetIsOriginalResourceCacheable (bool cacheable) |
void | SetTimingRequestStartMs (int64 ms) |
void | SetTimingFetchMs (int64 ms) |
bool | WriteLog () |
bool | WriteLogForBlink (const GoogleString &user_agent) |
bool | WriteLogWhileLocked () |
bool | WriteLogForBlinkWhileLocked (const GoogleString &user_agent) |
AbstractMutex * | mutex () |
Protected Member Functions | |
LogRecord () | |
void | set_mutex (AbstractMutex *m) |
GoogleString | ConcatenatedRewriterString () |
virtual void | LogAppliedRewriterImpl (const char *rewriter_id) |
virtual void | FinalizeImpl () |
Implements finalization. | |
virtual bool | WriteLogImpl () |
virtual bool | WriteLogForBlinkImpl (const GoogleString &user_agent) |
bool | finalized () |
True if Finalize() has been called. mutex_ guards this. | |
FRIEND_TEST (LogRecordTest, NoAppliedRewriters) |
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.
net_instaweb::LogRecord::LogRecord | ( | AbstractMutex * | mutex | ) | [explicit] |
Construct a LogRecord with a new LoggingInfo proto and caller- supplied mutex. This class takes ownership of the mutex.
net_instaweb::LogRecord::LogRecord | ( | ) | [protected] |
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.
GoogleString net_instaweb::LogRecord::ConcatenatedRewriterString | ( | ) | [protected] |
Returns a comma-joined string concatenating the contents of applied_rewriters_
void net_instaweb::LogRecord::Finalize | ( | ) |
This should be called when all logging activity on the log record is complete. If a subclass of this class uses other aggregate data structures or other intermediates before writing to the wrapped data structure, it should do those writes in FinalizeImpl. mutex_ guards this.
void net_instaweb::LogRecord::LogAppliedRewriter | ( | const char * | rewriter_id | ) |
Log a rewriter (identified by an id string) as having been applied to the request being logged. These ids will be aggregated and written to the protobuf when Finalize() is called.
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().
AbstractMutex* net_instaweb::LogRecord::mutex | ( | ) | [inline] |
Return the mutex associated with this instance. Calling code should guard reads and writes of LogRecords
void net_instaweb::LogRecord::SetBlinkRequestFlow | ( | int | flow | ) |
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.
bool net_instaweb::LogRecord::WriteLog | ( | ) |
Mutex-guarded log-writing operations. Derived classes should override Impl methods. Returns false if the log write attempt failed.
bool net_instaweb::LogRecord::WriteLogForBlink | ( | const GoogleString & | user_agent | ) |
Update the log record with Blink-specific information, then write the log as if WriteLog() was called.
virtual bool net_instaweb::LogRecord::WriteLogForBlinkImpl | ( | const GoogleString & | user_agent | ) | [inline, protected, virtual] |
Implements writing the Blink log, base implementation is a no-op. Returns false if writing 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.
If log-writing needs to occur in the context of an existing lock, these methods may be used. Returns false if write attempt failed.