Log Timestamp

引擎默认的 Log 时间是 UTC,与国内的有差别,可以修改配置实现:

BaseEngine.ini
1
2
3
4
[LogFiles]
PurgeLogsDays=5
MaxLogFilesOnDisk=10
LogTimes=True

通过控制 LogTimes 项的值可以设置不同的时区,可选项为None/UTC/SinceStart/Local/Timecode/(Ture/Flase(UTC)):

Launch/Private/LaunchEngineLoop.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
static void CheckForPrintTimesOverride()
{
// Determine whether to override the default setting for including timestamps in the log.
FString LogTimes;
if (GConfig->GetString(TEXT("LogFiles" ), TEXT("LogTimes" ), LogTimes, GEngineIni ))
{
if (LogTimes == TEXT("None" ))
{
CVarLogTimestamp->Set((int)ELogTimes::None, ECVF_SetBySystemSettingsIni);
}
else if (LogTimes == TEXT("UTC" ))
{
CVarLogTimestamp->Set((int)ELogTimes::UTC, ECVF_SetBySystemSettingsIni);
}
else if (LogTimes == TEXT("SinceStart" ))
{
CVarLogTimestamp->Set((int)ELogTimes::SinceGStartTime, ECVF_SetBySystemSettingsIni);
}
else if (LogTimes == TEXT("Local" ))
{
CVarLogTimestamp->Set((int)ELogTimes::Local, ECVF_SetBySystemSettingsIni);
}
else if (LogTimes == TEXT("Timecode" ))
{
CVarLogTimestamp->Set((int)ELogTimes::Timecode, ECVF_SetBySystemSettingsIni);
}
// Assume this is a bool for backward compatibility
else if (FCString::ToBool(*LogTimes))
{
CVarLogTimestamp->Set((int)ELogTimes::UTC, ECVF_SetBySystemSettingsIni);
}
}

if (FParse::Param(FCommandLine::Get(), TEXT("LOGTIMES" ) ))
{
CVarLogTimestamp->Set((int)ELogTimes::UTC, ECVF_SetByCommandline);
}
else if (FParse::Param(FCommandLine::Get(), TEXT("UTCLOGTIMES" ) ))
{
CVarLogTimestamp->Set((int)ELogTimes::UTC, ECVF_SetByCommandline);
}
else if (FParse::Param(FCommandLine::Get(), TEXT("NOLOGTIMES" ) ))
{
CVarLogTimestamp->Set((int)ELogTimes::None, ECVF_SetByCommandline);
}
else if (FParse::Param(FCommandLine::Get(), TEXT("LOGTIMESINCESTART" ) ))
{
CVarLogTimestamp->Set((int)ELogTimes::SinceGStartTime, ECVF_SetByCommandline);
}
else if (FParse::Param(FCommandLine::Get(), TEXT("LOCALLOGTIMES" ) ))
{
CVarLogTimestamp->Set((int)ELogTimes::Local, ECVF_SetByCommandline);
}
else if (FParse::Param(FCommandLine::Get(), TEXT("LOGTIMECODE" )))
{
CVarLogTimestamp->Set((int)ELogTimes::Timecode, ECVF_SetByCommandline);
}
}