net: udp sending data routine
[quarnos.git] / services / early_logger.cpp
blob71677db85a06225f3e10476f3962dc37d993203c
1 /* Quarn OS
3 * Early logger
5 * Copyright (C) 2008-2009 Pawel Dziepak
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 /* Implementation of a logger that can be used immediately after booting kernel.
24 * It does not uses any high-level kernel structures and objects, so it can be
25 * a good way to inform about their corruption. However it is not reccomended
26 * to use it after setting up "standard" tty logger.
29 #include "early_logger.h"
31 #include "server.h"
32 #include "manes/cds/creator.h"
33 #include "manes/cds/type.h"
34 #include "manes/manec.h"
36 #include "libs/colors.h"
38 using namespace manes;
39 using namespace manes::cds;
40 using namespace services;
43 early_logger::early_logger() {
44 output = manec::get()->get<resources::stream>("/console");
47 /* Print a log message. This logger prints everything on the screen regardless
48 * of its level. At the stage when it is used, all information is imported.
50 void early_logger::print(const string &message, log_level) {
51 assert("early_logger: empty message provided", message.null());
53 bool accept_colors = output.is<color_output>();
54 if (accept_colors)
55 output.cast<color_output>()->set_forecolor(color::white);
56 output->write(message.to_mem());
57 if (accept_colors)
58 output.cast<color_output>()->default_color();
61 void early_logger::register_type() {
62 manec::get()->register_type<early_logger>("early_logger", "service");