Jump to content

Add advanced logging options


klepto2
 Share

Recommended Posts

As i am currently working on a cli tool, i found that the constant "spamming" of UltraEngine logs is quite annoying. 

While these messages are good for debugging or even for release builds,It would by nice to disable them, or redirect them. 

Espescially the messages with just an infomative character should be optional, like "Texture xxx loaded..." othe messages like errors should go to the stderr and everything else should be managed by the developer.

  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

15 hours ago, Josh said:

Paste in the console:

function hook() return false end ListenEvent(EVENT_PRINT, nil, hook)

ok, this prevents any message to be displayed. So, if i want to still use Output i need to write my own print functions, but this is an unforunate step :( maybe the print functions need an optional source parameter. 

In case someone wants a small sample:

bool PrintHook(const Event& ev, shared_ptr<Object> extra)
{
    if (ev.data == 1)
    {
        fwprintf(stdout, ev.text.c_str());
        fflush(stdout);
        return true;
    }

    return false;
}

void PrintLog(const std::string& s) { EmitEvent(EVENT_PRINT, 0, 1, 0, 0, 0, 0, 0, s); }
void PrintLog(const String& s) { PrintLog(std::string(s)); }
void PrintLog(const WString& s, const bool linereturn = true) { EmitEvent(EVENT_PRINT, 0, 1, 0, 0, 0, 0, 0, s + (linereturn ? "\n" : "")); };
void PrintLog(const unsigned int i, const bool linereturn = true) { PrintLog(WString(i), linereturn); }
void PrintLog(const uint64_t i, const bool linereturn = true) { PrintLog(WString(i), linereturn); }
void PrintLog(const int i, const bool linereturn = true) { PrintLog(WString(i), linereturn); }
void PrintLog(const float i, const bool linereturn = true) { PrintLog(WString(i), linereturn); }
void PrintLog(const double i, const bool linereturn = true) { PrintLog(WString(i), linereturn); }
void PrintLog(const bool i, const bool linereturn = true) { PrintLog(WString(i), linereturn); }
void PrintLog(const char* i, const bool linereturn = true) { PrintLog(WString(i), linereturn); }
void PrintLog(const wchar_t* i, const bool linereturn = true) { PrintLog(WString(i), linereturn); }
void PrintLog(const table& t) { PrintLog(string(t)); }
  
int main(int argc, const char* argv[])
{
    ListenEvent(EVENT_PRINT, NULL, PrintHook);
  
  	PrintLog("My-Message");
  	return 0;
}

  

 

  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

Sorry, I should have mentioned that event.text will contain the printed text, so you can use that to filter which messages get printed and which get skipped. Return true and the message will go into the Print routine.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Also, I should mention the LOAD_QUIET load flag will cause asset loading messages to not print. Generally, these get passed along when an auxillary asset is loaded, so if you pass LOAD_QUIET to LoadModel it won't print texture loading messages.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

13 hours ago, Josh said:

Sorry, I should have mentioned that event.text will contain the printed text, so you can use that to filter which messages get printed and which get skipped. Return true and the message will go into the Print routine.

Well, no need for mentioning it. It was very obvious ;)

Filtering is very difficult with the current log messages, maybe the engine logging should be something like this: "[UltraEngine] Timestamp : Texture "xyz" loaded. This way a developer could simply filter out everything which begins with "[UltraEngine]", otherwise this could collide with mesages intended by the developer.

Another way, which might be useful is some kind of log format setting. A simple function ptr which receives the msg and outputs a custom formatted msg. (Could be added to EngineSettings)

  • Haha 1
  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...