* logging.c - Kernel Logging Service
*/
#include <acess.h>
+#include <adt.h>
+#define CACHE_MESSAGES 0
#define PRINT_ON_APPEND 1
#define USE_RING_BUFFER 1
#define RING_BUFFER_SIZE 4096
//Log("len = %i", len);
- #if USE_RING_BUFFER
+ #if USE_RING_BUFFER || !CACHE_MESSAGES
{
char buf[sizeof(tLogEntry)+len+1];
ent = (void*)buf;
ent->Level = Level;
ent->Length = len;
vsnprintf( ent->Data, len+1, Format, Args );
-
- #if USE_RING_BUFFER
+
+ #if CACHE_MESSAGES
+ # if USE_RING_BUFFER
{
#define LOG_HDR_LEN (14+1+2+8+2)
char newData[ LOG_HDR_LEN + len + 2 + 1 ];
gpLog_RingBuffer->Space = RING_BUFFER_SIZE; // Needed to init the buffer
RingBuffer_Write( gpLog_RingBuffer, newData, LOG_HDR_LEN + len + 2 );
}
- #else
+ # else
Mutex_Acquire( &glLog );
ent->Next = gLog.Tail;
gLog_Levels[Level].Tail = gLog_Levels[Level].Head = ent;
Mutex_Release( &glLog );
+ # endif
#endif
- #if PRINT_ON_APPEND
+ #if PRINT_ON_APPEND || !CACHE_MESSAGES
Log_Int_PrintMessage( ent );
#endif
- #if USE_RING_BUFFER
+ #if USE_RING_BUFFER || !CACHE_MESSAGES
}
#endif
}
void Log_Int_PrintMessage(tLogEntry *Entry)
{
SHORTLOCK( &glLogOutput );
- LogF("%s%014lli%s [%-8s] %s",
+ LogF("%s%014lli%s [%-8s] %i - %s",
csaLevelColours[Entry->Level],
Entry->Time,
csaLevelCodes[Entry->Level],
Entry->Ident,
+ Threads_GetTID(),
Entry->Data
);
LogF("\x1B[0m\r\n"); // Separate in case Entry->Data is too long
va_start(args, Message);
Log_AddEvent(Ident, LOG_LEVEL_KPANIC, Message, args);
va_end(args);
+ Panic("Log_KernelPanic - %s", Ident);
}
/**