Changeset 748 for Whitix/branches

Show
Ignore:
Timestamp:
07/08/08 15:42:38 (5 months ago)
Author:
mwhitworth
Message:

Add log levels.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • Whitix/branches/fs/kernel/print.c

    r559 r748  
    1717 */ 
    1818 
     19#include <config.h> 
    1920#include <module.h> 
    2021#include <stdarg.h> 
     
    3132SYMBOL_EXPORT(KeSetOutput); 
    3233 
     34int logLevelUnknown=1; 
     35int currLogLevel=-1; 
     36 
    3337void KePrint(const char* message, ...) 
    3438{ 
    35         char buf[2048]; 
    36         int length; 
     39        char buf[1024]; 
     40        char outputBuf[1024]; 
     41        char* start; 
     42        int length=0; 
    3743        va_list args; 
    3844 
     
    4147        va_end(args); 
    4248 
    43         ConsoleOutput(buf, length); 
     49        length=0; 
     50 
     51        for (start=buf; *start; start++) 
     52        { 
     53                if (logLevelUnknown) 
     54                { 
     55                        /* Parse the beginning of the message to find out the log level. */ 
     56                        if (*start == '<') 
     57                        { 
     58                                currLogLevel=*(start+1)-'0'; 
     59 
     60                                /* Skip past the closing > */ 
     61                                start+=3; 
     62                        }else 
     63                                currLogLevel=1; 
     64 
     65                        logLevelUnknown=0; 
     66                } 
     67 
     68                if (currLogLevel <= KERN_LOG_LEVEL) 
     69                        outputBuf[length++]=*start; 
     70 
     71                if (*start == '\n') 
     72                        logLevelUnknown=1; 
     73        } 
     74 
     75        outputBuf[length]='\0'; 
     76 
     77        ConsoleOutput(outputBuf, length); 
    4478} 
    4579