test-cpp-enable-rolling.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 #include <fstream>
7 
8 TEST_CASE("ROLLING C++ LOGGER", "[log]") {
9 
10  std::string log_filename = "rolling-log.log";
11  rs2::log_to_file(RS2_LOG_SEVERITY_INFO, log_filename.c_str());
12 
13  int max_size = 1;
15 
16  for (int i = 0; i < 15000; ++i)
17  {
18  const std::string msg("debug message ");
20  }
21 
23 
24  std::ifstream log_file(log_filename.c_str(), std::ios::binary | std::ios::in);
25  REQUIRE(log_file.good());
26  log_file.seekg(0, std::ios::end);
27  auto log_size = log_file.tellg();
28 
29  std::string old_filename = log_filename + ".old";
30  std::ifstream old_file(old_filename.c_str(), std::ios::binary | std::ios::in);
31  REQUIRE(old_file.good());
32  old_file.seekg(0, std::ios::end);
33  auto old_size = old_file.tellg();
34  auto max_size_in_bytes = max_size * 1024 * 1024;
35  auto size = log_size + old_size;
36  REQUIRE(size <= 2 * max_size_in_bytes);
37 
38 }
GLuint GLuint end
void reset_logger()
Definition: rs.hpp:33
void log(rs2_log_severity severity, const char *message)
Definition: rs.hpp:149
GLsizei const GLchar *const * string
static const char * log_filename
Definition: model-views.h:162
GLsizeiptr size
REQUIRE(n_callbacks==1)
void log_to_file(rs2_log_severity min_severity, const char *file_path=nullptr)
Definition: rs.hpp:26
GLuint in
Definition: glext.h:8859
const GLuint GLenum const void * binary
Definition: glext.h:1882
void enable_rolling_log_file(unsigned max_size)
Definition: rs.hpp:47
REQUIRE_NOTHROW(rs2_log(RS2_LOG_SEVERITY_INFO,"Log message using rs2_log()", nullptr))
int i
TEST_CASE("ROLLING C++ LOGGER","[log]")
std::string to_string(T value)


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