test-env-log-level-on.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 // Has to be static or else our setenv won't affect LRS!
5 //#cmake: static!
6 
7 //#cmake: add-file log-common.h
8 #include "log-common.h"
9 #include <stdlib.h>
10 
11 
12 TEST_CASE( "With LRS_LOG_LEVEL", "[log]" ) {
13 
14  REQUIRE( ! getenv( "LRS_LOG_LEVEL" ));
15 #ifdef _WINDOWS
16  _putenv
17 #else
18  putenv
19 #endif
20  ( "LRS_LOG_LEVEL=WARN" );
21  REQUIRE( getenv( "LRS_LOG_LEVEL" ));
22  TRACE( "LRS_LOG_LEVEL=" << getenv( "LRS_LOG_LEVEL" ));
23 
24  size_t n_callbacks = 0;
25  auto callback = [&]( rs2_log_severity severity, rs2::log_message const& msg )
26  {
27  ++n_callbacks;
28  TRACE( severity << ' ' << msg.filename() << '+' << msg.line_number() << ": " << msg.raw() );
29  };
30 
32  REQUIRE( !n_callbacks );
33  log_all();
34  // Without LRS_LOG_LEVEL, the result would be 1 (error)
35  //REQUIRE( n_callbacks == 1 );
36  // But, since we have the log-level forced to warning:
37  REQUIRE( n_callbacks == 2 );
38 }
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
REQUIRE(n_callbacks==1)
def callback(frame)
Definition: t265_stereo.py:91
TEST_CASE("With LRS_LOG_LEVEL","[log]")
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