/*
* kernelerror.{cc,hh} -- ErrorHandler subclass that saves errors for
* /proc/click/errors(XXX) and reports them with printk()
* Eddie Kohler, Nickolai Zeldovich
*
* Copyright (c) 1999-2001 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, subject to the conditions
* listed in the Click LICENSE file. These conditions include: you must
* preserve this copyright notice, and you cannot mention the copyright
* holders in advertising related to the Software without their permission.
* The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This
* notice is a summary of the Click LICENSE file; the license in that file is
* legally binding.
*/
#include <click/config.h>
#include "modulepriv.hh"
#include "kernelerror.hh"
#include <click/straccum.hh>
static StringAccum *all_errors = 0;
void
syslog_message(const String &message)
{
int pos = 0, nl;
while ((nl = message.find_left('\n', pos)) >= 0) {
String x = message.substring(pos, nl - pos);
printf("%s\n", x.c_str());
pos = nl + 1;
}
if (pos < message.length()) {
String x = message.substring(pos);
printf("%s\n", x.c_str());
}
}
void
KernelErrorHandler::handle_text(Seriousness seriousness, const String &message)
{
syslog_message(message);
if (all_errors)
*all_errors << message << "\n";
if (seriousness >= ERR_MIN_FATAL)
panic("KernelErrorHandler");
}
void
SyslogErrorHandler::handle_text(Seriousness, const String &message)
{
syslog_message(message);
}
syntax highlighted by Code2HTML, v. 0.9.1