} tLogList;
// === PROTOTYPES ===
-void Log_AddEvent(char *Ident, int Level, char *Format, va_list Args);
+void Log_AddEvent(const char *Ident, int Level, const char *Format, va_list Args);
static void Log_Int_PrintMessage(tLogEntry *Entry);
-void Log_KernelPanic(char *Ident, char *Message, ...);
-void Log_Panic(char *Ident, char *Message, ...);
-void Log_Error(char *Ident, char *Message, ...);
-void Log_Warning(char *Ident, char *Message, ...);
-void Log_Notice(char *Ident, char *Message, ...);
-void Log_Log(char *Ident, char *Message, ...);
-void Log_Debug(char *Ident, char *Message, ...);
+//void Log_KernelPanic(const char *Ident, const char *Message, ...);
+//void Log_Panic(const char *Ident, const char *Message, ...);
+//void Log_Error(const char *Ident, const char *Message, ...);
+//void Log_Warning(const char *Ident, const char *Message, ...);
+//void Log_Notice(const char *Ident, const char *Message, ...);
+//void Log_Log(const char *Ident, const char *Message, ...);
+//void Log_Debug(const char *Ident, const char *Message, ...);
// === EXPORTS ===
EXPORT(Log_Panic);
EXPORT(Log_Debug);
// === GLOBALS ===
-tSpinlock glLog;
-tSpinlock glLogOutput;
+tShortSpinlock glLogOutput;
#if USE_RING_BUFFER
Uint8 gaLog_RingBufferData[sizeof(tRingBuffer)+RING_BUFFER_SIZE];
tRingBuffer *gpLog_RingBuffer = (void*)gaLog_RingBufferData;
#else
+tMutex glLog;
tLogList gLog;
tLogList gLog_Levels[NUM_LOG_LEVELS];
#endif
/**
* \brief Adds an event to the log
*/
-void Log_AddEvent(char *Ident, int Level, char *Format, va_list Args)
+void Log_AddEvent(const char *Ident, int Level, const char *Format, va_list Args)
{
int len;
tLogEntry *ent;
#endif
ent->Time = now();
strncpy(ent->Ident, Ident, 8);
+ ent->Ident[8] = '\0';
ent->Level = Level;
ent->Length = len;
vsnprintf( ent->Data, len+1, Format, Args );
{
#define LOG_HDR_LEN (14+1+2+8+2)
char newData[ LOG_HDR_LEN + len + 2 + 1 ];
+ char _ident[9];
+ strncpy(_ident, Ident, 9);
sprintf( newData, "%014lli%s [%+8s] ",
ent->Time, csaLevelCodes[Level], Ident);
strcpy( newData + LOG_HDR_LEN, ent->Data );
RingBuffer_Write( gpLog_RingBuffer, newData, LOG_HDR_LEN + len + 2 );
}
#else
- LOCK( &glLog );
+ Mutex_Acquire( &glLog );
ent->Next = gLog.Tail;
if(gLog.Head)
else
gLog_Levels[Level].Tail = gLog_Levels[Level].Head = ent;
- RELEASE( &glLog );
+ Mutex_Release( &glLog );
#endif
#if PRINT_ON_APPEND
*/
void Log_Int_PrintMessage(tLogEntry *Entry)
{
- LOCK( &glLogOutput );
+ SHORTLOCK( &glLogOutput );
LogF("%s%014lli%s [%+8s] %s\x1B[0m\r\n",
csaLevelColours[Entry->Level],
Entry->Time,
Entry->Ident,
Entry->Data
);
- RELEASE( &glLogOutput );
+ SHORTREL( &glLogOutput );
}
/**
* \brief KERNEL PANIC!!!!
*/
-void Log_KernelPanic(char *Ident, char *Message, ...)
+void Log_KernelPanic(const char *Ident, const char *Message, ...)
{
va_list args;
va_start(args, Message);
/**
* \brief Panic Message - Driver Unrecoverable error
*/
-void Log_Panic(char *Ident, char *Message, ...)
+void Log_Panic(const char *Ident, const char *Message, ...)
{
va_list args;
va_start(args, Message);
/**
* \brief Error Message - Recoverable Error
*/
-void Log_Error(char *Ident, char *Message, ...)
+void Log_Error(const char *Ident, const char *Message, ...)
{
va_list args;
va_start(args, Message);
/**
* \brief Warning Message - Something the user should know
*/
-void Log_Warning(char *Ident, char *Message, ...)
+void Log_Warning(const char *Ident, const char *Message, ...)
{
va_list args;
/**
* \brief Notice Message - Something the user might like to know
*/
-void Log_Notice(char *Ident, char *Message, ...)
+void Log_Notice(const char *Ident, const char *Message, ...)
{
va_list args;
va_start(args, Message);
/**
* \brief Log Message - Possibly useful information
*/
-void Log_Log(char *Ident, char *Message, ...)
+void Log_Log(const char *Ident, const char *Message, ...)
{
va_list args;
va_start(args, Message);
/**
* \brief Debug Message - Only a developer would want this info
*/
-void Log_Debug(char *Ident, char *Message, ...)
+void Log_Debug(const char *Ident, const char *Message, ...)
{
va_list args;
va_start(args, Message);