G3log now available on GitHub: github.com/KjellKod/g3log

Thanks to popular request you can now find g3log on GitHub as well as on BitBucket.
Feel free to use whichever repository is best for you.

Use github.com/KjellKod/g3log or bitbucket.com/KjellKod/g3log (it’s moved to be only at github)

Advertisements

About kjellkod

Software Engineer by trade, (former?) Martial Artist and Champion by strong will and small skill... and a Swede by nationality :)
This entry was posted in Uncategorized. Bookmark the permalink.

2 Responses to G3log now available on GitHub: github.com/KjellKod/g3log

  1. Hello, i am trying to connect websocketpp to output messages through g3log.
    Websocketpp provides a facility accepting an ostream: server.get_alog().set_ostream()
    So i tried this: server.get_alog().set_ostream(&(INTERNAL_LOG_MESSAGE(INFO).stream()));
    Suffice to say it does not work since the messages are not getting into the log, plus this sentence generates an empty entry in the logs: 2015/03/13 17:53:29.161 INFO [ConnectionManager.cpp L: 9] “”

    So my question is: does g3log provides an ostream to write into ? if it does, how do i get it, if it does not, how can i make it?

    Regards.

    • kjellkod says:

      Cool. I hadn’t thought of that scenario.

      As you probably already have figured out:
      ————
      The INTERNAL_LOG_MESSAGE sets up a simple struct “LogCapture” and calls it stream operator.

      I.e
      LOG(INFO) << "Hello";
      is really
      INTERNAL_LOG_MESSAGE(level).stream() << "Hello";
      which becomes
      LogCapture(__FILE__, __LINE__, __PRETTY_FUNCTION__, level).stream() << "Hello";

      Once the LogCapture struct goes out of scope it will forward the captured data as a LogMessage to the background log worker. I.e. if you save the reference to the stream then you are playing with a dangling pointer.

      ** surprised no crashes **

      So if you want to buffer up a lot of data for some time and then push it out I suggest you either
      1) Do it in one INTERNAL_LOG_MESSAGE(INFO).stream() << your stuff goes here.

      2) Or you can have your own LogCapture struct that you create (on the heap makes most sense). Call the stream() funcion on it whenever it pleases. Then let it go out of scope (delete it).

      At deletion/scope exit. That's when the LogMessage will be forwarded.

      Files to look in.
      g2log.hpp
      g2log.cpp
      g2logmessagecapture.hpp.cpp
      g2logmessage.hpp.cpp

      Feel free to email me directly if you have more questions.
      Hedstrom at KjellKod dot cc

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s