本文主要是介绍UE4/UE5 日志插件(基于spdlog),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
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文库
这篇关于UE4/UE5 日志插件(基于spdlog)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!