1
This commit is contained in:
parent
a82a78407b
commit
7cba21ca64
16
cpp/tglog.cc
16
cpp/tglog.cc
@ -1,4 +1,6 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
@ -25,6 +27,7 @@ namespace f8
|
||||
std::string filename_fmt;
|
||||
std::string project_name;
|
||||
bool is_poly_log = false;
|
||||
int time_zone = 0;
|
||||
|
||||
std::thread* save_thread = nullptr;
|
||||
volatile bool save_thread_shutdown = false;
|
||||
@ -56,6 +59,12 @@ namespace f8
|
||||
std::string GetCurrentFileName()
|
||||
{
|
||||
time_t nowtime = time(nullptr);
|
||||
{
|
||||
struct timeval tv;
|
||||
struct timezone tz;
|
||||
gettimeofday(&tv, &tz);
|
||||
nowtime = tz.tz_minuteswest * -3600 + time_zone * 3600;
|
||||
}
|
||||
struct tm tm_nowtime = {0};
|
||||
localtime_r(&nowtime, &tm_nowtime);
|
||||
|
||||
@ -67,12 +76,14 @@ namespace f8
|
||||
}
|
||||
};
|
||||
|
||||
void TGLog::Init(const std::string& project_name, bool is_poly_log)
|
||||
void TGLog::Init(const std::string& project_name, bool is_poly_log, int time_zone)
|
||||
{
|
||||
time_zone_ = time_zone;
|
||||
project_name_ = project_name;
|
||||
is_poly_log_ = is_poly_log;
|
||||
impl_ = new TGLogImpl();
|
||||
impl_->filename_fmt = TGLOG_FILENAME;
|
||||
impl_->time_zone = time_zone;
|
||||
a8::ReplaceString(impl_->filename_fmt, "$pid", a8::XValue(getpid()));
|
||||
|
||||
impl_->project_name = project_name_;
|
||||
@ -88,8 +99,9 @@ namespace f8
|
||||
impl_ = nullptr;
|
||||
}
|
||||
|
||||
void TGLog::SetProjectInfo(const std::string& project_name, bool is_poly_log)
|
||||
void TGLog::SetProjectInfo(const std::string& project_name, bool is_poly_log, int time_zone)
|
||||
{
|
||||
time_zone_ = time_zone;
|
||||
project_name_ = project_name;
|
||||
is_poly_log_ = is_poly_log;
|
||||
}
|
||||
|
@ -10,10 +10,10 @@ namespace f8
|
||||
friend class a8::Singleton<TGLog>;
|
||||
|
||||
public:
|
||||
void Init(const std::string& project_name, bool is_poly_log);
|
||||
void Init(const std::string& project_name, bool is_poly_log, int time_zone = 8);
|
||||
void UnInit();
|
||||
|
||||
void SetProjectInfo(const std::string& project_name, bool is_poly_log);
|
||||
void SetProjectInfo(const std::string& project_name, bool is_poly_log, int time_zone = 8);
|
||||
void AddTrackLog(int game_id, const std::string& accountid, unsigned long ip_saddr,
|
||||
int logclass1, int logclass2, a8::XObject* prop);
|
||||
void AddTrackLog(int game_id, const std::string& accountid, unsigned long ip_saddr,
|
||||
@ -25,6 +25,7 @@ namespace f8
|
||||
const std::string& event_name, a8::XObject* prop);
|
||||
|
||||
private:
|
||||
int time_zone_ = 0;
|
||||
std::string project_name_;
|
||||
bool is_poly_log_ = false;
|
||||
TGLogImpl* impl_ = nullptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user