22#include "pedigree/kernel/Spinlock.h"
23#include "pedigree/kernel/compiler.h"
24#include "pedigree/kernel/process/WaitQueue.h"
25#include "pedigree/kernel/processor/types.h"
26#include "pedigree/kernel/time/Time.h"
27#include "pedigree/kernel/utilities/StaticCord.h"
28#include "pedigree/kernel/utilities/StaticString.h"
42#define LOG_AT_LEVEL(level, text, lock) \
44 Log::LogEntry __log_macro_logentry; \
45 __log_macro_logentry << level << text; \
47 __log_macro_logentry << Unlocked; \
48 Log::instance().addEntry(__log_macro_logentry, lock); \
55#define DEBUG_LOG(text) LOG_AT_LEVEL(Log::Debug, text, 1)
56#define DEBUG_LOG_NOLOCK(text) LOG_AT_LEVEL(Log::Debug, text, 0)
58#define DEBUG_LOG(text)
59#define DEBUG_LOG_NOLOCK(text)
63#define NOTICE(text) LOG_AT_LEVEL(Log::Notice, text, 1)
64#define NOTICE_NOLOCK(text) LOG_AT_LEVEL(Log::Notice, text, 0)
67#define WARNING(text) LOG_AT_LEVEL(Log::Warning, text, 1)
68#define WARNING_NOLOCK(text) LOG_AT_LEVEL(Log::Warning, text, 0)
71#define ERROR(text) LOG_AT_LEVEL(Log::Error, text, 1)
72#define ERROR_NOLOCK(text) LOG_AT_LEVEL(Log::Error, text, 0)
80 LOG_AT_LEVEL(Log::Fatal, text, 1); \
84#define FATAL_NOLOCK(text) \
86 LOG_AT_LEVEL(Log::Fatal, text, 0); \
94#define PEDANTRY WARNING
99#define DEBUG_LOG(text)
100#define DEBUG_LOG_NOLOCK(text)
102#define NOTICE_NOLOCK(text)
104#define WARNING_NOLOCK(text)
106#define ERROR_NOLOCK(text)
108#define FATAL_NOLOCK(text)
109#define PEDANTRY(text)
114#define LOG_LENGTH 128
117#define LOG_ENTRIES ((1 << 16) / sizeof(LogEntry))
119#define LOG_CALLBACK_COUNT 16
141typedef void (*BootProgressUpdateFn)(
const char*);
143extern size_t g_BootProgressCurrent;
144extern size_t g_BootProgressTotal;
145extern BootProgressUpdateFn g_BootProgressUpdate;
147extern void installSerialLogger();
162 virtual void callback(
const LogCord& cord,
bool locked =
true) = 0;
227 bool lockfree =
false;
229 bool showTimestamp =
true;
236 LogEntry& operator<<(
const char (&str)[N]) {
237 str.appendBytes(str, N);
245 str.appendBytes(s, s.length());
255 LogEntry& operator<<(
char* append_str);
258 LogEntry& operator<<(
bool b);
266 return (*
this) << Hex << (reinterpret_cast<uintptr_t>(p)) << currentNumberType;
290 EXPORTED_PUBLIC
size_t copyText(
char* buffer,
size_t capacity);
292 static constexpr size_t textCapacity() {
298 const LogEntry& getLatestEntry()
const;
300 void enableTimestamps();
301 void disableTimestamps();
303#if HOSTED && PEDIGREE_HOSTED_SMOKE_TESTS
304 using CallbackPinHook = void (*)(LogCallback* callback);
305 using EntrySnapshotHook = void (*)(
const LogEntry& entry);
307 EXPORTED_PUBLIC
static void setCallbackPinHook(CallbackPinHook hook);
308 EXPORTED_PUBLIC
static void setEntrySnapshotHook(EntrySnapshotHook hook);
348 void* currentCallbackOwner();
349 bool isCallbackContext(
void* owner);
359 size_t m_StaticEntryStart, m_StaticEntryEnd;
368 size_t m_nOutputCallbacks;
405#if HOSTED && PEDIGREE_HOSTED_SMOKE_TESTS
406 static CallbackPinHook m_CallbackPinHook;
407 static EntrySnapshotHook m_EntrySnapshotHook;
StaticLogEntry m_StaticLog[LOG_ENTRIES]
size_t getStaticEntryCount() const
size_t m_HashMatchedCount
NormalStaticString m_CachedTimestamp
static TinyStaticString m_DebugSeverityString
SeverityLevel m_LastEntrySeverity
EXPORTED_PUBLIC bool removeCallback(LogCallback *pCallback)
EXPORTED_PUBLIC void addEntry(const LogEntry &entry, bool lock=true)
const StaticLogEntry & getStaticEntry(size_t n) const
Log & operator=(const Log &)
static TinyStaticString m_LineEnding
static NormalStaticString m_DedupeHead
size_t getDynamicEntryCount() const
Time::Timestamp m_LastTime
static EXPORTED_PUBLIC Log & instance()
EXPORTED_PUBLIC bool installCallback(LogCallback *pCallback, bool bSkipBacklog=false)
const DynamicLogEntry & getDynamicEntry(size_t n) const
EXPORTED_PUBLIC size_t copyText(char *buffer, size_t capacity)
WaitQueue m_CallbackWaiters
static EXPORTED_PUBLIC Log m_Instance
#define LOG_CALLBACK_COUNT
LogEntry & operator<<(T n)
LogEntry & operator<<(T *p)
StaticString< LOG_LENGTH > str