Log.h
Go to the documentation of this file.
1 // (C) Copyright Renaud Detry 2007-2015.
2 // Distributed under the GNU General Public License and under the
3 // BSD 3-Clause License (See accompanying file LICENSE.txt).
4 
5 /** @file */
6 
7 #ifndef NUKLEI_LOG_H
8 #define NUKLEI_LOG_H
9 
10 #include <string>
11 #include <sstream>
12 #include <iostream>
13 #include <fstream>
14 #include <cassert>
15 #include <boost/thread/mutex.hpp>
16 
17 namespace nuklei {
18 
19  class Log
20  {
21  public:
22  static std::ostream& stream()
23  {
24  assert(out != NULL);
25  return *out;
26  }
27 
28  static void setOutput(const std::string &filename);
29  static void setOutput(std::ostream *stream);
30 
31  static std::string breakLines(const std::string &s);
32 
33  static void log(const char* file,
34  int line,
35  unsigned level,
36  const std::string &s);
37 
38 
39  typedef enum { NEVER = 0, FATAL, ERROR, WARN, INFO,
40  LOG, DEBUG, UNKNOWN } Type;
41  static const Type defaultType = LOG;
42  static const std::string TypeNames[];
43 
44  //This one should be moved elsewhere sometime.
45  static boost::mutex mutex_;
46  private:
47  static std::string msgColor;
48  static std::string errorColor;
49  static std::string nocolor;
50 
51  static std::ostream *out;
52  static std::ostream *outInstance;
53  };
54 
55 }
56 
57 #endif
Public namespace.
Definition: Color.cpp:9
Definition: Log.h:19
© Copyright 2007-2013 Renaud Detry.
Distributed under the terms of the GNU General Public License (GPL).
(See accompanying file LICENSE.txt or copy at http://www.gnu.org/copyleft/gpl.html.)
Revised Sun Sep 13 2020 19:10:06.