c++ - Exclude logging from function -


i've encountered problem multiple times. there "smart" way exclude logging functions? if there logical check (if/else) before logging happens. have if/else excluded too. example:

return_value = init_winsock();  if( return_value != 0 ) {     cout << "(" << __filename__ << ":" << __line__ << "): ";     errorcode_to_string( __function__ ); }  else {     cout << "(" << __filename__ << ":" << __line__      << "): " << "info: winsocked started" << endl; }  socket = socket(    af_inet,                      sock_dgram,                      0 );  if( socket == invalid_socket ) {     cout << "(" << __filename__ << ":" << __line__ << "): ";     errorcode_to_string( __function__ ); }  else {     cout << "(" << __filename__ << ":" << __line__      << "): info: udp socket opened" << endl; } 

i have 2 if/else in seperate function, preferably in one. possible in c++? maybe seperate logging class should neatly possible?

the logging lines have places want log. there no way around this.

that said, idea have logging macros can de-activated when in production, this article explains how (with complete code)


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -