[Native][C++] How to log WebRTC related stuff in file.

1,138 views
Skip to first unread message

rudresh pandey

unread,
Jan 13, 2014, 1:54:54 AM1/13/14
to discuss...@googlegroups.com

Hi,

While going through the Peerconnection_client sample on windows, I see that log are being displayed in debugger console that are generated by WebRTC Libs.
Also in some member function they are putting it explicitly like LOG(INFO) << __FUNCTION__;

I want these thing to be written on a file. What I need to do?
Please suggest.

Thanks
R.



Francois Temasys

unread,
Jan 14, 2014, 9:13:08 PM1/14/14
to discuss...@googlegroups.com
Great question. I'm also interested by the answer.

Jozsef Vass

unread,
Jan 15, 2014, 4:46:32 PM1/15/14
to discuss...@googlegroups.com
Try including talk/base/logging.h and use LogMessage::ConfigureLogging() method.

Jozsef


--
 
---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

grgk...@gmail.com

unread,
Jan 18, 2014, 2:57:53 AM1/18/14
to discuss...@googlegroups.com
Hi Rudresh,

I normally add the following to the main.cc in the beginning of the function wWinMain:

bool debug = true;
   std::string log = "verbose";

   if (debug) {
       talk_base::LogMessage::LogToDebug(talk_base::LS_VERBOSE);
   }

   if (!log.empty()) {
       talk_base::FileStream *fs = new talk_base::FileStream();
       if (!fs->Open("peerconnectionclient.log", "w", NULL)) {
           LOG(INFO) << "Could not open file";
       } else {
           talk_base::LogMessage::LogToStream(fs, talk_base::LS_VERBOSE);
       }
   }

The logs will end up in trunk/talk. It is not perfect, but it works for me.

Thanks.
George

Francois Temasys

unread,
Jan 20, 2014, 2:37:16 AM1/20/14
to discuss...@googlegroups.com
Thanks for the sharing George!

Francois Temasys

unread,
Jan 20, 2014, 2:54:56 AM1/20/14
to discuss...@googlegroups.com
In your case, if you are building with gyp/ninja it may be more interesting to use:
#ifdef _DEBUG
talk_base::LogMessage::LogToDebug(talk_base::LS_VERBOSE);

talk_base::FileStream *fs = new talk_base::FileStream();
if (!fs->Open("peerconnectionclient.log", "w", NULL))
  LOG(INFO) << "Could not open file";
else
  talk_base::LogMessage::LogToStream(fs, talk_base::LS_VERBOSE);
#endif

As _DEBUG is defined in the gyp configuration.

Cheers

devel...@gmail.com

unread,
Oct 5, 2016, 4:08:07 AM10/5/16
to discuss-webrtc
Hi,

I'm trying to disable logs, and it doesn't seem to work:

rtc::LogMessage::LogToDebug(rtc::LS_NONE);
rtc::LogMessage::SetLogToStderr(false);

So, probably, something hase changed in the logging system.
Reply all
Reply to author
Forward
0 new messages