UnrealEngine Log封裝

11 篇文章 1 订阅

UE Log Macro Custom 自定義Log封裝

#pragma once

#ifdef _MSC_VER
#define CLASS_FUNCTION FUNCTION
#endif

#ifdef GNUG
#include <cxxabi.h>
#include <execinfo.h>
char *class_func(const char *c, const char *f)
{
int status;
static char buff[100];
char *demangled = abi::__cxa_demangle(c, NULL, NULL, &status);
snprintf(buff, sizeof(buff), “%s::%s”, demangled, f);
free(demangled);
return buff;
}
#define CLASS_FUNCTION class_func(typeid(*this).name(), func)
#endif

/* ClassName::FunctionName where this is called. /
#define CURRENT_CLASS_FUNCTION (FString(CLASS_FUNCTION))
/
Class Name where this is called. /
#define CURRENT_CLASS (FString(CLASS_FUNCTION).Left(FString(CLASS_FUNCTION).Find(TEXT(“:”))) )
/
Function Name where this is called. /
#define CURRENT_FUNCTION (FString(CLASS_FUNCTION).Right(FString(CLASS_FUNCTION).Len() - FString(CLASS_FUNCTION).Find(TEXT(“::”)) - 2 ))
/
Line Number where this is called. /
#define CURRENT_LINE (FString::FromInt(LINE))
/
Class Name and Line Number where this is called. /
#define CURRENT_CLASS_LINE (CURRENT_CLASS + " (" + CURRENT_LINE + “)”)
/
Class Name and Function Name and Line Number where this is called. /
#define CURRENT_CLASS_FUNCTION_LINE (CURRENT_CLASS_FUNCTION + " (" + CURRENT_LINE + “)”)
/
Function Signature where this is called. */
#define CURRENT_FUNCTIONSIG (FString(FUNCSIG))

/*

  • UE_LOG macros
    */

/* Equivalent to UE_LOG. /
#define LOG_UE(CategoryName, Verbosity, Message, …) UE_LOG(CategoryName, Verbosity, Message, ##VA_ARGS)
/
Log macro. Style: ClassName::FunctionName Format. */
#define LOG_SENDER(CategoryName, Verbosity, Message, …) UE_LOG(CategoryName, Verbosity, TEXT("%s "), TEXT(CLASS_FUNCTION), Message, ##VA_ARGS )

/* Log macro. Style: ClassName::FunctionName (Line) Message. */
#define LOG(CategoryName, Message) UE_LOG(CategoryName, Log, TEXT(“%s: %s”), *CURRENT_CLASS_FUNCTION_LINE, FString(Message))
/
Log macro. Style: ClassName::FunctionName (Line) Message. */
#define LOG_PRINTF(CategoryName, FormatString , …) UE_LOG(CategoryName, Log, TEXT(“%s: %s”), *CURRENT_CLASS_FUNCTION_LINE, *FString::Printf(TEXT(FormatString), ##VA_ARGS ) )

/* Log macro with verbosity. Style: ClassName::FunctionName (Line) Message. */
#define LOG_VERBOSITY(CategoryName, Verbosity, Message) UE_LOG(CategoryName, Verbosity, TEXT(“%s: %s”), *CURRENT_CLASS_FUNCTION_LINE, FString(Message))
/
Log macro with verbosity. Style: ClassName::FunctionName (Line) Message. */
#define LOG_VERBOSITY_PRINTF(CategoryName, Verbosity, FormatString , …) UE_LOG(CategoryName, Verbosity, TEXT(“%s: %s”), *CURRENT_CLASS_FUNCTION_LINE, *FString::Printf(TEXT(FormatString), ##VA_ARGS ) )

/* Log warning macro. Style: ClassName::FunctionName (Line) Message. */
#define LOG_WARNING(CategoryName, Message) UE_LOG(CategoryName, Warning, TEXT(“%s: %s”), *CURRENT_CLASS_FUNCTION_LINE, FString(Message))
/
Log warning macro. Style: ClassName::FunctionName (Line) Message. */
#define LOG_WARNING_PRINTF(CategoryName, FormatString , …) UE_LOG(CategoryName, Warning, TEXT(“%s: %s”), *CURRENT_CLASS_FUNCTION_LINE, *FString::Printf(TEXT(FormatString), ##VA_ARGS ) )

/* Log error macro. Style: ClassName::FunctionName (Line) Message. */
#define LOG_ERROR(CategoryName, Message) UE_LOG(CategoryName, Error, TEXT(“%s: %s”), *CURRENT_CLASS_FUNCTION_LINE, FString(Message))
/
Log error macro. Style: ClassName::FunctionName (Line) Message. */
#define LOG_ERROR_PRINTF(CategoryName, FormatString , …) UE_LOG(CategoryName, Error, TEXT(“%s: %s”), *CURRENT_CLASS_FUNCTION_LINE, *FString::Printf(TEXT(FormatString), ##VA_ARGS ) )
#define LOG_ERROR_Format(CategoryName, FormatString , …) UE_LOG(CategoryName, Error, TEXT(“%s: %s”), *CURRENT_CLASS_FUNCTION_LINE, *FString::Printf(TEXT(FormatString), ##VA_ARGS ) )

/* Log fatal macro. Style: ClassName::FunctionName (Line) Message. */
#define LOG_FATAL(CategoryName, Message) UE_LOG(CategoryName, Fatal, TEXT(“%s: %s”), *CURRENT_CLASS_FUNCTION_LINE, FString(Message))
/
Log fatal macro. Style: ClassName::FunctionName (Line) Message. */
#define LOG_FATAL_PRINTF(CategoryName, FormatString , …) UE_LOG(CategoryName,Fatal,TEXT(“%s: %s”), *CURRENT_CLASS_FUNCTION_LINE, *FString::Printf(TEXT(FormatString), ##VA_ARGS ) )

/*

  • Screen Messages macros
    */

#define LOG_SCREENMSG(Message) (GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::Yellow, *(CURRENT_CLASS_FUNCTION_LINE + ": " + Message)) )
#define LOG_SCREENMSG_PRINTF(FormatString , …) (GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::Yellow, *(CURRENT_CLASS_FUNCTION_LINE + ": " + (FString::Printf(TEXT(FormatString), ##VA_ARGS )))) )

  • 16
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Unreal Engine 4 Scripting with C++ Cookbook 2016 | ISBN-10: 1785885545 | 431 pages | PDF | 7 MB Key Features A straightforward and easy-to-follow format A selection of the most important tasks and problems Carefully organized instructions to solve problems efficiently Clear explanations of what you did Solutions that can be applied to solve real-world problems Book Description Unreal Engine 4 (UE4) is a complete suite of game development tools made by game developers, for game developers. With more than 100 practical recipes, this book is a guide showcasing techniques to use the power of C++ scripting while developing games with UE4. It will start with adding and editing C++ classes from within the Unreal Editor. It will delve into one of Unreal's primary strengths, the ability for designers to customize programmer-developed actors and components. It will help you understand the benefits of when and how to use C++ as the scripting tool. With a blend of task-oriented recipes, this book will provide actionable information about scripting games with UE4, and manipulating the game and the development environment using C++. Towards the end of the book, you will be empowered to become a top-notch developer with Unreal Engine 4 using C++ as the scripting language. What you will learn Build function libraries (Blueprints) containing reusable code to reduce upkeep Move low-level functions from Blueprint into C++ to improve performance Abstract away complex implementation details to simplify designer workflows Incorporate existing libraries into your game to add extra functionality such as hardware integration Implement AI tasks and behaviors in Blueprints and C++ Generate data to control the appearance and content of UI elements

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值