UE4--Log写入到单独文件中_ue 日志写入文件_cartzhang的博客-CSDN博客
参考ue4的对应文章,修改代码适应ue5的接口
同时修改了没有文件的时候会创建两个文件的问题
改了备份文件名与ue标准一致,优化了输出格式
添加了子文件夹的功能
#include "Misc/Paths.h"
#include "Misc/FileHelper.h"
#define SG_LOG_S(FileName,PathName,Value) \
{ \
static bool IsNewLog = true; \
FString SaveDirectory = FPaths::ProjectSavedDir(); \
SaveDirectory.Append("Logs/SgLogs/"); \
SaveDirectory.Append(PathName + "/"); \
FString TmpFileName = FileName; \
TmpFileName.Append(".log"); \
\
/** CreateDirectoryTree returns true if the destination directory existed prior to call or has been created during the call.*/ \
IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile(); \