test-two-callbacks.cpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2020 Intel Corporation. All Rights Reserved.
3 
4 //#cmake:add-file log-common.h
5 #include "log-common.h"
6 
7 
8 TEST_CASE( "Logging to two callbacks", "[log]" ) {
9 
10  size_t n_callbacks_1 = 0;
11  auto callback1 = [&]( rs2_log_severity severity, rs2::log_message const& msg )
12  {
13  ++n_callbacks_1;
14  TRACE( severity << ' ' << msg.filename() << '+' << msg.line_number() << ": " << msg.raw() );
15  };
16  size_t n_callbacks_2 = 0;
17  auto callback2 = [&]( rs2_log_severity severity, rs2::log_message const& msg )
18  {
19  ++n_callbacks_2;
20  TRACE( severity << ' ' << msg.filename() << '+' << msg.line_number() << ": " << msg.raw() );
21  };
22 
25 
26  REQUIRE( !n_callbacks_1 );
27  REQUIRE( !n_callbacks_2 );
28  log_all(); // one error should go to each
29  REQUIRE( n_callbacks_1 == 1 );
30  REQUIRE( n_callbacks_2 == 1 );
31 }
GLenum GLuint GLenum severity
void log_to_callback(rs2_log_severity min_severity, S callback)
Definition: rs.hpp:139
void log_all()
Definition: log-common.h:35
TEST_CASE("Logging to two callbacks","[log]")
REQUIRE(n_callbacks==1)
REQUIRE_NOTHROW(rs2_log(RS2_LOG_SEVERITY_INFO,"Log message using rs2_log()", nullptr))
rs2_log_severity
Severity of the librealsense logger.
Definition: rs_types.h:153


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:50:11