Show
Ignore:
Timestamp:
08/06/08 14:35:12 (4 years ago)
Author:
mwhitworth
Message:

Add log levels to KePrint.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • Whitix/trunk/kernel/print.c

    r559 r823  
    1717 */ 
    1818 
     19#include <config.h> 
    1920#include <module.h> 
    2021#include <stdarg.h> 
    2122#include <string.h> 
    2223#include <typedefs.h> 
     24 
     25#include <i386/ioports.h> 
    2326 
    2427static void (*ConsoleOutput)(char* message, int length); 
     
    3134SYMBOL_EXPORT(KeSetOutput); 
    3235 
     36int logLevelUnknown=1; 
     37int currLogLevel=-1; 
     38 
    3339void KePrint(const char* message, ...) 
    3440{ 
    35         char buf[2048]; 
    36         int length; 
     41        char buf[1024]; 
     42        char outputBuf[1024]; 
     43        char* start; 
     44        int length=0; 
    3745        va_list args; 
    3846 
     
    4149        va_end(args); 
    4250 
    43         ConsoleOutput(buf, length); 
     51        length=0; 
     52 
     53        for (start=buf; *start; start++) 
     54        { 
     55                if (logLevelUnknown) 
     56                { 
     57                        /* Parse the beginning of the message to find out the log level. */ 
     58                        if (*start == '<') 
     59                        { 
     60                                currLogLevel=*(start+1)-'0'; 
     61 
     62                                /* Skip past the closing > */ 
     63                                start+=3; 
     64                        }else 
     65                                currLogLevel=1; 
     66 
     67                        logLevelUnknown=0; 
     68                } 
     69 
     70                if (currLogLevel <= KERN_LOG_LEVEL) 
     71                        outputBuf[length++]=*start; 
     72 
     73                if (*start == '\n') 
     74                        logLevelUnknown=1; 
     75        } 
     76 
     77        outputBuf[length]='\0'; 
     78 
     79        ConsoleOutput(outputBuf, length); 
    4480} 
    4581