1 解决问题
对于高频日志序列化到本地的需求,spdlog肯定完美满足。
源码地址:https://github.com/gabime/spdlog
博主下载的版本为 spdlog-1.12.0,各位大佬可以根绝自己爱好选择。
2 过程介绍
大概目录:
SpdlogLibC目录下是对spdlog的封装:
bin里是.dll,lib放是.lib,include是.h文件。
SpdLoggerLib.Build.cs文件内容:
// Copyright Epic Games, Inc. All Rights Reserved.using UnrealBuildTool;
using System.IO;public class SpdLoggerLib : ModuleRules
{private string OuterLibPath{get { return Path.GetFullPath(Path.Combine(ModuleDirectory, "SpdlogLibC/")); }}public SpdLoggerLib(ReadOnlyTargetRules Target) : base(Target){PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;PublicIncludePaths.AddRange(new string[] { });PrivateIncludePaths.AddRange(new string[] {// ... add other private include paths required here ...});PublicDependencyModuleNames.AddRange(new string[]{"Core","Projects"// ... add other public dependencies that you statically link with here ...});PrivateDependencyModuleNames.AddRange(new string[]{"CoreUObject","Engine","InputCore"// ... add private dependencies that you statically link with here ... });DynamicallyLoadedModuleNames.AddRange(new string[]{// ... add any modules that your module loads dynamically here ...});if (Target.Platform == UnrealTargetPlatform.Win64){string LibPath = OuterLibPath + "lib/x64/";string DllPath = OuterLibPath + "bin/x64/";string IncludePath = OuterLibPath + "include/";PublicSystemIncludePaths.AddRange(new string[] {IncludePath});foreach (string file in Directory.GetFiles(LibPath)){PublicAdditionalLibraries.Add(file);}foreach (string file in Directory.GetFiles(DllPath)){string filename = Path.GetFileName(file);string outdll = "$(TargetOutputDir)/";outdll += filename;RuntimeDependencies.Add(outdll, file);}}else if (Target.Platform == UnrealTargetPlatform.Mac) { }else if (Target.Platform == UnrealTargetPlatform.Linux) { }}
}
3 使用简介
将插件拷贝到您的项目插件目录下:
蓝图里直接使用:
产生的日志在您的项目content根目录下:
4 插件特点
- 屏蔽大量实现细节,只暴露一个接口到蓝图;
- 足够高效,继承了spdlog的多线程、高并发;
- 封装的原生dll库不区分debug和release,实用性更广。
5 下载地址
UE4/5高并发日志插件资源-CSDN文库