The Pedigree Project  0.1
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Log Class Reference

the kernel's log More...

#include <Log.h>

+ Collaboration diagram for Log:

Classes

class  LogCallback
 
struct  LogEntry
 

Public Types

enum  SeverityLevel {
  Debug = 0, Notice, Warning, Error,
  Fatal
}
 
typedef LogEntry StaticLogEntry
 
typedef LogEntry DynamicLogEntry
 

Public Member Functions

void initialise1 ()
 
void initialise2 ()
 
EXPORTED_PUBLIC void installCallback (LogCallback *pCallback, bool bSkipBacklog=false)
 
EXPORTED_PUBLIC void removeCallback (LogCallback *pCallback)
 
EXPORTED_PUBLIC Logoperator<< (const LogEntry &entry)
 
EXPORTED_PUBLIC Logoperator<< (Modifier type)
 
EXPORTED_PUBLIC void addEntry (const LogEntry &entry, bool lock=true, bool flush=true)
 
void flushEntry (bool lock=true)
 
size_t getStaticEntryCount () const
 
size_t getDynamicEntryCount () const
 
const StaticLogEntrygetStaticEntry (size_t n) const
 
const DynamicLogEntrygetDynamicEntry (size_t n) const
 
bool echoToSerial ()
 
const LogEntrygetLatestEntry () const
 
void enableTimestamps ()
 
void disableTimestamps ()
 

Static Public Member Functions

static EXPORTED_PUBLIC Loginstance ()
 

Public Attributes

Spinlock m_Lock
 

Private Member Functions

 Log ()
 
 ~Log ()
 
 Log (const Log &)
 
Logoperator= (const Log &)
 
const NormalStaticStringgetTimestamp ()
 
const TinyStaticStringseverityToString (SeverityLevel level) const
 

Private Attributes

StaticLogEntry m_StaticLog [LOG_ENTRIES]
 
size_t m_StaticEntries
 
size_t m_StaticEntryStart
 
size_t m_StaticEntryEnd
 
StaticLogEntry m_Buffer
 
bool m_EchoToSerial
 
LogCallbackm_OutputCallbacks [LOG_CALLBACK_COUNT]
 
size_t m_nOutputCallbacks
 
uint64_t m_LastEntryHash
 
SeverityLevel m_LastEntrySeverity
 
size_t m_HashMatchedCount
 
bool m_Timestamps
 
Time::Timestamp m_LastTime
 
NormalStaticString m_CachedTimestamp
 

Static Private Attributes

static EXPORTED_PUBLIC Log m_Instance
 
static TinyStaticString m_DebugSeverityString
 
static TinyStaticString m_NoticeSeverityString
 
static TinyStaticString m_WarningSeverityString
 
static TinyStaticString m_ErrorSeverityString
 
static TinyStaticString m_FatalSeverityString
 
static TinyStaticString m_LineEnding
 
static NormalStaticString m_DedupeHead
 
static TinyStaticString m_DedupeTail
 

Detailed Description

the kernel's log

Implements a kernel log that can be used to debug problems.

Note
You should use the NOTICE, WARNING, ERROR and FATAL macros to write something into the log. Direct access to the log should only be needed to retrieve the entries from the log (within the debugger's log viewer for example).

Definition at line 166 of file Log.h.

Member Typedef Documentation

Type of a static log entry (no memory-management involved)

Definition at line 285 of file Log.h.

Member Enumeration Documentation

Severity level of the log entry

Definition at line 180 of file Log.h.

Constructor & Destructor Documentation

Log::Log ( )
private

Default constructor - does nothing.

Definition at line 76 of file Log.cc.

References LOG_CALLBACK_COUNT, and m_OutputCallbacks.

Log::~Log ( )
private

Default destructor - does nothing

Definition at line 101 of file Log.cc.

References addEntry().

Log::Log ( const Log )
private

Copy-constructor

Note
NOT implemented

Member Function Documentation

void Log::addEntry ( const LogEntry entry,
bool  lock = true,
bool  flush = true 
)

Adds an entry to the log and immediately flushes.

Definition at line 369 of file Log.cc.

References flushEntry(), and m_Buffer.

Referenced by ~Log().

+ Here is the caller graph for this function:

void Log::flushEntry ( bool  lock = true)
const Log::DynamicLogEntry & Log::getDynamicEntry ( size_t  n) const

Returns the (n - getStaticEntryCount())'th dynamic log entry

Definition at line 240 of file Log.cc.

References m_EchoToSerial, m_StaticEntries, and m_StaticLog.

Referenced by LogViewer::execute().

+ Here is the caller graph for this function:

size_t Log::getDynamicEntryCount ( ) const

Get the number of dynamic entries in the log

Returns
the number of dynamic entries in the log

Definition at line 230 of file Log.cc.

Referenced by LogViewer::execute().

+ Here is the caller graph for this function:

const Log::StaticLogEntry & Log::getStaticEntry ( size_t  n) const

Returns the n'th static log entry, counting from the start.

Definition at line 235 of file Log.cc.

References LOG_ENTRIES, and m_StaticLog.

Referenced by LogViewer::execute().

+ Here is the caller graph for this function:

size_t Log::getStaticEntryCount ( ) const

Get the number of static entries in the log.

Returns
the number of static entries in the log

Definition at line 225 of file Log.cc.

References m_StaticEntries.

Referenced by LogViewer::execute().

+ Here is the caller graph for this function:

void Log::initialise1 ( )

Initialises the Log

Definition at line 113 of file Log.cc.

References Vector< T >::begin(), Vector< T >::end(), and m_EchoToSerial.

void Log::initialise2 ( )

Initialises the default Log callback (to a serial port)

Definition at line 138 of file Log.cc.

References m_EchoToSerial.

void Log::installCallback ( LogCallback pCallback,
bool  bSkipBacklog = false 
)

Installs an output callback

Todo:
installCallback should return success/failure
Note
This could send a massive batch of log entries on the callback. If the callback isn't designed to handle big buffers this may fail.

Definition at line 146 of file Log.cc.

References LOG_CALLBACK_COUNT, LOG_ENTRIES, m_LineEnding, m_Lock, m_OutputCallbacks, m_StaticLog, and m_Timestamps.

Referenced by StreamingScreenLogger::callback().

+ Here is the caller graph for this function:

Log & Log::instance ( )
static

Retrieves the static Log instance.

Returns
instance of the log class

Definition at line 108 of file Log.cc.

References m_Instance.

Referenced by StreamingScreenLogger::callback(), LogViewer::execute(), BootIO::initialise(), and Debugger::start().

+ Here is the caller graph for this function:

Log & Log::operator<< ( const LogEntry entry)

Adds an entry to the log.

Definition at line 352 of file Log.cc.

References m_Buffer.

Referenced by Log::LogEntry::operator<<().

+ Here is the caller graph for this function:

Log & Log::operator<< ( Modifier  type)

Modifier

Definition at line 358 of file Log.cc.

References Flush, and flushEntry().

Log& Log::operator= ( const Log )
private

Assignment operator

Note
NOT implemented
void Log::removeCallback ( LogCallback pCallback)

Removes an output callback

Definition at line 209 of file Log.cc.

References LOG_CALLBACK_COUNT, m_Lock, and m_OutputCallbacks.

Referenced by StreamingScreenLogger::callback().

+ Here is the caller graph for this function:

Member Data Documentation

StaticLogEntry Log::m_Buffer
private

Temporary buffer which gets filled by calls to operator<<, and flushed by << Flush.

Definition at line 327 of file Log.h.

Referenced by addEntry(), flushEntry(), and operator<<().

NormalStaticString Log::m_CachedTimestamp
private

Cached timestamp string.

Definition at line 355 of file Log.h.

Referenced by flushEntry().

TinyStaticString Log::m_DebugSeverityString
staticprivate

Log severity tag strings.

Definition at line 358 of file Log.h.

Referenced by flushEntry().

NormalStaticString Log::m_DedupeHead
staticprivate

Dedupe information strings.

Definition at line 368 of file Log.h.

Referenced by flushEntry().

bool Log::m_EchoToSerial
private

If we should output to serial

Definition at line 330 of file Log.h.

Referenced by getDynamicEntry(), initialise1(), and initialise2().

size_t Log::m_HashMatchedCount
private

Number of entries that matched the last entry hash.

Definition at line 346 of file Log.h.

Referenced by flushEntry().

Log Log::m_Instance
staticprivate

The Log instance (singleton class)

Definition at line 337 of file Log.h.

Referenced by instance().

uint64_t Log::m_LastEntryHash
private

Last seen message hash (for cleaning up dupes).

Definition at line 340 of file Log.h.

Referenced by flushEntry().

SeverityLevel Log::m_LastEntrySeverity
private

Last seen message severity (for cleaning up dupes).

Definition at line 343 of file Log.h.

Referenced by flushEntry().

Time::Timestamp Log::m_LastTime
private

Last timestamp seen in getTimestamp().

Definition at line 352 of file Log.h.

Referenced by flushEntry().

TinyStaticString Log::m_LineEnding
staticprivate

Log line ending string.

Definition at line 365 of file Log.h.

Referenced by flushEntry(), and installCallback().

Spinlock Log::m_Lock

The lock

Note
this should only be acquired by the NOTICE, WARNING, ERROR and FATAL macros

Definition at line 193 of file Log.h.

Referenced by flushEntry(), installCallback(), and removeCallback().

LogCallback* Log::m_OutputCallbacks[LOG_CALLBACK_COUNT]
private

Output callback list

Definition at line 333 of file Log.h.

Referenced by flushEntry(), installCallback(), Log(), and removeCallback().

size_t Log::m_StaticEntries
private

Dynamic buffer of log messages Number of entries in the static log

Definition at line 321 of file Log.h.

Referenced by flushEntry(), getDynamicEntry(), and getStaticEntryCount().

StaticLogEntry Log::m_StaticLog[LOG_ENTRIES]
private

Static buffer of log messages.

Definition at line 317 of file Log.h.

Referenced by flushEntry(), getDynamicEntry(), getStaticEntry(), and installCallback().

bool Log::m_Timestamps
private

Are timestamps enabled?

Definition at line 349 of file Log.h.

Referenced by flushEntry(), and installCallback().


The documentation for this class was generated from the following files: