test-mixed-file-callback.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: static!
5 
6 //#cmake:add-file log-common.h
7 #include "log-common.h"
8 
9 
10 TEST_CASE( "Mixed file & callback logging", "[log]" ) {
11 
12  char filename[L_tmpnam];
13  tmpnam( filename );
14 
15  TRACE( "Filename logging to: " << filename );
17  size_t n_callbacks = 0;
19  [&]( rs2_log_severity severity, rs2::log_message const& msg )
20  {
21  ++n_callbacks;
22  TRACE( severity << ' ' << msg.filename() << '+' << msg.line_number() << ": " << msg.raw() );
23  } ));
24 
25  // Following should log to both
26  log_all();
27 
28  el::Loggers::flushAll(); // requires static!
29  REQUIRE( count_lines( filename ) == 1 );
30 
31  REQUIRE( n_callbacks == 4 );
32 }
GLenum GLuint GLenum severity
void log_to_callback(rs2_log_severity min_severity, S callback)
Definition: rs.hpp:139
const char * filename() const
Definition: rs.hpp:74
TEST_CASE("Mixed file & callback logging","[log]")
void log_all()
Definition: log-common.h:35
size_t line_number() const
Definition: rs.hpp:66
size_t count_lines(char const *filename)
Definition: log-common.h:48
REQUIRE(n_callbacks==1)
const char * raw() const
Definition: rs.hpp:82
static void flushAll(void)
Flushes all loggers for all levels - Be careful if you dont know how many loggers are registered...
void log_to_file(rs2_log_severity min_severity, const char *file_path=nullptr)
Definition: rs.hpp:26
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