void test_Logger(){ { Logger lg; lg.Log(LOG_WARN, "Test logger"); lg.Debug("logger debug"); lg.Fatal("Fatal test [%s] [%d]", "args", 1); lg.SetHandler("test_log"); lg.SetLevel(LOG_ALL); lg.Info("info test [%s]", "args"); Logger* lg_ptr = Logger::GetLogger("test"); lg_ptr->Error("You can see me in file test"); Logger* lg_ptr2 = Logger::GetLogger(); lg_ptr2->Error("You can see me in console"); } { LOG(LOG_DEBUG, "log debug info: %s", "Hello"); } { SetLogger(LOG_WARN, "test_logger.log"); LOG(LOG_DEBUG, "DEBUG NO SEE, you should not see this"); LOG(LOG_ERROR, "ERROR, you should know"); LOG(LOG_WARN, "WARN, you should see this"); } { SetLogger(LOG_ALL); LOG(LOG_DEBUG, "DEBUG [%d], you should see this", LOG_DEBUG); LOG(LOG_WARN, "LOG_WARN [%d], you should see this", LOG_WARN); LOG(LOG_ERROR, "LOG_ERROR [%d], you should see this", LOG_ERROR); LOG(LOG_FATAL, "LOG_FATAL [%d], you should see this", LOG_FATAL); } }
int set_log_level(int level) { return g_logger.SetLevel(level); }