[UE4] Output LOG and definition

In the .h file, fill in the following code:

DECLARE_LOG_CATEGORY_EXTERN(YourLog, Log, All);

In the .cpp file, fill in the following code:

DEFINE_LOG_CATEGORY(YourLog);

The output format is as follows:

(1)UE_LOG(LogTemp, Warning, TEXT("Problem on load Province Message!"));

(2)UE_LOG(LogTemp, Warning, TEXT("Content:%s"), *(Response->GetContentAsString()));

  1. UE_LOG(CategoryName,Warning,TEXT("MyCharacter's Health is %d"), MyCharacter->Health );

  2. UE_LOG(CategoryName,Warning,TEXT("MyCharacter's Health is %f"), MyCharacter->Health );

  3. UE_LOG(CategoryName,Warning,TEXT("MyCharacter's Name is %s"), *MyCharacter->GetName() );

/** * A macro to declare a logging category as a C++ "extern" * @param CategoryName, category to declare * @param DefaultVerbosity, default run time verbosity * @param CompileTimeVerbosity, maximum verbosity to compile into the code **/ #define DECLARE_LOG_CATEGORY_EXTERN(CategoryName, DefaultVerbosity, CompileTimeVerbosity) externstructFLogCategory##CategoryName : public FLogCategory<ELogVerbosity::DefaultVerbosity, ELogVerbosity::CompileTimeVerbosity> {     FORCEINLINEFLogCategory##CategoryName() : FLogCategory(TEXT(#CategoryName)) {} }CategoryName;   /** * A macro to define a logging category, usually paired with DECLARE_LOG_CATEGORY_EXTERN from the header. * @param CategoryName, category to define **/ #define DEFINE_LOG_CATEGORY(CategoryName) FLogCategory##CategoryName CategoryName;   /** * A macro to define a logging category as a C++ "static" * @param CategoryName, category to declare * @param DefaultVerbosity, default run time verbosity * @param CompileTimeVerbosity, maximum verbosity to compile into the code **/ #define DEFINE_LOG_CATEGORY_STATIC(CategoryName, DefaultVerbosity, CompileTimeVerbosity) staticstructFLogCategory##CategoryName : public FLogCategory<ELogVerbosity::DefaultVerbosity, ELogVerbosity::CompileTimeVerbosity> {     FORCEINLINEFLogCategory##CategoryName() : FLogCategory(TEXT(#CategoryName)) {} }CategoryName;   /** * A macro to declare a logging category as a C++ "class static" * @param CategoryName, category to declare * @param DefaultVerbosity, default run time verbosity * @param CompileTimeVerbosity, maximum verbosity to compile into the code **/ #define DECLARE_LOG_CATEGORY_CLASS(CategoryName, DefaultVerbosity, CompileTimeVerbosity) DEFINE_LOG_CATEGORY_STATIC(CategoryName,DefaultVerbosity,CompileTimeVerbosity)   /** * A macro to define a logging category, usually paired with DECLARE_LOG_CATEGORY_CLASS from the header. * @param CategoryName, category to definee **/ #define DEFINE_LOG_CATEGORY_CLASS(Class, CategoryName) Class::FLogCategory##CategoryName Class::CategoryName;  

namespaceELogVerbosity { enumType { /** Not used */ NoLogging=0,   /** Always prints s 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 }; }