I am trying to add custom log categories to my project. I have added
DECLARE_LOG_CATEGORY_EXTERN(LogInfo, Log, All);
to my Logger.h file after the include statements.
and added
DECLARE_LOG_CATEGORY(LogInfo);
to Logger.cpp also immediately after the include statements.
When I try to compile I get an error for the .cpp file “this declaration has no storage class or type specifier”
Am I missing something?
Logger.h
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Logger.generated.h"
//Create custom log categories
DECLARE_LOG_CATEGORY_EXTERN(LogInfo, Log, All);
UCLASS()
class TRAFFICSIMRUNTIME_API ALogger : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ALogger();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
};
Logger.cpp
#include “Logger.h”
//Define log categories
DECLARE_LOG_CATEGORY(LogInfo);
// Sets default values
ALogger::ALogger()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void ALogger::BeginPlay()
{
Super::BeginPlay();
//UE_LOG(LogInfo, Log, TEXT("hi"));
}
// Called every frame
void ALogger::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}