Unreal Engine C++: log categories

// MyLogCategory.h

// MYGAME_API will be needed if the category is to be used outside the module.
MYGAME_API DECLARE_LOG_CATEGORY_EXTERN(LogMyGameLog, Log, All);

//MyLogCategory.cpp
DEFINE_LOG_CATEGORY(LogMyGameLog);

Include the above header where you want to use the category.

#include "MyLogCategory.h"

// you can now use your category:
{
    UE_LOG(LogMyGame, Display, Text("a message"));
}

If used in another module, set up the dependency to the category’s module. for instance in MyOtherModule.Build.cs:

PublicDependencyModuleNames.AddRange(new string[] { "Core", "MyGame" });

No comments

(optional field, I won't disclose or spam but it's necessary to notify you if I respond to your comment)
All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.
Anti-spam question: