23 #include "pedigree/kernel/compiler.h" 25 #include "pedigree/kernel/Spinlock.h" 27 #include "pedigree/kernel/processor/types.h" 28 #include "pedigree/kernel/utilities/StaticString.h" 29 #include "pedigree/kernel/utilities/StaticCord.h" 30 #include "pedigree/kernel/time/Time.h" 38 #define SHOW_FILE_IN_LOGS 0 43 #define FILE_LOG(entry, level) \ 46 entry << level << __FILE__ << ":" << Dec << __LINE__ << Hex << " " \ 47 << __FUNCTION__ << " -- "; \ 50 #define FILE_LOG(entry, level) 53 #define LOG_AT_LEVEL(level, text, lock) \ 56 Log::LogEntry __log_macro_logentry; \ 57 FILE_LOG(__log_macro_logentry, level); \ 58 __log_macro_logentry << level << text; \ 59 Log::instance().addEntry(__log_macro_logentry, lock); \ 66 #define DEBUG_LOG(text) LOG_AT_LEVEL(Log::Debug, text, 1) 67 #define DEBUG_LOG_NOLOCK(text) LOG_AT_LEVEL(Log::Debug, text, 0) 69 #define DEBUG_LOG(text) 70 #define DEBUG_LOG_NOLOCK(text) 74 #define NOTICE(text) LOG_AT_LEVEL(Log::Notice, text, 1) 75 #define NOTICE_NOLOCK(text) LOG_AT_LEVEL(Log::Notice, text, 0) 78 #define WARNING(text) LOG_AT_LEVEL(Log::Warning, text, 1) 79 #define WARNING_NOLOCK(text) LOG_AT_LEVEL(Log::Warning, text, 0) 82 #define ERROR(text) LOG_AT_LEVEL(Log::Error, text, 1) 83 #define ERROR_NOLOCK(text) LOG_AT_LEVEL(Log::Error, text, 0) 92 LOG_AT_LEVEL(Log::Fatal, text, 1); \ 96 #define FATAL_NOLOCK(text) \ 99 LOG_AT_LEVEL(Log::Fatal, text, 0); \ 106 #define DEBUG_LOG(text) 107 #define DEBUG_LOG_NOLOCK(text) 109 #define NOTICE_NOLOCK(text) 110 #define WARNING(text) 111 #define WARNING_NOLOCK(text) 113 #define ERROR_NOLOCK(text) 115 #define FATAL_NOLOCK(text) 120 #define LOG_LENGTH 128 122 #ifdef HUGE_STATIC_LOG 124 #define LOG_ENTRIES ((1 << 21) / sizeof(LogEntry)) 127 #define LOG_ENTRIES ((1 << 16) / sizeof(LogEntry)) 130 #define LOG_CALLBACK_COUNT 16 152 typedef void (*BootProgressUpdateFn)(
const char *);
154 extern size_t g_BootProgressCurrent;
155 extern size_t g_BootProgressTotal;
156 extern BootProgressUpdateFn g_BootProgressUpdate;
158 extern void installSerialLogger();
175 virtual void callback(
const LogCord &cord) = 0;
270 return (*
this) << Hex << (reinterpret_cast<uintptr_t>(p))
271 << currentNumberType;
295 const LogEntry &getLatestEntry()
const;
297 void enableTimestamps();
298 void disableTimestamps();
323 size_t m_StaticEntryStart, m_StaticEntryEnd;
334 size_t m_nOutputCallbacks;
size_t m_HashMatchedCount
EXPORTED_PUBLIC void addEntry(const LogEntry &entry, bool lock=true, bool flush=true)
StaticString< LOG_LENGTH > str
Time::Timestamp m_LastTime
static TinyStaticString m_LineEnding
size_t getStaticEntryCount() const
Log & operator=(const Log &)
const StaticLogEntry & getStaticEntry(size_t n) const
StaticLogEntry m_StaticLog[LOG_ENTRIES]
SeverityLevel m_LastEntrySeverity
const DynamicLogEntry & getDynamicEntry(size_t n) const
LogEntry & operator<<(T *p)
EXPORTED_PUBLIC Log & operator<<(const LogEntry &entry)
EXPORTED_PUBLIC void removeCallback(LogCallback *pCallback)
size_t getDynamicEntryCount() const
static EXPORTED_PUBLIC Log m_Instance
LogCallback * m_OutputCallbacks[LOG_CALLBACK_COUNT]
static EXPORTED_PUBLIC Log & instance()
void flushEntry(bool lock=true)
#define LOG_CALLBACK_COUNT
static TinyStaticString m_DebugSeverityString
EXPORTED_PUBLIC void installCallback(LogCallback *pCallback, bool bSkipBacklog=false)
static NormalStaticString m_DedupeHead
NormalStaticString m_CachedTimestamp