Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
unit-tests
log
log-common.h
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
#pragma once
5
6
#include <
librealsense2/rs.hpp
>
// Include RealSense Cross Platform API
7
8
// Let Catch define its own main() function
9
#define CATCH_CONFIG_MAIN
10
#include "../catch.h"
11
12
#include <
easylogging++.h
>
13
#ifdef BUILD_SHARED_LIBS
14
// With static linkage, ELPP is initialized by librealsense, so doing it here will
15
// create errors. When we're using the shared .so/.dll, the two are separate and we have
16
// to initialize ours if we want to use the APIs!
17
INITIALIZE_EASYLOGGINGPP
18
#endif
19
20
// Define our own logging macro for debugging to stdout
21
// Can possibly turn it on automatically based on the Catch options supplied
22
// on the command-line, with a custom main():
23
// Catch::Session catch_session;
24
// int main (int argc, char * const argv[]) {
25
// return catch_session.run( argc, argv );
26
// }
27
// #define TRACE(X) if( catch_session.configData().verbosity == ... ) {}
28
// With Catch2, we can turn this into SCOPED_INFO.
29
#define TRACE(X) do { \
30
std::cout << X << std::endl; \
31
} while(0)
32
33
34
/* Issue log messages in all severities */
35
void
log_all
()
36
{
37
REQUIRE_NOTHROW
(
rs2::log
(
RS2_LOG_SEVERITY_DEBUG
,
"debug message"
) );
38
REQUIRE_NOTHROW
(
rs2::log
(
RS2_LOG_SEVERITY_INFO
,
"info message"
) );
39
REQUIRE_NOTHROW
(
rs2::log
(
RS2_LOG_SEVERITY_WARN
,
"warn message"
) );
40
REQUIRE_NOTHROW
(
rs2::log
(
RS2_LOG_SEVERITY_ERROR
,
"error message"
) );
41
// NOTE: fatal messages will exit the process and so cannot be tested
42
//REQUIRE_NOTHROW( rs2::log( RS2_LOG_SEVERITY_FATAL, "fatal message" ));
43
REQUIRE_NOTHROW
(
rs2::log
(
RS2_LOG_SEVERITY_NONE
,
"no message"
) );
// ignored; no callback
44
}
45
46
47
/* Return the number of lines in a file */
48
size_t
count_lines
(
char
const
*
filename
)
49
{
50
FILE* pFile = fopen( filename,
"r"
);
51
REQUIRE
( pFile );
52
char
buffer
[512];
53
size_t
line_index = 0;
54
while
( !feof( pFile ) )
55
{
56
if
( fgets( buffer,
sizeof
(buffer), pFile ) ==
NULL
)
57
break
;
58
++line_index;
59
}
60
fclose( pFile );
61
return
line_index;
62
}
RS2_LOG_SEVERITY_ERROR
Definition:
rs_types.h:157
RS2_LOG_SEVERITY_WARN
Definition:
rs_types.h:156
rs2::log
void log(rs2_log_severity severity, const char *message)
Definition:
rs.hpp:149
rs.hpp
buffer
GLenum GLfloat * buffer
Definition:
glad/glad/glad.h:2067
RS2_LOG_SEVERITY_DEBUG
Definition:
rs_types.h:154
log_all
void log_all()
Definition:
log-common.h:35
INITIALIZE_EASYLOGGINGPP
#define INITIALIZE_EASYLOGGINGPP
Definition:
easylogging++.h:4584
count_lines
size_t count_lines(char const *filename)
Definition:
log-common.h:48
REQUIRE
REQUIRE(n_callbacks==1)
easylogging++.h
RS2_LOG_SEVERITY_NONE
Definition:
rs_types.h:159
RS2_LOG_SEVERITY_INFO
Definition:
rs_types.h:155
test-non-realtime.filename
string filename
Definition:
test-non-realtime.py:17
REQUIRE_NOTHROW
REQUIRE_NOTHROW(rs2_log(RS2_LOG_SEVERITY_INFO,"Log message using rs2_log()", nullptr))
NULL
#define NULL
Definition:
tinycthread.c:47
librealsense2
Author(s): Sergey Dorodnicov
, Doron Hirshberg
, Mark Horn
, Reagan Lopez
, Itay Carpis
autogenerated on Mon May 3 2021 02:47:21