lundi 20 juillet 2015

Logger with preformatted text, output to console and optionally output to file

I need a logger for my application (no console application), wich shall fit following requirements:

  1. Preformatted text for my message, e.g.

[MyApp] on 01.02.2015_12:12:12:123 : Library calc.dll load - OK

  1. Output to console (seperate window shell@linux or cmd@windows etc. additional to my WidgetWindow)
  2. Output to file for each application run, I want to create a debug-.log

For instance I only forward "Library calc.dll load - OK" to the debug function, which then creates the final string "[MyApp] on 01.02.2015_12:12:12:123 : Library calc.dll load - OK"

Here I have a WidgetApp with a MainWindow. In that MainWindow I can toggle in the MainMenu a checkbox "Activate logging". When that is activated, a second window (basically a console) should be opened, where all the debug output is written.

And that very same output shall be able to be written to a file as well.

The qInstallMessageHandler was recommended in my previous question, but its documentation says:

With Windows, if it is a console application, the text is sent to console; otherwise, it is sent to the debugger.

Since my MainWindow is a Widget, I think that does not work for me? I would prefer Qt libs.

Aucun commentaire:

Enregistrer un commentaire