/** * 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 { enumType : 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 }; }
可以根据自己的需求来指定不同的日志等级。
DECLARE_LOG_CATEGORY_EXTERN
1 2 3 4 5 6 7 8 9 10 11
/** * A macro to declare a logging category as a C++ "extern", usually declared in the header and paired with DEFINE_LOG_CATEGORY in the source. Accessible by all files that include the header. * @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) \ extern struct FLogCategory###CategoryName : public FLogCategory<ELogVerbosity::DefaultVerbosity, ELogVerbosity::CompileTimeVerbosity> \ { \ FORCEINLINE FLogCategory###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". This should ONLY be declared in a source file. Only accessible in that single file. * @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) \ static struct FLogCategory###CategoryName : public FLogCategory<ELogVerbosity::DefaultVerbosity, ELogVerbosity::CompileTimeVerbosity> \ { \ FORCEINLINE FLogCategory###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)
// Platform specific logs, set here to make it easier to use them from anywhere // need another layer of macro to help using a define in a define #define DECLARE_LOG_CATEGORY_EXTERN_HELPER(A,B,C) DECLARE_LOG_CATEGORY_EXTERN(A,B,C)