[Unreal]#20_Log

2022. 11. 2. 10:31· 게임개발/Unreal C++
목차
  1.  
  2. [Unreal]#20_Log

 

[Unreal]#20_Log

Unreal 개발 중 "Debugging"에 대해 알아보겠습니다.

커스텀 로그 클래스를 생성하고 활용하는 방법에 대해 살펴보겠습니다.

 

 


 

로그

1. ELogVerbosity

namespace ELogVerbosity
{
    enum Type
    {
        NoLogging        = 0,
        Fatal,
        Error,
        Warning,
        Display,
        Log,
        Verbose,
        VeryVerbose,
        All              = VeryVerbose,
        NumVerbosity,
        VerbosityMask    = 0xf,
        SetColor         = 0x40,
        BreakOnLog       = 0x80,
    }
}
  • 단순히, 로깅 메세지의 컬러를 변경합니다.
  • "Fatal" 타입만 예외적으로, 메세지가 출력되면 Crash가 발생합니다!

 

2. Custom Log Category

DEFINE_LOG_CATEGORY_STATIC(GameProject, Display, All)
  • LogTemp 대신, 다른 로그 카테고리를 활용하기위해 위 문장이 필요합니다!

 

3. 메크로 

출저: https://www.kernelpanic.kr/50

  • 해당 메크로들은 디버깅 로그시 유용하게 활용할 수 있겠죠!

 

커스텀 로그 클래스

1. /Utilities/CustomLog.h

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"

#define PrintLine(){ CLog::Log(__FUNCTION__, __LINE__);}

/**
 * 
 */
class DARKSOUL_API CustomLog
{

public:
	static void Print(int32 InValue, int32 InKey = -1, float Duration = 10.0f, FColor InColor = FColor::Blue);
	static void Print(float InValue, int32 InKey = -1, float Duration = 10.0f, FColor InColor = FColor::Blue);
	static void Print(const FString& InValue, int32 InKey = -1, float Duration = 10.0f, FColor InColor = FColor::Blue);
	static void Print(const FVector& InValue, int32 InKey = -1, float Duration = 10.0f, FColor InColor = FColor::Blue);
	static void Print(const FRotator& InValue, int32 InKey = -1, float Duration = 10.0f, FColor InColor = FColor::Blue);

	static void Log(int32 InValue);
	static void Log(float InValue);
	static void Log(const FString& InValue);
	static void Log(const FVector& InValue);
	static void Log(const FRotator& InValue);
	static void Log(const UObject* InObject);
	static void Log(const FString& InFuncName, int32 InLineNumber);
};

 

2. /Utilities/CustomLog.cpp

// Fill out your copyright notice in the Description page of Project Settings.


#include "CustomLog.h"
#include "Engine.h"

DEFINE_LOG_CATEGORY_STATIC(GameProject, Display, All)

void CustomLog::Print(int32 InValue, int32 InKey, float Duration, FColor InColor)
{
	GEngine->AddOnScreenDebugMessage(InKey, Duration, InColor, FString::FromInt(InValue));
}

void CustomLog::Print(float InValue, int32 InKey, float Duration, FColor InColor)
{
	GEngine->AddOnScreenDebugMessage(InKey, Duration, InColor, FString::SanitizeFloat(InValue));
}

void CustomLog::Print(const FString& InValue, int32 InKey, float Duration, FColor InColor)
{
	GEngine->AddOnScreenDebugMessage(InKey, Duration, InColor, InValue);
}

void CustomLog::Print(const FVector& InValue, int32 InKey, float Duration, FColor InColor)
{
	GEngine->AddOnScreenDebugMessage(InKey, Duration, InColor, InValue.ToString());
}

void CustomLog::Print(const FRotator& InValue, int32 InKey, float Duration, FColor InColor)
{
	GEngine->AddOnScreenDebugMessage(InKey, Duration, InColor, InValue.ToString());
}

void CustomLog::Log(int32 InValue)
{
	UE_LOG(GameProject, Display, L"%d", InValue);
}

void CustomLog::Log(float InValue)
{
	UE_LOG(GameProject, Display, L"%f", InValue);
}

void CustomLog::Log(const FString& InValue)
{
	UE_LOG(GameProject, Display, L"%s", *InValue);
}

void CustomLog::Log(const FVector& InValue)
{
	UE_LOG(GameProject, Display, L"%s", *InValue.ToString());
}

void CustomLog::Log(const FRotator& InValue)
{
	UE_LOG(GameProject, Display, L"%s", *InValue.ToString());
}

void CustomLog::Log(const UObject* InObject)
{
	FString str;
	if (!!InObject)
		str.Append(InObject->GetName());

	str.Append(!!InObject ? " Not Null" : "Null");

	UE_LOG(GameProject, Display, L"%s", *str);
}

void CustomLog::Log(const FString& InFuncName, int32 InLineNumber)
{
	FString str;
	str.Append(InFuncName);
	str.Append(", ");
	str.Append(FString::FromInt(InLineNumber));

	UE_LOG(GameProject, Display, L"%s", *str);
}

 

 

 

'게임개발 > Unreal C++' 카테고리의 다른 글

[Unreal]#22_TTuple  (0) 2023.02.05
[Unreal]#21_Custom Delegate  (0) 2022.11.02
[Unreal]#19_Custom Behavior Tree Service  (0) 2022.10.05
[Unreal]#18_Custom Behavior Tree Task  (0) 2022.10.05
[Unreal]#17_Behavior Tree  (1) 2022.10.04
  1.  
  2. [Unreal]#20_Log
'게임개발/Unreal C++' 카테고리의 다른 글
  • [Unreal]#22_TTuple
  • [Unreal]#21_Custom Delegate
  • [Unreal]#19_Custom Behavior Tree Service
  • [Unreal]#18_Custom Behavior Tree Task
Hardii2
Hardii2
Hardii2
개발 블로그
Hardii2
전체
오늘
어제
  • 분류 전체보기
    • 알고리즘
    • 웹 개발
      • Node.js
      • React
    • 게임개발
      • DirectX12
      • 관련 지식
      • Unreal C++
      • Unreal 블루프린트
    • 언어
      • Effective C++
      • Basic C++
      • 디자인 패턴
      • 자료구조
      • 기술 질문
    • 문제 풀이
      • BOJ 문제 풀이
      • Programmers 문제 풀이
      • geeksForgeeks 문제 풀이
    • 수학
      • 확률과 통계
      • 게임수학
    • 개인프로젝트
    • 그룹프로젝트
      • PM
      • Dev
    • Github

블로그 메뉴

  • 홈
  • 글쓰기

공지사항

인기 글

태그

  • set
  • BFS
  • C++
  • 기술 질문
  • 디자인 패턴
  • dfs
  • 정렬
  • 그래프
  • 개발
  • 트리
  • 최단 경로
  • DP
  • 알고리즘
  • 우선순위 큐
  • programmers
  • Unreal Blueprint
  • stl
  • unreal
  • Effective C++
  • BOJ

최근 댓글

최근 글

hELLO · Designed By 정상우.v4.2.2
Hardii2
[Unreal]#20_Log
상단으로

티스토리툴바

개인정보

  • 티스토리 홈
  • 포럼
  • 로그인

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.