alaCarte Maps
Renderer for OpenStreetMap tiles
parser_logger.hpp
Go to the documentation of this file.
1 
21 #pragma once
22 #ifndef PARSER_LOGGER_HPP
23 #define PARSER_LOGGER_HPP
24 
25 
26 #include <boost/enable_shared_from_this.hpp>
27 #include <fstream>
28 
29 #include "settings.hpp"
30 
32  : public boost::enable_shared_from_this<ParserLogger>
33 {
34 public:
35  enum Category
36  {
39  };
40 
41  class LogStream
42  {
43  public:
44  LogStream(const shared_ptr<ParserLogger>& logger, Category cat);
45  LogStream(const LogStream& other);
46  ~LogStream();
47 
48  template<typename T>
49  LogStream& operator <<(const T& v)
50  {
51  value << v;
52  return *this;
53  }
54 
55  string logvalue() const;
56  private:
57  std::ostringstream value;
58  shared_ptr<ParserLogger> logger;
60  };
61 
62  ParserLogger(const string& parsedFile);
63 
66 
67  void warn(const string& str);
68  void error(const string& str);
69 private:
70  void logToStream(Category cat, const string& str);
71 
72  std::ofstream outputStream;
73  string filename;
74 };
75 
76 
77 
78 #endif
string logvalue() const
Returns the log value.
~LogStream()
Destroyes the log stream.
LogStream(const shared_ptr< ParserLogger > &logger, Category cat)
This file is part of alaCarte.
LogStream & operator<<(const T &v)
LogStream warnStream()
Returns a warn stream.
LogStream errorStream()
Returns a error stream.
void logToStream(Category cat, const string &str)
prints a message to the log
std::ofstream outputStream
std::ostringstream value
void warn(const string &str)
outputs an warn message
ParserLogger(const string &parsedFile)
Creates a new parse logger.
shared_ptr< ParserLogger > logger
void error(const string &str)
outputs an error message