Time: 2021年5月4日15:04:01
Author: blackD
Desc: UE4自定义log(输出log格式: 类名/函数名 + 行号 + 自定义输出log)
FString filePath
UE_LOG(LogTemp, Log, TEXT("%d, %s"), 100, *filePath);
UE_LOG(LogTemp, Error, TEXT("Hello,World!"));
FString filePath;
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green,FString::Printf(TEXT("DLL_Init")));
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green,FString::Printf(TEXT("%s"),*filePath));if (GEngine)
{GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, FString::Printf(TEXT("Print Message this is %f"), 2.3f));
}
.h文件
DECLARE_LOG_CATEGORY_EXTERN(MyProjectLog, Log, All);
.cpp文件
DEFINE_LOG_CATEGORY(MyProjectLog);
需要打印日志的.cpp添加申明自定义日志的头文件FString filePath
UE_LOG(MyProjectLog, Log, TEXT("%s"), *filePath);
UE_LOG(MyProjectLog, Error, TEXT("Hello,World!"));
DECLARE_LOG_CATEGORY_EXTERN(LogMyController, Log, All)
#include ated.h"
#include "Runtime/Engine/Classes/Engine/StaticMeshActor.h"
DEFINE_LOG_CATEGORY(LogMyController)
#define LINE_LOG ("CTime: " + FDateTime::Now().ToString() + "; CFunc: " + *FString(__FUNCTION__) + "; CLineNum: " + *FString::FromInt(__LINE__) + "; CLog: " )//Log日志格式: 类名/函数名 + 行号 + msg
void AMyPlayerController::BeginPlay()
{UE_LOG(LogMyController, Warning, TEXT("%s, Start"), *LINE_LOG);Super::BeginPlay();UE_LOG(LogMyController, Warning, TEXT("%s, End"), *LINE_LOG);
}
/**
* This function will add a debug message to the onscreen message list.
* It will be displayed for FrameCount frames.
*
* @param Key A unique key to prevent the same message from being added multiple times.
* 用来防止相同信息被显示多次:当Key为0时,相同的信息只在界面上显示一次;当Key为-1时,相同信息会按照程序执行依次显示。
* @param TimeToDisplay How long to display the message, in seconds.
* 信息显示时间
* @param DisplayColor The color to display the text in.
* 信息颜色
* @param DebugMessage The message to display.
* 打印的消息
* @param bNewerOnTop 用来确定一系列信息显示的位置:当bNewerOnTop=true时,最新的信息永远显示在顶部;当bNewerOnTop=false时,最新的信息显示在底部,缺省时默认为true。
* @param TextScale
*/
void UEngine::AddOnScreenDebugMessage(uint64 Key, float TimeToDisplay, FColor DisplayColor, const FString& DebugMessage, bool bNewerOnTop, const FVector2D& TextScale)
本文发布于:2024-01-27 17:50:54,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/17063490581743.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |