Skip to content

Commit d880bd0

Browse files
committed
log_record now don't log on destruction, logging macro will.
1 parent b2be660 commit d880bd0

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

include/network/detail/debug.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
# include <network/logging/logging.hpp>
2525
# ifndef NETWORK_MESSAGE
26-
# define NETWORK_MESSAGE(msg) network::logging::log_record( __FILE__, __LINE__ ) << msg;
26+
# define NETWORK_MESSAGE(msg) { network::logging::log( network::logging::log_record( __FILE__, __LINE__ ) << msg ); }
2727
# endif
2828

2929
#else

include/network/logging/logging.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,7 @@ class log_record
5151
, m_line( line )
5252
{
5353
}
54-
55-
~log_record()
56-
{
57-
log( *this );
58-
}
59-
54+
6055
template< typename TypeOfSomething >
6156
log_record& write( TypeOfSomething&& something )
6257
{

libs/network/test/logging/logging_custom_handler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ BOOST_AUTO_TEST_CASE(custom_log_handler_output) {
2828
const auto message = "At line " + std::to_string(line_num) + " we check the code.";
2929

3030
set_log_record_handler( custom_log_handler );
31-
log_record( file_name, line_num ) << "At line " << line_num << " we check the code.";
31+
log( log_record( file_name, line_num ) << "At line " << line_num << " we check the code." );
3232

3333
const auto result_output = log_output.str();
3434

libs/network/test/logging/logging_log_record.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include <boost/test/unit_test.hpp>
1111

1212
#include <network/logging/logging.hpp>
13+
#define NETWORK_ENABLE_LOGGING
14+
#include <network/detail/debug.hpp>
1315

1416
using namespace network::logging;
1517

@@ -68,4 +70,9 @@ BOOST_AUTO_TEST_CASE(text_stream) {
6870

6971
BOOST_AUTO_TEST_CASE(raw_log) {
7072
log( "This is a raw log." );
73+
}
74+
75+
BOOST_AUTO_TEST_CASE(macro_log) {
76+
NETWORK_MESSAGE( "This is a log through the macro." );
77+
NETWORK_MESSAGE( "This is a log through the macro, with a stream! Num=" << 42 << " - OK!" );
7178
}

0 commit comments

Comments
 (0)