Frage

Wie protokolliere ich mehr als eine einzige Zeichenfolge mit log4cpp?

z.Wenn ich alle Argvs zum Hauptanschluss anmelden möchte: generasacodicetagpre.

die linie generasacodicetagpre.

kompiliert nicht.Natürlich funktioniert der Logger nicht als ostream .Was ist der log4cppp-way , um so etwas wie dieses, vorzuziehen, auf einmal vorzuziehen?

War es hilfreich?

Lösung

You have two options:

  • Use printf-style formatting:

    for (int i = 0; i < argc; ++i)
    {   
        category.info("argv[%d] = '%s'", i, argv[i]);
    }  
    
  • Use infoStream():

    for (int i = 0; i < argc; ++i)
    {
        category.infoStream() << "argv[" << i << "] = '" << argv[i] << "'";
    }  
    

I'd go with the latter.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top