Reorder README
[purplehaze.git] / src / log.cpp
blob24a7689598dd51ba5e13b57b11184d4612dfe0f5
1 /* Copyright (C) 2007-2012 Vincent Ollivier
3 * Purple Haze is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * Purple Haze is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include <iostream>
18 #include <fstream>
20 #include "log.h"
23 Log& Log::icmd(Log& log)
25 std::cout << "bip";
26 log << "test";
27 log.cout.stream << 123 << "<< ";
28 return log;
32 Log& Log::to(Stream s)
34 switch (s) {
35 case COUT:
36 cout.state = true;
37 file.state = false;
38 break;
39 case FILE:
40 cout.state = false;
41 file.state = true;
42 break;
43 case BOTH:
44 cout.state = true;
45 file.state = true;
46 break;
48 return *this;
51 Log& Log::operator<<(const LogDirection &dir)
53 if (file.state && file.stream.is_open()) {
54 switch (dir) {
55 case IN:
56 file.stream << ">> ";
57 break;
58 case OUT:
59 file.stream << "<< ";
60 break;
61 case DEBUG:
62 file.stream << "## ";
63 break;
66 return *this;