• UE427_Logging


    UE427_Logging

    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

    UE_LOG宏会经常用到,方便地判断我们的代码何时能够起到作用。

    #define UE_LOG(CategoryName, Verbosity, Format, ...)
    
    • 1

    它的前两个参数表示日志的类别名称(可以随意命名)以及日志的级别(ELogVerbosity枚举量),之后的参数类似于经典的printf(),但是最常用的参数类型只有%d(整数),%f(浮点数)和%s(字符串,并且一定是FString类型),我们需要执行必要的转换函数将char*转换到FString再输入到日志中。

    namespace ELogVerbosity
    {
    	enum Type : uint8;
    }
    
    • 1
    • 2
    • 3
    • 4
    namespace ELogVerbosity
    {
    	enum Type : uint8
    	{
    		/** Not used */
    		NoLogging		= 0,
    
    		/** Always prints a fatal error to console (and log file) and crashes (even if logging is disabled) */
    		Fatal,
    
    		/** 
    		 * Prints an error to console (and log file). 
    		 * Commandlets and the editor collect and report errors. Error messages result in commandlet failure.
    		 */
    		Error,
    
    		/** 
    		 * Prints a warning to console (and log file).
    		 * Commandlets and the editor collect and report warnings. Warnings can be treated as an error.
    		 */
    		Warning,
    
    		/** Prints a message to console (and log file) */
    		Display,
    
    		/** Prints a message to a log file (does not print to console) */
    		Log,
    
    		/** 
    		 * Prints a verbose message to a log file (if Verbose logging is enabled for the given category, 
    		 * usually used for detailed logging) 
    		 */
    		Verbose,
    
    		/** 
    		 * Prints a verbose message to a log file (if VeryVerbose logging is enabled, 
    		 * usually used for detailed logging that would otherwise spam output) 
    		 */
    		VeryVerbose,
    
    		// Log masks and special Enum values
    
    		All				= VeryVerbose,
    		NumVerbosity,
    		VerbosityMask	= 0xf,
    		SetColor		= 0x40, // not actually a verbosity, used to set the color of an output device 
    		BreakOnLog		= 0x80
    	};
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    // Log格式:
    	// 1. Log Message
    	//"This is a message to yourself during runtime!"
    	UE_LOG(YourLog,Warning,TEXT("This is a message to yourself during runtime!"));
    	// 2. Log an FString
    	// %s strings are wanted as TCHAR* by Log, so use *FString() %s字符串被日志需要作为TCHAR*,所以使用*FString()
    	//"MyCharacter's Name is %s"
    	UE_LOG(YourLog,Warning,TEXT("MyCharacter's Name is %s"), *MyCharacter->GetName() );
    	// 3. Log an Int
    	//"MyCharacter's Health is %d"
    	UE_LOG(YourLog,Warning,TEXT("MyCharacter's Health is %d"), MyCharacter->Health );
    	// 4. Log a Float
    	//"MyCharacter's Health is %f"
    	UE_LOG(YourLog,Warning,TEXT("MyCharacter's Health is %f"), MyCharacter->Health );
    	// 5. Log an FVector
    	//"MyCharacter's Location is %s"
    	UE_LOG(YourLog,Warning,TEXT("MyCharacter's Location is %s"), 
    	    *MyCharacter->GetActorLocation().ToString());
    	// 6. Log an FName
    	//"MyCharacter's FName is %s"
    	UE_LOG(YourLog,Warning,TEXT("MyCharacter's FName is %s"), 
    	    *MyCharacter->GetFName().ToString());
    	// 7. Log an FString,Int,Float
    	//"%s has health %d, which is %f percent of total health" %s的生命值%d,也就是总生命值的%f %
    	UE_LOG(YourLog,Warning,TEXT("%s has health %d, which is %f percent of total health"),
    	    *MyCharacter->GetName(), MyCharacter->Health, MyCharacter->HealthPercent);
    	    
    // Log的颜色设置:
    // 第二个参数是是用来控制颜色的。
    //"this is Grey Text"
    UE_LOG(YourLog,Log,TEXT("This is grey text!"));
    //"this is Yellow Text"
    UE_LOG(YourLog,Warning,TEXT("This is yellow text!"));
    //"This is Red Text"
    UE_LOG(YourLog,Error,TEXT("This is red text!"));
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    文章参考:
    Ue4的UE_LOG

    https://www.cnblogs.com/blueroses/p/6037981.html
    https://zhuanlan.zhihu.com/p/469324623

    Logging

    https://unrealcommunity.wiki/logging-lgpidy6i

    官方说明(以上若不明请详看以下)

    在这里插入图片描述
    在这里插入图片描述

    // Formatting Examples Quick Reference
    // 1. Logging an FString
    UE_LOG(LogTemp, Warning, TEXT("The Actor's name is %s"), *YourActor->GetName());
    // 2. Logging a Bool
    UE_LOG(LogTemp, Warning, TEXT("The boolean value is %s"), ( bYourBool ? TEXT("true") : TEXT("false") ));
    // 3. Logging an Integer
    UE_LOG(LogTemp, Warning, TEXT("The integer value is: %d"), YourInteger);
    // 4. Logging a Float
    UE_LOG(LogTemp, Warning, TEXT("The float value is: %f"), YourFloat);
    // 5. Logging an FVector
    UE_LOG(LogTemp, Warning, TEXT("The vector value is: %s"), *YourVector.ToString());
    // 6. Logging with Multiple Specifiers
    UE_LOG(LogTemp, Warning, TEXT("Current values are: vector %s, float %f, and integer %d"), *YourVector.ToString(), YourFloat, YourInteger);
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

  • 相关阅读:
    verilog学习笔记7——PMOS和NMOS、TTL电路和CMOS电路
    用OneFlow实现数据类型自动提升
    Redis启动时提示Creating Server TCP listening socket *:6379: bind: No error
    JS-事件委托-阻止事件冒泡和阻止默认行为-滚动事件-加载事件-元素尺寸位置
    Apache ShardingSphere 5.1.2 发布|全新驱动 API + 云原生部署,打造高性能数据网关...
    Milvus Cloud——LLM Agent 现阶段出现的问题
    Docker error
    E9000服务器更改初始密码
    大数据之LibrA数据库常见术语(二)
    @设计模式-代理模式
  • 原文地址:https://blog.csdn.net/weixin_45728126/article/details/127630626