|
|
@@ -1,16 +1,16 @@
|
|
|
-#include "logutils.h"
|
|
|
+#include "log.h"
|
|
|
#include "util/print.h"
|
|
|
#include "util/time.h"
|
|
|
#include "util/codec.h"
|
|
|
#include "util/file.h"
|
|
|
#include "core/define.h"
|
|
|
#include "core/config.h"
|
|
|
-
|
|
|
+#include "core/app.h"
|
|
|
#ifdef _WIN32
|
|
|
#include <Windows.h>
|
|
|
#endif
|
|
|
#define DEBUG_INFO 0
|
|
|
-void LogUtils::print(const std::string& type,const std::string& msg,const std::string& filepath, const std::string& func, int line,int color,bool error) {
|
|
|
+void fastweb::log::print(const std::string& type,const std::string& msg,const std::string& filepath, const std::string& func, int line,int color,bool error) {
|
|
|
|
|
|
std::string __now_time = time::now_time("%m-%d %H:%M:%S");
|
|
|
printf("[%s] ", __now_time.c_str());
|
|
|
@@ -26,7 +26,7 @@ void LogUtils::print(const std::string& type,const std::string& msg,const std::s
|
|
|
ylib::println(msg, (ylib::ConsoleTextColor)color);
|
|
|
#endif
|
|
|
|
|
|
- if (sConfig->log.enable)
|
|
|
+ if (app()->config->log.enable)
|
|
|
{
|
|
|
std::string logcontent = __now_time + " " + type + " " + msg
|
|
|
#ifdef _WIN32
|
|
|
@@ -34,17 +34,17 @@ void LogUtils::print(const std::string& type,const std::string& msg,const std::s
|
|
|
#else
|
|
|
+ "\n";
|
|
|
#endif
|
|
|
- std::string new_time = time::now_time(sConfig->log.name);
|
|
|
+ std::string new_time = time::now_time(app()->config->log.name);
|
|
|
if (new_time == "")
|
|
|
{
|
|
|
- std::cout << "error: The log file name is incorrect: " << sConfig->log.name << std::endl;
|
|
|
+ std::cout << "error: The log file name is incorrect: " << app()->config->log.name << std::endl;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (m_current_name != new_time)
|
|
|
{
|
|
|
- ylib::file::create_dir(sConfig->log.dir, true);
|
|
|
- std::string newfilepath = sConfig->log.dir + "/" + new_time;
|
|
|
+ ylib::file::create_dir(app()->config->log.dir, true);
|
|
|
+ std::string newfilepath = app()->config->log.dir + "/" + new_time;
|
|
|
m_file.close();
|
|
|
if (m_file.open(newfilepath) == false)
|
|
|
{
|
|
|
@@ -55,14 +55,14 @@ void LogUtils::print(const std::string& type,const std::string& msg,const std::s
|
|
|
m_file.appead(logcontent);
|
|
|
}
|
|
|
}
|
|
|
-LogUtils::LogUtils()
|
|
|
+fastweb::log::log(fastweb::app* ptr):Interface(ptr)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
-LogUtils::~LogUtils()
|
|
|
+fastweb::log::~log()
|
|
|
{
|
|
|
}
|
|
|
-void LogUtils::success(const std::string& msg, const std::string& filepath, const std::string& func, int line)
|
|
|
+void fastweb::log::success(const std::string& msg, const std::string& filepath, const std::string& func, int line)
|
|
|
{
|
|
|
//log_error();
|
|
|
this->print("[SUCC ] ", msg, filepath, func, line, ylib::ConsoleTextColor::GREEN
|
|
|
@@ -72,13 +72,13 @@ void LogUtils::success(const std::string& msg, const std::string& filepath, cons
|
|
|
,false);
|
|
|
}
|
|
|
|
|
|
-void LogUtils::info(const std::string& msg, const std::string& filepath, const std::string& func, int line)
|
|
|
+void fastweb::log::info(const std::string& msg, const std::string& filepath, const std::string& func, int line)
|
|
|
{
|
|
|
this->print("[INFO ] ", msg, filepath, func, line, ylib::ConsoleTextColor::GREEN | ylib::ConsoleTextColor::RED | ylib::ConsoleTextColor::BLUE, false);
|
|
|
|
|
|
}
|
|
|
|
|
|
-void LogUtils::error(const std::string& msg, const std::string& filepath, const std::string& func, int line)
|
|
|
+void fastweb::log::error(const std::string& msg, const std::string& filepath, const std::string& func, int line)
|
|
|
{
|
|
|
//#ifdef _DEBUG
|
|
|
this->print("[ERROR] ", msg, filepath, func, line, ylib::ConsoleTextColor::RED
|
|
|
@@ -91,7 +91,7 @@ void LogUtils::error(const std::string& msg, const std::string& filepath, const
|
|
|
//#endif
|
|
|
}
|
|
|
|
|
|
-void LogUtils::warn(const std::string& msg, const std::string& filepath, const std::string& func, int line)
|
|
|
+void fastweb::log::warn(const std::string& msg, const std::string& filepath, const std::string& func, int line)
|
|
|
{
|
|
|
this->print("[WARN ] ", msg, filepath, func, line, ylib::ConsoleTextColor::YELLOW
|
|
|
#ifdef _WIN32
|
|
|
@@ -100,7 +100,7 @@ void LogUtils::warn(const std::string& msg, const std::string& filepath, const s
|
|
|
, false);
|
|
|
}
|
|
|
|
|
|
-void LogUtils::debug(const std::string& msg, const std::string& filepath, const std::string& func,int line)
|
|
|
+void fastweb::log::debug(const std::string& msg, const std::string& filepath, const std::string& func,int line)
|
|
|
{
|
|
|
this->print("[DEBUG] ", msg, filepath, func, line, ylib::ConsoleTextColor::BLUE
|
|
|
#ifdef _WIN32
|
|
|
@@ -108,3 +108,8 @@ void LogUtils::debug(const std::string& msg, const std::string& filepath, const
|
|
|
#endif
|
|
|
, false);
|
|
|
}
|
|
|
+
|
|
|
+void fastweb::log::lua(const std::string& msg)
|
|
|
+{
|
|
|
+ this->print("[LUA ] ", msg,"","",0, ylib::ConsoleTextColor::GREEN | ylib::ConsoleTextColor::RED | ylib::ConsoleTextColor::BLUE, false);
|
|
|
+}
|