|
The Pedigree Project 0.1
|
the kernel's log More...
#include <Log.h>
Collaboration diagram for Log:Classes | |
| struct | CallbackPin |
| struct | CallbackSlot |
| 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 bool | installCallback (LogCallback *pCallback, bool bSkipBacklog=false) |
| EXPORTED_PUBLIC bool | removeCallback (LogCallback *pCallback) |
| EXPORTED_PUBLIC void | addEntry (const LogEntry &entry, 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 |
| EXPORTED_PUBLIC size_t | copyText (char *buffer, size_t capacity) |
| bool | echoToSerial () |
| const LogEntry & | getLatestEntry () const |
| void | enableTimestamps () |
| void | disableTimestamps () |
Static Public Member Functions | |
| static EXPORTED_PUBLIC Log & | instance () |
| static constexpr size_t | textCapacity () |
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 |
| size_t | snapshotCallbacks (CallbackPin pins[LOG_CALLBACK_COUNT]) |
| bool | pinCallback (CallbackSlot *slot, CallbackPin &pin) |
| bool | callbackEnabled (const CallbackPin &pin) |
| void | releaseCallback (CallbackPin &pin) |
| void | dispatchCallbacks (CallbackPin pins[LOG_CALLBACK_COUNT], size_t count, const LogCord &message, bool locked) |
| void | dispatchCallback (CallbackSlot *slot, const LogCord &message, bool locked) |
| void * | currentCallbackOwner () |
| bool | isCallbackContext (void *owner) |
| void | clearCallback (CallbackSlot *slot) |
Private Attributes | |
| StaticLogEntry | m_StaticLog [LOG_ENTRIES] |
| size_t | m_StaticEntries |
| size_t | m_StaticEntryStart |
| size_t | m_StaticEntryEnd |
| bool | m_EchoToSerial |
| WaitQueue | m_CallbackWaiters |
| CallbackSlot | m_OutputCallbacks [LOG_CALLBACK_COUNT] |
| CallbackPin * | m_ActiveCallbackPins |
| 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::DynamicLogEntry |
| typedef LogEntry Log::StaticLogEntry |
| enum Log::SeverityLevel |
|
private |
Default constructor - does nothing.
Definition at line 85 of file Log.cc.
References LOG_CALLBACK_COUNT.
|
private |
Default destructor - does nothing
Definition at line 109 of file Log.cc.
References addEntry(), and NoTimestamp.
|
private |
Copy-constructor
| void Log::addEntry | ( | const LogEntry & | entry, |
| bool | lock = true |
||
| ) |
Adds an entry to the log and immediately flushes.
Definition at line 612 of file Log.cc.
References Spinlock::acquire(), ProcessorBase::breakpoint(), EMIT_IF, Machine::getSerial(), LOG_CALLBACK_COUNT, LOG_ENTRIES, m_DedupeHead, m_HashMatchedCount, m_LastEntryHash, m_LastEntrySeverity, m_LineEnding, m_Lock, m_StaticEntries, m_StaticLog, m_Timestamps, panic(), and Spinlock::release().
Referenced by Debugger::start(), and ~Log().
Here is the caller graph for this function:
|
private |
|
private |
| size_t Log::copyText | ( | char * | buffer, |
| size_t | capacity | ||
| ) |
Copies the newest log text without consuming entries or invoking callbacks.
Definition at line 454 of file Log.cc.
References getStaticEntry(), m_Lock, m_StaticEntries, and Log::LogEntry::str.
|
private |
|
private |
| const Log::DynamicLogEntry & Log::getDynamicEntry | ( | size_t | n | ) | const |
Returns the (n - getStaticEntryCount())'th dynamic log entry
Definition at line 450 of file Log.cc.
References m_StaticLog.
| size_t Log::getDynamicEntryCount | ( | ) | const |
| const Log::LogEntry & Log::getLatestEntry | ( | ) | const |
| const Log::StaticLogEntry & Log::getStaticEntry | ( | size_t | n | ) | const |
Returns the n'th static log entry, counting from the start.
Definition at line 446 of file Log.cc.
References LOG_ENTRIES, and m_StaticLog.
Referenced by copyText().
Here is the caller graph for this function:| size_t Log::getStaticEntryCount | ( | ) | const |
Get the number of static entries in the log.
Definition at line 438 of file Log.cc.
References m_StaticEntries.
|
private |
| void Log::initialise1 | ( | ) |
| void Log::initialise2 | ( | ) |
Initialises the default Log callback (to a serial port)
Definition at line 138 of file Log.cc.
References EMIT_IF, and m_EchoToSerial.
| bool Log::installCallback | ( | LogCallback * | pCallback, |
| bool | bSkipBacklog = false |
||
| ) |
Installs an output callback.
A callback may only be registered once. Returns false for a null, duplicate, or full registration.
Definition at line 145 of file Log.cc.
References Log::LogEntry::lockfree, LOG_CALLBACK_COUNT, LOG_ENTRIES, m_CallbackWaiters, m_LineEnding, m_Lock, m_StaticEntries, m_StaticLog, m_Timestamps, Log::LogEntry::severity, and Log::LogEntry::str.
|
static |
Retrieves the static Log instance.
Definition at line 117 of file Log.cc.
References m_Instance.
Referenced by Debugger::start().
Here is the caller graph for this function:
|
private |
|
private |
| bool Log::removeCallback | ( | LogCallback * | pCallback | ) |
Closes a callback registration and drains committed invocations.
Returns true once no invocation can still use the callback. A live target cannot be drained from callback context, so admission is closed and false retains the registration for a later external retry. An idle target may be removed immediately from any context.
Definition at line 228 of file Log.cc.
References ProcessorBase::getInterrupts(), ProcessorBase::information(), LOG_CALLBACK_COUNT, and m_CallbackWaiters.
|
private |
|
private |
|
inlinestaticconstexpr |
|
private |
|
private |
|
private |
Callback registrations and their committed invocation pins.
Definition at line 368 of file Log.h.
Referenced by installCallback(), and removeCallback().
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
private |
If we should output to serial
Definition at line 365 of file Log.h.
Referenced by initialise1(), and initialise2().
|
staticprivate |
|
staticprivate |
|
private |
Number of entries that matched the last entry hash.
Definition at line 383 of file Log.h.
Referenced by addEntry().
|
staticprivate |
|
private |
Last seen message hash (for cleaning up dupes).
Definition at line 377 of file Log.h.
Referenced by addEntry().
|
private |
Last seen message severity (for cleaning up dupes).
Definition at line 380 of file Log.h.
Referenced by addEntry().
|
private |
|
staticprivate |
Log line ending string.
Definition at line 402 of file Log.h.
Referenced by addEntry(), and installCallback().
| Spinlock Log::m_Lock |
The lock
Definition at line 175 of file Log.h.
Referenced by addEntry(), copyText(), and installCallback().
|
staticprivate |
|
private |
|
private |
Dynamic buffer of log messages Number of entries in the static log
Definition at line 360 of file Log.h.
Referenced by addEntry(), copyText(), getStaticEntryCount(), and installCallback().
|
private |
Static buffer of log messages.
Definition at line 356 of file Log.h.
Referenced by addEntry(), getDynamicEntry(), getStaticEntry(), and installCallback().
|
private |
Are timestamps enabled?
Definition at line 386 of file Log.h.
Referenced by addEntry(), and installCallback().
|
staticprivate |