GEngine is available to you from wherever you please; being global (that’s why it’s prefixed with a capital G) you can access it anywhere you like, just make sure you check whether it is not null first.
Simple syntax:
if(GEngine)
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT("Some debug message!"));
Something more complex:
if(GEngine)
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, FString::Printf(TEXT("World delta for current frame equals %f"), GetWorld()->TimeSeconds));
See EngineGlobals.h for how GEngine is defined to learn more.