]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/loader/server/src/log.h
083b58f1f8d2443fb50b9cf289d51edceba7546d
[l4.git] / l4 / pkg / loader / server / src / log.h
1 /*
2  * (c) 2008-2009 Alexander Warg <warg@os.inf.tu-dresden.de>
3  *     economic rights: Technische Universität Dresden (Germany)
4  *
5  * This file is part of TUD:OS and distributed under the terms of the
6  * GNU General Public License 2.
7  * Please see the COPYING-GPL-2 file for details.
8  */
9 #pragma once
10
11 #include <l4/sys/capability>
12 #include <l4/cxx/ipc_server>
13 #include <l4/cxx/string>
14
15 #include "local_service.h"
16 #include <cstring>
17
18 namespace Ldr {
19
20 class Log : public L4::Server_object
21 {
22 private:
23   enum { Max_tag = 8 };
24   char _tag[Max_tag];
25   unsigned char _l;
26   unsigned char _color;
27   bool _in_line;
28
29 public:
30   Log() : _l(0), _color(0), _in_line(false) {}
31   void set_tag(cxx::String const &tag)
32   {
33     _l = cxx::min<unsigned long>(tag.len(), Max_tag);
34     memcpy(_tag, tag.start(), _l);
35   }
36
37   void set_color(unsigned char color)
38   { _color = color; }
39
40   char const *tag() const { return _tag; }
41   unsigned char color() const { return _color; }
42
43   int dispatch(l4_umword_t obj, L4::Ipc_iostream &ios);
44
45   static int color_value(cxx::String const &col);
46   virtual ~Log() {}
47 };
48 }