polish Log
[Tsunagari.git] / src / log.h
blobc45f1cd31760191baa5020a0326b3f907f373094
1 /******************************
2 ** Tsunagari Tile Engine **
3 ** log.h **
4 ** Copyright 2011 OmegaSDG **
5 ******************************/
7 #ifndef LOG_H
8 #define LOG_H
10 #include <iostream>
11 #include <string>
13 //! Logging Mode Enum
15 //! This enum defines the logging modes.
16 enum message_mode_t {
17 //! Only error messages are sent to the console.
18 MM_SILENT = 1,
19 //! Error and development messages are sent to the console.
20 MM_DEVELOPER,
21 //! All messages are sent to the console.
22 MM_DEBUG
25 //! This is a singleton that handles error messages.
26 class Log
28 public:
29 //! Set message mode. (SILENT, DEVELOPER, or DEBUG)
30 static void setMode(message_mode_t mode);
32 //! Send a message to the console.
33 /*!
34 @param domain the name of the message's origin (traditionally,
35 the name of the function we're in)
36 @param message the message to be sent
38 static void err(std::string domain, std::string message);
39 static void dev(std::string domain, std::string message);
40 static void dbg(std::string domain, std::string message);
42 //! Send a blank line to the console.
43 static void blank();
45 private:
46 //! Access to our singleton instance.
47 static Log* instance();
48 static std::string& rtrim(std::string& str);
50 //! Hide our constructor.
51 Log();
54 //! Our class instance.
55 static Log* pInstance;
57 //! Controls verbosity.
58 message_mode_t mode;
61 #endif