Changeset 5a9f4d7 in mainline


Ignore:
Timestamp:
2010-07-27T16:45:43Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
571addd
Parents:
3629481
Message:

store kernel log output to /log/klog

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/klog/klog.c

    r3629481 r5a9f4d7  
    4343#include <event.h>
    4444#include <errno.h>
     45#include <str_error.h>
    4546#include <io/klog.h>
    4647
    47 #define NAME  "klog"
     48#define NAME       "klog"
     49#define LOG_FNAME  "/log/klog"
    4850
    4951/* Pointer to klog area */
    5052static wchar_t *klog;
    5153static size_t klog_length;
     54
     55static FILE *log;
    5256
    5357static void interrupt_received(ipc_callid_t callid, ipc_call_t *call)
     
    5862        size_t i;
    5963       
    60         for (i = klog_len - klog_stored; i < klog_len; i++)
    61                 putchar(klog[(klog_start + i) % klog_length]);
     64        for (i = klog_len - klog_stored; i < klog_len; i++) {
     65                wchar_t ch = klog[(klog_start + i) % klog_length];
     66               
     67                putchar(ch);
     68               
     69                if (log != NULL)
     70                        fprintf(log, "%lc", ch);
     71        }
     72       
     73        if (log != NULL) {
     74                fflush(log);
     75                fsync(fileno(log));
     76        }
    6277}
    6378
     
    91106        }
    92107       
     108        /*
     109         * Mode "a" would be definitively much better here, but it is
     110         * not well supported by the FAT driver.
     111         *
     112         */
     113        log = fopen(LOG_FNAME, "w");
     114        if (log == NULL)
     115                printf("%s: Unable to create log file %s (%s)\n", NAME, LOG_FNAME,
     116                    str_error(errno));
     117       
    93118        async_set_interrupt_received(interrupt_received);
    94119        klog_update();
Note: See TracChangeset for help on using the changeset viewer.