Usermode/Libs - x86_64 port in progress
[tpg/acess2.git] / Kernel / logging.c
index 225ce53..c00746a 100644 (file)
@@ -47,15 +47,15 @@ typedef struct sLogList
 }      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);
@@ -80,7 +80,7 @@ tLogList      gLog_Levels[NUM_LOG_LEVELS];
 /**
  * \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;
@@ -102,6 +102,7 @@ void Log_AddEvent(char *Ident, int Level, char *Format, va_list Args)
        #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 );
@@ -110,7 +111,9 @@ void Log_AddEvent(char *Ident, int Level, char *Format, va_list Args)
        {
                #define LOG_HDR_LEN     (14+1+2+8+2)
                char    newData[ LOG_HDR_LEN + len + 2 + 1 ];
-               sprintf( newData, "%014lli%s [%+8s] ",
+               char    _ident[9];
+               strncpy(_ident, Ident, 9);
+               sprintf( newData, "%014lli%s [%-8s] ",
                        ent->Time, csaLevelCodes[Level], Ident);
                strcpy( newData + LOG_HDR_LEN, ent->Data );
                strcpy( newData + LOG_HDR_LEN + len, "\r\n" );
@@ -150,20 +153,21 @@ void Log_AddEvent(char *Ident, int Level, char *Format, va_list Args)
 void Log_Int_PrintMessage(tLogEntry *Entry)
 {
        SHORTLOCK( &glLogOutput );
-       LogF("%s%014lli%s [%+8s] %s\x1B[0m\r\n",
+       LogF("%s%014lli%s [%-8s] %s",
                csaLevelColours[Entry->Level],
                Entry->Time,
                csaLevelCodes[Entry->Level],
                Entry->Ident,
                Entry->Data
                );
+       LogF("\x1B[0m\r\n");    // Separate in case Entry->Data is too long
        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);
@@ -174,7 +178,7 @@ void Log_KernelPanic(char *Ident, char *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);
@@ -185,7 +189,7 @@ void Log_Panic(char *Ident, char *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);
@@ -196,7 +200,7 @@ void Log_Error(char *Ident, char *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;
        
@@ -208,7 +212,7 @@ void Log_Warning(char *Ident, char *Message, ...)
 /**
  * \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);
@@ -219,7 +223,7 @@ void Log_Notice(char *Ident, char *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);
@@ -230,7 +234,7 @@ void Log_Log(char *Ident, char *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);

UCC git Repository :: git.ucc.asn.au