diff --git a/base-hw/include/base/native_types.h b/base-hw/include/base/native_types.h index 3db5f418f..c1e80c9a8 100644 --- a/base-hw/include/base/native_types.h +++ b/base-hw/include/base/native_types.h @@ -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 */ diff --git a/base-hw/include/kernel/log.h b/base-hw/include/kernel/log.h index 4690c8183..2c1a94cb4 100644 --- a/base-hw/include/kernel/log.h +++ b/base-hw/include/kernel/log.h @@ -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,42 +17,45 @@ /* Genode includes */ #include -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 { - /** - * Print an unsigned 4 bit integer as hexadecimal value - */ - void _print_4bit_hex(unsigned char x) const - { - /* decode to ASCII char */ - x &= 0x0f; - if (x > 9) x += 39; - x += 48; + private: - /* print ASCII char */ - Kernel::print_char(x); - } + /** + * Print an unsigned 4 bit integer x as hexadecimal value + */ + void _print_4bit_hex(unsigned char x) const + { + /* decode to ASCII char */ + x &= 0x0f; + if (x > 9) x += 39; + x += 48; + + /* print ASCII char */ + 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; } } diff --git a/base-hw/src/core/include/platform.h b/base-hw/src/core/include/platform.h index 4d48e4402..d3931aeb3 100644 --- a/base-hw/src/core/include/platform.h +++ b/base-hw/src/core/include/platform.h @@ -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; } diff --git a/base-hw/src/core/platform.cc b/base-hw/src/core/platform.cc index 995e7c9ea..664a2ca65 100644 --- a/base-hw/src/core/platform.cc +++ b/base-hw/src/core/platform.cc @@ -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) ; } diff --git a/base-hw/src/core/thread.cc b/base-hw/src/core/thread.cc index 85dab8540..72cce376c 100644 --- a/base-hw/src/core/thread.cc +++ b/base-hw/src/core/thread.cc @@ -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) ; }