hw: ease usage of the kernel log

ref #989
This commit is contained in:
Martin Stein 2014-01-20 18:24:57 +01:00 committed by Norman Feske
parent eeb2d95b1f
commit 901b3e2bb4
5 changed files with 39 additions and 30 deletions

View File

@ -203,7 +203,7 @@ class Genode::Message_tpl
enum { NAME_SIZE = sizeof(name) };
size_t const data_size = raw_data_size + NAME_SIZE;
if (data_size > _max_data_size()) {
kernel_log() << __func__ << ": oversized message outgoing\n";
Kernel::log() << "oversized message outgoing\n";
raw_data_size = _max_data_size() - NAME_SIZE;
}
/* copy data */
@ -224,7 +224,7 @@ class Genode::Message_tpl
{
/* limit data size */
if (_data_size > buf_size) {
kernel_log() << __func__ << ": oversized message incoming\n";
Kernel::log() << "oversized message incoming\n";
_data_size = buf_size;
}
/* copy data */

View File

@ -1,5 +1,5 @@
/*
* \brief Print to kernel log output
* \brief Print to the standard output of the kernel
* \author Martin stein
* \date 2012-04-05
*/
@ -17,15 +17,17 @@
/* Genode includes */
#include <kernel/interface.h>
namespace Genode
namespace Kernel
{
/**
* Prints incoming streams to the kernel log output
* Prints incoming streams to the standard output of the kernel
*/
class Kernel_log
class Log
{
private:
/**
* Print an unsigned 4 bit integer as hexadecimal value
* Print an unsigned 4 bit integer x as hexadecimal value
*/
void _print_4bit_hex(unsigned char x) const
{
@ -35,24 +37,25 @@ namespace Genode
x += 48;
/* print ASCII char */
Kernel::print_char(x);
print_char(x);
}
public:
/**
* Print zero-terminated string
* Print a zero-terminated string s
*/
Kernel_log & operator << (char const * s)
Log & operator << (char const * s)
{
while (*s) Kernel::print_char(*s++);
while (*s) print_char(*s++);
if (*--s != '\n') { print_char(' '); }
return *this;
}
/**
* Print an unsigned integer as hexadecimal value
* Print an unsigned integer x as hexadecimal value
*/
Kernel_log & operator << (unsigned int const & x)
Log & operator << (unsigned int const x)
{
enum {
BYTE_WIDTH = 8,
@ -91,17 +94,23 @@ namespace Genode
_print_4bit_hex(c >> 4);
_print_4bit_hex(c);
}
print_char(' ');
return *this;
}
/**
* Print a pointer p as hexadecimal value
*/
Log & operator << (void * const p) { return *this << (unsigned)p; }
};
/**
* Give static 'Kernel_log' reference as target for common log output
* Return singleton kernel-log
*/
inline Kernel_log & kernel_log()
inline Log & log()
{
static Kernel_log _log;
return _log;
static Log s;
return s;
}
}

View File

@ -116,7 +116,7 @@ namespace Genode {
inline Range_allocator * region_alloc()
{
kernel_log() << __PRETTY_FUNCTION__ << ": Not implemented\n";
Kernel::log() << __PRETTY_FUNCTION__ << "not implemented\n";
while (1) ;
return 0;
}

View File

@ -175,7 +175,7 @@ Platform::Platform()
void Core_parent::exit(int exit_value)
{
kernel_log() << __PRETTY_FUNCTION__ << ": Not implemented\n";
Kernel::log() << __PRETTY_FUNCTION__ << "not implemented\n";
while (1) ;
}

View File

@ -62,7 +62,7 @@ Thread_base::Thread_base(const char * const label, size_t const stack_size)
Thread_base::~Thread_base()
{
kernel_log() << __PRETTY_FUNCTION__ << ": Not implemented\n";
Kernel::log() << __PRETTY_FUNCTION__ << "not implemented\n";
while (1) ;
}