File tree Expand file tree Collapse file tree 1 file changed +29
-19
lines changed Expand file tree Collapse file tree 1 file changed +29
-19
lines changed Original file line number Diff line number Diff line change 11#include < iostream>
22
3- #define LOG (x ) std::cout << x << std::endl
4-
5- class Player
3+ class Log
64{
75public:
8- int x, y;
9- int speed;
6+ const int LogLevelError = 0 ;
7+ const int LogLevelWarning = 1 ;
8+ const int LogLevelInfo = 2 ;
9+
10+ private:
11+ int m_LogLevel = LogLevelInfo;
1012
11- void Move (int xa, int ya)
13+ public:
14+ void SetLevel (int level)
1215 {
13- x += xa * speed;
14- y += ya * speed;
16+ m_LogLevel = level;
1517 }
16- };
1718
18- struct Vec2
19- {
20- float x, y;
19+ void Error (const char * message)
20+ {
21+ if (m_LogLevel >= LogLevelError)
22+ std::cout << " [ERROR]:" << message << std::endl;
23+ }
2124
22- void Add (const Vec2& other )
25+ void Warn (const char * message )
2326 {
24- x += other.x ;
25- y += other.y ;
27+ if (m_LogLevel >= LogLevelWarning)
28+ std::cout << " [WARNING]:" << message << std::endl;
29+ }
30+
31+ void Info (const char * message)
32+ {
33+ if (m_LogLevel >= LogLevelInfo)
34+ std::cout << " [INFO]:" << message << std::endl;
2635 }
2736};
2837
2938int main ()
3039{
31- Player player;
32- player.x = 5 ;
33- player.Move (1 , -1 );
34-
40+ Log log;
41+ log.SetLevel (log.LogLevelError );
42+ log.Warn (" Hello!" );
43+ log.Error (" Hello!" );
44+ log.Info (" Hello!" );
3545 std::cin.get ();
3646}
You can’t perform that action at this time.
0 commit comments