本文整理汇总了C++中GetTimestampStr函数的典型用法代码示例。如果您正苦于以下问题:C++ GetTimestampStr函数的具体用法?C++ GetTimestampStr怎么用?C++ GetTimestampStr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetTimestampStr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: worker
Log::Log() : worker(NULL)
{
SetRealmID(0);
m_logsTimestamp = "_" + GetTimestampStr();
LoadFromConfig();
pandashanLog = fopen("pandashan.log", "a");
}
示例2: worker
Log::Log() : worker(NULL)
{
SetRealmID(0);
m_logsTimestamp = "_" + GetTimestampStr();
LoadFromConfig();
pandashanLog = fopen(std::string(m_logsDir).append("pandashan.log").c_str(), "a");
}
示例3: GetTimestampStr
void Log::ChangeLogFile(std::string name)
{
//将旧日志文件改名
std::string logname = m_logsDir + name;
std::string storefile = m_logsDir + name + "." + GetTimestampStr(time(NULL) - 24*3600);
// 移动到其他位置
rename(logname.c_str(), storefile.c_str());
}
示例4: GetTimestampStr
void Log::Initialize()
{
std::string logsDir = sConfig.GetStringDefault("LogsDir","");
if(!logsDir.empty())
{
if((logsDir.at(logsDir.length()-1)!='/') && (logsDir.at(logsDir.length()-1)!='\\'))
logsDir.append("/");
}
std::string logfn=sConfig.GetStringDefault("LogFile", "");
if(logfn!="")
{
if(sConfig.GetIntDefault("LogTimestamp",0))
{
std::string logTimestamp = sConfig.GetIntDefault("LogTimestamp",0) ? GetTimestampStr() : "";
logTimestamp.insert(0,"_");
size_t dot_pos = logfn.find_last_of(".");
if(dot_pos!=logfn.npos)
logfn.insert(dot_pos,logTimestamp);
else
logfn += logTimestamp;
}
logfile = fopen((logsDir+logfn).c_str(), "w");
}
std::string gmlogname = sConfig.GetStringDefault("GMLogFile", "");
if(gmlogname!="")
{
gmLogfile = fopen((logsDir+gmlogname).c_str(), "a");
}
std::string dberlogname = sConfig.GetStringDefault("DBErrorLogFile", "");
if(dberlogname!="")
{
dberLogfile = fopen((logsDir+dberlogname).c_str(), "a");
}
std::string ralogname = sConfig.GetStringDefault("RaLogFile", "");
if(ralogname!="")
{
raLogfile = fopen((logsDir+ralogname).c_str(), "a");
}
m_logLevel = sConfig.GetIntDefault("LogLevel", 0);
m_logFileLevel = sConfig.GetIntDefault("LogFileLevel", 0);
InitColors(sConfig.GetStringDefault("LogColors", ""));
m_logFilter = 0;
if(sConfig.GetIntDefault("LogFilter_TransportMoves", 0)!=0)
m_logFilter |= LOG_FILTER_TRANSPORT_MOVES;
if(sConfig.GetIntDefault("LogFilter_CreatureMoves", 0)!=0)
m_logFilter |= LOG_FILTER_CREATURE_MOVES;
if(sConfig.GetIntDefault("LogFilter_VisibilityChanges", 0)!=0)
m_logFilter |= LOG_FILTER_VISIBILITY_CHANGES;
}
示例5: va_start
void Log::OutPandashan(const char* str, ...)
{
if (!str)
return;
char result[MAX_QUERY_LEN];
va_list ap;
va_start(ap, str);
vsnprintf(result, MAX_QUERY_LEN, str, ap);
va_end(ap);
std::string date = GetTimestampStr();
fprintf(pandashanLog, "[%s] Pandashan LOG : %s\n", date.c_str(), result);
fflush(pandashanLog);
}
示例6: GetTimestampStr
void Log::Initialize()
{
/// Common log files data
m_logsDir = sConfig.GetStringDefault("LogsDir","");
if(!m_logsDir.empty())
{
if((m_logsDir.at(m_logsDir.length()-1)!='/') && (m_logsDir.at(m_logsDir.length()-1)!='\\'))
m_logsDir.append("/");
}
m_logsTimestamp = "_" + GetTimestampStr();
/// Open specific log files
logfile = openLogFile("LogFile","LogTimestamp","w");
m_gmlog_per_account = sConfig.GetBoolDefault("GmLogPerAccount",false);
if(!m_gmlog_per_account)
gmLogfile = openLogFile("GMLogFile","GmLogTimestamp","a");
else
{
// GM log settings for per account case
m_gmlog_filename_format = sConfig.GetStringDefault("GMLogFile", "");
if(!m_gmlog_filename_format.empty())
{
bool m_gmlog_timestamp = sConfig.GetBoolDefault("GmLogTimestamp",false);
size_t dot_pos = m_gmlog_filename_format.find_last_of(".");
if(dot_pos!=m_gmlog_filename_format.npos)
{
if(m_gmlog_timestamp)
m_gmlog_filename_format.insert(dot_pos,m_logsTimestamp);
m_gmlog_filename_format.insert(dot_pos,"_#%u");
}
else
{
m_gmlog_filename_format += "_#%u";
if(m_gmlog_timestamp)
m_gmlog_filename_format += m_logsTimestamp;
}
m_gmlog_filename_format = m_logsDir + m_gmlog_filename_format;
}
}
charLogfile = openLogFile("CharLogFile","CharLogTimestamp","a");
dberLogfile = openLogFile("DBErrorLogFile",NULL,"a");
raLogfile = openLogFile("RaLogFile",NULL,"a");
worldLogfile = openLogFile("WorldLogFile","WorldLogTimestamp","a");
// Main log file settings
m_includeTime = sConfig.GetBoolDefault("LogTime", false);
m_logLevel = sConfig.GetIntDefault("LogLevel", 0);
m_logFileLevel = sConfig.GetIntDefault("LogFileLevel", 0);
InitColors(sConfig.GetStringDefault("LogColors", ""));
m_logFilter = 0;
if(sConfig.GetBoolDefault("LogFilter_TransportMoves", true))
m_logFilter |= LOG_FILTER_TRANSPORT_MOVES;
if(sConfig.GetBoolDefault("LogFilter_CreatureMoves", true))
m_logFilter |= LOG_FILTER_CREATURE_MOVES;
if(sConfig.GetBoolDefault("LogFilter_VisibilityChanges", true))
m_logFilter |= LOG_FILTER_VISIBILITY_CHANGES;
if(sConfig.GetBoolDefault("LogFilter_AchievementUpdates", true))
m_logFilter |= LOG_FILTER_ACHIEVEMENT_UPDATES;
// Char log settings
m_charLog_Dump = sConfig.GetBoolDefault("CharLogDump", false);
}
示例7: AppenderId
Log::Log() : AppenderId(0), lowestLogLevel(LOG_LEVEL_FATAL), _ioService(nullptr), _strand(nullptr)
{
m_logsTimestamp = "_" + GetTimestampStr();
RegisterAppender<AppenderConsole>();
RegisterAppender<AppenderFile>();
}
示例8: worker
Log::Log() : worker(NULL)
{
SetRealmID(0);
m_logsTimestamp = "_" + GetTimestampStr();
LoadFromConfig();
}
示例9: GetTimestampStr
void Log::Initialize()
{
// Common log files data
m_logsDir = sConfig.GetStringDefault("LogsDir", "0 6 4 3 1 1 2 7 5 0 4 0 1 3 2 4 0");
if (!m_logsDir.empty())
if ((m_logsDir.at(m_logsDir.length() - 1) != '/') && (m_logsDir.at(m_logsDir.length() - 1) != '\\'))
m_logsDir.append("/");
m_logsTimestamp = "_" + GetTimestampStr();
// Open specific log files
FILE* logfile = openLogFile("LogFile", "LogTimestamp", "wb");
for (int i = 0; i < MAX_LOG_TYPES; ++i)
if (!m_logFiles[i])
m_logFiles[i] = logfile;
InitColors(sConfig.GetStringDefault("LogColors", "0 6 4 3 1 1 2 7 5 0 4 0 1 3 2 4 0"));
m_gmlog_per_account = sConfig.GetBoolDefault("GmLogPerAccount", false);
if (!m_gmlog_per_account)
m_logFiles[LOG_TYPE_COMMAND] = openLogFile("GMLogFile", "GmLogTimestamp", "ab");
else
{
// GM log settings for per account case
m_gmlog_filename_format = sConfig.GetStringDefault("GMLogFile", "");
if (!m_gmlog_filename_format.empty())
{
bool m_gmlog_timestamp = sConfig.GetBoolDefault("GmLogTimestamp", false);
size_t dot_pos = m_gmlog_filename_format.find_last_of(".");
if (dot_pos != m_gmlog_filename_format.npos)
{
if (m_gmlog_timestamp)
m_gmlog_filename_format.insert(dot_pos, m_logsTimestamp);
m_gmlog_filename_format.insert(dot_pos, "_#%u");
}
else
{
m_gmlog_filename_format += "_#%u";
if (m_gmlog_timestamp)
m_gmlog_filename_format += m_logsTimestamp;
}
m_gmlog_filename_format = m_logsDir + m_gmlog_filename_format;
}
}
m_logFiles[LOG_TYPE_CHAR] = openLogFile("CharLogFile", "CharLogTimestamp", "ab");
m_logFiles[LOG_TYPE_ERROR_DB] = openLogFile("DBErrorLogFile", NULL, "ab");
m_logFiles[LOG_TYPE_REMOTE] = openLogFile("RaLogFile", NULL, "ab");
m_logFiles[LOG_TYPE_CHAT] = openLogFile("ChatLogFile", "ChatLogTimestamp", "ab");
m_logFiles[LOG_TYPE_ARENA] = openLogFile("ArenaLogFile", NULL, "ab");
m_logFiles[LOG_TYPE_WARDEN] = openLogFile("Warden.LogFile", NULL, "ab");
m_logFiles[LOG_TYPE_NETWORK] = openLogFile("WorldLogFile", NULL, "ab");
m_logFiles[LOG_TYPE_SQL] = openLogFile("LogSQLFilename", "LogSQLTimestamp", "ab");
m_logMask = sConfig.GetIntDefault("LogMask", 51);
m_logMaskDatabase = sConfig.GetIntDefault("DBLogMask", 0);
// -------------------------------------------------------------------
// Deprecated, kept for backward compatibilty - @todo remove in future
// -------------------------------------------------------------------
// Main log file settings
switch (sConfig.GetIntDefault("LogLevel", -1))
{
case LOGL_MINIMAL:
m_logMask = LOG_TYPE_STRING | LOG_TYPE_COMMAND | LOG_TYPE_ERROR | LOG_TYPE_ERROR_DB;
break;
case LOGL_BASIC:
m_logMask = LOG_TYPE_STRING | LOG_TYPE_COMMAND | LOG_TYPE_ERROR | LOG_TYPE_ERROR_DB;
m_logMask |= LOG_TYPE_BASIC | LOG_TYPE_WARDEN;
break;
case LOGL_DETAIL:
m_logMask = LOG_TYPE_STRING | LOG_TYPE_COMMAND | LOG_TYPE_ERROR | LOG_TYPE_ERROR_DB;
m_logMask |= LOG_TYPE_BASIC | LOG_TYPE_WARDEN;
m_logMask |= LOGL_BASIC | LOG_TYPE_DETAIL | LOG_TYPE_SQL | LOG_TYPE_REMOTE | LOG_TYPE_CHAR;
break;
case LOGL_DEBUG:
m_logMask = LOG_TYPE_STRING | LOG_TYPE_COMMAND | LOG_TYPE_ERROR | LOG_TYPE_ERROR_DB;
m_logMask |= LOG_TYPE_BASIC | LOG_TYPE_WARDEN;
m_logMask |= LOGL_BASIC | LOG_TYPE_DETAIL | LOG_TYPE_SQL | LOG_TYPE_REMOTE | LOG_TYPE_CHAR;
m_logMask |= LOGL_DETAIL | LOG_TYPE_DEBUG | LOG_TYPE_MAP | LOG_TYPE_VMAP | LOG_TYPE_MMAP | LOG_TYPE_WARDEN | LOG_TYPE_ARENA | LOG_TYPE_NETWORK;
break;
case -1:
break;
}
switch (sConfig.GetIntDefault("DBLogLevel", -1))
{
case LOGL_MINIMAL:
m_logMaskDatabase = LOG_TYPE_STRING | LOG_TYPE_COMMAND | LOG_TYPE_ERROR | LOG_TYPE_ERROR_DB;
break;
case LOGL_BASIC:
m_logMaskDatabase = LOG_TYPE_STRING | LOG_TYPE_COMMAND | LOG_TYPE_ERROR | LOG_TYPE_ERROR_DB;
m_logMaskDatabase |= LOG_TYPE_BASIC | LOG_TYPE_WARDEN;
break;
//.........这里部分代码省略.........
示例10: _ioService
Log::Log() : _ioService(nullptr), _strand(nullptr)
{
m_logsTimestamp = "_" + GetTimestampStr();
RegisterAppender<AppenderConsole>();
RegisterAppender<AppenderFile>();
}
示例11: SetRealmID
void Log::Initialize()
{
/// Check whether we'll log GM commands/RA events/character outputs/chat stuffs
m_dbChar = sConfig->GetBoolDefault("LogDB.Char", false);
m_dbRA = sConfig->GetBoolDefault("LogDB.RA", false);
m_dbGM = sConfig->GetBoolDefault("LogDB.GM", false);
m_dbChat = sConfig->GetBoolDefault("LogDB.Chat", false);
/// Realm must be 0 by default
SetRealmID(0);
/// Common log files data
m_logsDir = sConfig->GetStringDefault("LogsDir","");
if (!m_logsDir.empty())
if ((m_logsDir.at(m_logsDir.length() - 1) != '/') && (m_logsDir.at(m_logsDir.length() - 1) != '\\'))
m_logsDir.append("/");
m_logsTimestamp = "_" + GetTimestampStr();
/// Open specific log files
logfile = openLogFile("LogFile","LogTimestamp","w");
InitColors(sConfig->GetStringDefault("LogColors", ""));
m_gmlog_per_account = sConfig->GetBoolDefault("GmLogPerAccount",false);
if(!m_gmlog_per_account)
gmLogfile = openLogFile("GMLogFile","GmLogTimestamp","a");
else
{
// GM log settings for per account case
m_gmlog_filename_format = sConfig->GetStringDefault("GMLogFile", "");
if(!m_gmlog_filename_format.empty())
{
bool m_gmlog_timestamp = sConfig->GetBoolDefault("GmLogTimestamp",false);
size_t dot_pos = m_gmlog_filename_format.find_last_of(".");
if(dot_pos!=m_gmlog_filename_format.npos)
{
if(m_gmlog_timestamp)
m_gmlog_filename_format.insert(dot_pos,m_logsTimestamp);
m_gmlog_filename_format.insert(dot_pos,"_#%u");
}
else
{
m_gmlog_filename_format += "_#%u";
if(m_gmlog_timestamp)
m_gmlog_filename_format += m_logsTimestamp;
}
m_gmlog_filename_format = m_logsDir + m_gmlog_filename_format;
}
}
charLogfile = openLogFile("CharLogFile", "CharLogTimestamp", "a");
dberLogfile = openLogFile("DBErrorLogFile", NULL, "a");
raLogfile = openLogFile("RaLogFile", NULL, "a");
chatLogfile = openLogFile("ChatLogFile", "ChatLogTimestamp", "a");
arenaLogFile = openLogFile("ArenaLogFile", NULL,"a");
sqlLogFile = openLogFile("SQLDriverLogFile", NULL, "a");
// Main log file settings
m_logLevel = sConfig->GetIntDefault("LogLevel", LOGL_NORMAL);
m_logFileLevel = sConfig->GetIntDefault("LogFileLevel", LOGL_NORMAL);
m_dbLogLevel = sConfig->GetIntDefault("DBLogLevel", LOGL_NORMAL);
m_sqlDriverQueryLogging = sConfig->GetBoolDefault("SQLDriverQueryLogging", false);
m_logFilter = 0;
if(sConfig->GetBoolDefault("LogFilter_TransportMoves", true))
m_logFilter |= LOG_FILTER_TRANSPORT_MOVES;
if(sConfig->GetBoolDefault("LogFilter_CreatureMoves", true))
m_logFilter |= LOG_FILTER_CREATURE_MOVES;
if(sConfig->GetBoolDefault("LogFilter_VisibilityChanges", true))
m_logFilter |= LOG_FILTER_VISIBILITY_CHANGES;
if(sConfig->GetBoolDefault("LogFilter_AchievementUpdates", true))
m_logFilter |= LOG_FILTER_ACHIEVEMENT_UPDATES;
// Char log settings
m_charLog_Dump = sConfig->GetBoolDefault("CharLogDump", false);
m_charLog_Dump_Separate = sConfig->GetBoolDefault("CharLogDump.Separate", false);
if (m_charLog_Dump_Separate)
{
m_dumpsDir = sConfig->GetStringDefault("CharLogDump.SeparateDir", "");
if (!m_dumpsDir.empty())
if ((m_dumpsDir.at(m_dumpsDir.length() - 1) != '/') && (m_dumpsDir.at(m_dumpsDir.length() - 1) != '\\'))
m_dumpsDir.append("/");
}
}
示例12: GetTimestampStr
void Log::Initialize()
{
/// Common log files data
m_logsDir = sConfig.GetStringDefault("LogsDir","");
if(!m_logsDir.empty())
{
if((m_logsDir.at(m_logsDir.length()-1)!='/') && (m_logsDir.at(m_logsDir.length()-1)!='\\'))
m_logsDir.append("/");
}
m_logsTimestamp = "_" + GetTimestampStr();
/// Open specific log files
m_gmlog_per_account = sConfig.GetBoolDefault("GmLogPerAccount",false);
if(!m_gmlog_per_account)
logFile[LOG_GM] = openLogFile(LOG_GM);
else
{
// GM log settings for per account case
m_gmlog_filename_format = sConfig.GetStringDefault(logToStr[LOG_GM][0],"gm_commands.log");
if(!m_gmlog_filename_format.empty())
{
bool m_gmlog_timestamp = sConfig.GetBoolDefault(logToStr[LOG_GM][2],false);
size_t dot_pos = m_gmlog_filename_format.find_last_of(".");
if(dot_pos!=m_gmlog_filename_format.npos)
{
if(m_gmlog_timestamp)
m_gmlog_filename_format.insert(dot_pos,m_logsTimestamp);
m_gmlog_filename_format.insert(dot_pos,"_%u");
}
else
{
m_gmlog_filename_format += "__%u";
if(m_gmlog_timestamp)
m_gmlog_filename_format += m_logsTimestamp;
}
m_gmlog_filename_format = (m_logsDir.empty() ? "" : m_logsDir + m_gmlog_filename_format);
}
}
m_whisplog_filename_format = (m_logsDir.empty() ? "." : m_logsDir) + sConfig.GetStringDefault("WhispLogDir", "whisps/") + "whisp_%u_.log";
for (uint8 i = LOG_DEFAULT; i < LOG_MAX_FILES; ++i)
logFile[i] = openLogFile(LogNames(i));
// Main log file settings
m_includeTime = sConfig.GetBoolDefault("LogTime", false);
m_logFileLevel = sConfig.GetIntDefault("LogFileLevel", 0);
m_logFilter = 0;
if(sConfig.GetBoolDefault("LogFilter_TransportMoves", true))
m_logFilter |= LOG_FILTER_TRANSPORT_MOVES;
if(sConfig.GetBoolDefault("LogFilter_CreatureMoves", true))
m_logFilter |= LOG_FILTER_CREATURE_MOVES;
if(sConfig.GetBoolDefault("LogFilter_VisibilityChanges", true))
m_logFilter |= LOG_FILTER_VISIBILITY_CHANGES;
}
示例13: worker
Log::Log() : worker(NULL)
{
m_logsTimestamp = "_" + GetTimestampStr();
LoadFromConfig();
}
示例14: SetRealmID
void Log::Initialize()
{
/// Check whether we'll log GM commands/RA events/character outputs/chat stuffs
m_dbChar = sConfig->GetBoolDefault("LogDB.Char", false);
m_dbRA = sConfig->GetBoolDefault("LogDB.RA", false);
m_dbGM = sConfig->GetBoolDefault("LogDB.GM", false);
m_dbChat = sConfig->GetBoolDefault("LogDB.Chat", false);
/// Realm must be 0 by default
SetRealmID(0);
/// Common log files data
m_logsDir = sConfig->GetStringDefault("LogsDir", "");
if(!m_logsDir.empty())
if((m_logsDir.at(m_logsDir.length() - 1) != '/') && (m_logsDir.at(m_logsDir.length() - 1) != '\\'))
m_logsDir.append("/");
m_logsTimestamp = "_" + GetTimestampStr();
/// Open specific log files
logfile = openLogFile("LogFile", "LogTimestamp", "w");
InitColors(sConfig->GetStringDefault("LogColors", ""));
m_gmlog_per_account = sConfig->GetBoolDefault("GmLogPerAccount", false);
if(!m_gmlog_per_account)
gmLogfile = openLogFile("GMLogFile", "GmLogTimestamp", "a");
else
{
// GM log settings for per account case
m_gmlog_filename_format = sConfig->GetStringDefault("GMLogFile", "");
if(!m_gmlog_filename_format.empty())
{
bool m_gmlog_timestamp = sConfig->GetBoolDefault("GmLogTimestamp", false);
size_t dot_pos = m_gmlog_filename_format.find_last_of(".");
if(dot_pos!=m_gmlog_filename_format.npos)
{
if(m_gmlog_timestamp)
m_gmlog_filename_format.insert(dot_pos, m_logsTimestamp);
m_gmlog_filename_format.insert(dot_pos, "_#%u");
}
else
{
m_gmlog_filename_format += "_#%u";
if(m_gmlog_timestamp)
m_gmlog_filename_format += m_logsTimestamp;
}
m_gmlog_filename_format = m_logsDir + m_gmlog_filename_format;
}
}
charLogfile = openLogFile("CharLogFile", "CharLogTimestamp", "a");
dberLogfile = openLogFile("DBErrorLogFile", NULL, "a");
raLogfile = openLogFile("RASOAP", NULL, "a");
chatLogfile = openLogFile("ChatLogFile", "ChatLogTimestamp", "a");
arenaLogFile = openLogFile("ArenaLogFile", NULL, "a");
sqlLogFile = openLogFile("SQLDriverLogFile", NULL, "a");
sqlDevLogFile = openLogFile("SQLDeveloperLogFile", NULL, "a");
wardenLogFile = openLogFile("WardenLogFile", NULL, "a");
// Main log file settings
m_logLevel = sConfig->GetIntDefault("LogLevel", LOGL_NORMAL);
m_logFileLevel = sConfig->GetIntDefault("LogFileLevel", LOGL_NORMAL);
m_dbLogLevel = sConfig->GetIntDefault("DBLogLevel", LOGL_NORMAL);
m_sqlDriverQueryLogging = sConfig->GetBoolDefault("SQLDriverQueryLogging", false);
m_DebugLogMask = DebugLogFilters(sConfig->GetIntDefault("DebugLogMask", LOG_FILTER_NONE));
// Char log settings
m_charLog_Dump = sConfig->GetBoolDefault("CharLogDump", false);
m_charLog_Dump_Separate = sConfig->GetBoolDefault("CharLogDump.Separate", false);
if(m_charLog_Dump_Separate)
{
m_dumpsDir = sConfig->GetStringDefault("CharLogDump.SeparateDir", "");
if(!m_dumpsDir.empty())
if((m_dumpsDir.at(m_dumpsDir.length() - 1) != '/') && (m_dumpsDir.at(m_dumpsDir.length() - 1) != '\\'))
m_dumpsDir.append("/");
}
}
示例15: _ioService
Log::Log() : _ioService(nullptr), _strand(nullptr)
{
m_logsTimestamp = "_" + GetTimestampStr();
LoadFromConfig();
}