Keywords: UE4 UE_LOG & ScreenDebugMessage Notes

UE_LOG

三种方式:

方式1:GLog
GLog->Log("Does something");
方式2:UE_LOG(LogTemp)
UE_LOG(LogTemp, Log, TEXT("%d"), 1111);
UE_LOG(LogTemp, Warning, TEXT("%d"), 1111);
方式3:自定义log

转载自:http://www.cnblogs.com/pengyingh/articles/5472998.html

头文件中加入:

#pragma once

#include "GameFramework/Actor.h"
#include "FloatingActor.generated.h"
DECLARE_LOG_CATEGORY_EXTERN(YourLog, Log, All);

cpp文件中加入:

#include "FirstProject.h"
#include "FloatingActor.h"

DEFINE_LOG_CATEGORY(YourLog);

使用

UE_LOG(YourLog, Warning, TEXT("Test UE_LOG %d"), rand());

自定义log时设定log级别:

DEFINE_LOG_CATEGORY_STATIC(LogGameNetworkManager, Log, All);

其中:LogGameNetworkManager为Log名,Log为运行时log级别,All为编译期间的log级别。

方式1和方式2的输出结果
Does something
LogTemp: 1111
LogTemp: Warning: 1111(黄色)

AddOnScreenDebugMessage

How to display screen debug message in fixed row
//display messag in second row (key = 1) when there're mulitple message in screen.
GEngine->AddOnScreenDebugMessage(1, 1.f, FColor::Green, FString("aaaaa"), false);

bNewerOnTop only works with Key == INDEX_NONE

Building Log

Build log from engine source building
D:\UnrealEngine-4.10.0-release\Engine\Programs\AutomationTool\Saved\Logs\
Build log from installed distributions of engine

todo

Verbosity Levels

Engine\Source\Runtime\Core\Public\Logging\LogVerbosity.h

/** 
 * Enum that defines the verbosity levels of the logging system.
 * Also defines some non-verbosity levels that are hacks that allow
 * breaking on a given log line or setting the color.
**/
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
    };
}