The Pedigree Project
0.1
|
the kernel's log More...
#include <Log.h>
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 Log & | operator<< (const LogEntry &entry) |
EXPORTED_PUBLIC Log & | operator<< (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 StaticLogEntry & | getStaticEntry (size_t n) const |
const DynamicLogEntry & | getDynamicEntry (size_t n) const |
bool | echoToSerial () |
const LogEntry & | getLatestEntry () const |
void | enableTimestamps () |
void | disableTimestamps () |
Static Public Member Functions | |
static EXPORTED_PUBLIC Log & | instance () |
Public Attributes | |
Spinlock | m_Lock |
Private Member Functions | |
Log () | |
~Log () | |
Log (const Log &) | |
Log & | operator= (const Log &) |
const NormalStaticString & | getTimestamp () |
const TinyStaticString & | severityToString (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 |
LogCallback * | m_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 |
the kernel's log
Implements a kernel log that can be used to debug problems.
typedef LogEntry Log::StaticLogEntry |
enum Log::SeverityLevel |
|
private |
Default constructor - does nothing.
Definition at line 76 of file Log.cc.
References LOG_CALLBACK_COUNT, and m_OutputCallbacks.
|
private |
|
private |
Copy-constructor
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().
void Log::flushEntry | ( | bool | lock = true | ) |
Perform a flush.
Definition at line 378 of file Log.cc.
References Spinlock::acquire(), StaticString< N >::allowHashing(), Processor::breakpoint(), StaticString< N >::disableHashing(), Processor::id(), LOG_CALLBACK_COUNT, LOG_ENTRIES, m_Buffer, m_CachedTimestamp, m_DebugSeverityString, m_DedupeHead, m_HashMatchedCount, m_LastEntryHash, m_LastEntrySeverity, m_LastTime, m_LineEnding, m_Lock, m_OutputCallbacks, m_StaticEntries, m_StaticLog, m_Timestamps, panic(), Spinlock::release(), Log::LogEntry::severity, and Log::LogEntry::str.
Referenced by addEntry(), and operator<<().
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().
size_t Log::getDynamicEntryCount | ( | ) | const |
Get the number of dynamic entries in the log
Definition at line 230 of file Log.cc.
Referenced by LogViewer::execute().
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().
size_t Log::getStaticEntryCount | ( | ) | const |
Get the number of static entries in the log.
Definition at line 225 of file Log.cc.
References m_StaticEntries.
Referenced by LogViewer::execute().
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
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().
|
static |
Retrieves the static Log instance.
Definition at line 108 of file Log.cc.
References m_Instance.
Referenced by StreamingScreenLogger::callback(), LogViewer::execute(), BootIO::initialise(), and Debugger::start().
Adds an entry to the log.
Definition at line 352 of file Log.cc.
References m_Buffer.
Referenced by Log::LogEntry::operator<<().
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().
|
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<<().
|
private |
|
staticprivate |
|
staticprivate |
|
private |
If we should output to serial
Definition at line 330 of file Log.h.
Referenced by getDynamicEntry(), initialise1(), and initialise2().
|
private |
Number of entries that matched the last entry hash.
Definition at line 346 of file Log.h.
Referenced by flushEntry().
|
staticprivate |
|
private |
Last seen message hash (for cleaning up dupes).
Definition at line 340 of file Log.h.
Referenced by flushEntry().
|
private |
Last seen message severity (for cleaning up dupes).
Definition at line 343 of file Log.h.
Referenced by flushEntry().
|
private |
Last timestamp seen in getTimestamp().
Definition at line 352 of file Log.h.
Referenced by flushEntry().
|
staticprivate |
Log line ending string.
Definition at line 365 of file Log.h.
Referenced by flushEntry(), and installCallback().
Spinlock Log::m_Lock |
The lock
Definition at line 193 of file Log.h.
Referenced by flushEntry(), installCallback(), and removeCallback().
|
private |
Output callback list
Definition at line 333 of file Log.h.
Referenced by flushEntry(), installCallback(), Log(), and removeCallback().
|
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().
|
private |
Static buffer of log messages.
Definition at line 317 of file Log.h.
Referenced by flushEntry(), getDynamicEntry(), getStaticEntry(), and installCallback().
|
private |
Are timestamps enabled?
Definition at line 349 of file Log.h.
Referenced by flushEntry(), and installCallback().