Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Migrate from printf to streams in my logfile class.

Migrate from printf to streams in my logfile class.

Scheduled Pinned Locked Moved C / C++ / MFC
questionxml
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    justin223
    wrote on last edited by
    #1

    Hello I've written a logfile class that writes the logentries in xml format. A typical usage: mylog.WriteLog(LOG_PRIO_HIGH, "Agroup", "This is a text with %d some %s vars", 34, "diffrent"); output <entry date="2003-01-01" time="20:01:32:1234" prio="1" group="Agroup">This is a text with 39 some diffrent vars</entry> I want to accomplish the same thing by using streams/stringbuf. But I've not found any good examples that show me how I should do. What i've found is a couple of examples that derives a class from stringbuf and from ostream. I would be nice of I can get something like this: log << log_prio(1) << log_group("test") << "hello" << nIntVar << strBuf << log_end; log << "this is a string"; log << " something more" << log_end; log << log_prio(2) << "last line" << log_end; would look like: <entry date="2003-01-01" time="20:01:32:1234" prio="1" group="test">hello1yeye</entry> <entry date="2003-01-01" time="20:01:32:2200" prio="1" group="test">this is a string something more</entry> <entry date="2003-01-01" time="20:01:32:6600" prio="2" group="test">last line</entry> How do I accomplish this? Thanks, Jonas

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups