Files
openvino/tools/legacy/benchmark_app/slog.hpp
T
f55e69d656 Legacy benchmark_app is added (#10239)
* Legacy benchmark_app is added

* apply fix for supporting multiple -i arguments

* new CMakeLists.txt with OpenCV auto detection

* fixes

* docs

* docs2

* Docs changes

* docs

* CMakeLists.txt modification

* Update tools/legacy/benchmark_app/README.md

Co-authored-by: ivikhrev <ivan.vikhrev@intel.com>
Co-authored-by: Vladimir Dudnik <vladimir.dudnik@intel.com>
2022-02-28 12:26:41 +03:00

75 lines
1.7 KiB
C++

// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
/**
* @brief a header file with logging facility for common samples
* @file log.hpp
*/
#pragma once
#include <ostream>
#include <string>
namespace slog {
/**
* @class LogStreamEndLine
* @brief The LogStreamEndLine class implements an end line marker for a log stream
*/
class LogStreamEndLine {};
static constexpr LogStreamEndLine endl;
/**
* @class LogStreamBoolAlpha
* @brief The LogStreamBoolAlpha class implements bool printing for a log stream
*/
class LogStreamBoolAlpha {};
static constexpr LogStreamBoolAlpha boolalpha;
/**
* @class LogStream
* @brief The LogStream class implements a stream for sample logging
*/
class LogStream {
std::string _prefix;
std::ostream* _log_stream;
bool _new_line;
public:
/**
* @brief A constructor. Creates an LogStream object
* @param prefix The prefix to print
*/
LogStream(const std::string& prefix, std::ostream& log_stream);
/**
* @brief A stream output operator to be used within the logger
* @param arg Object for serialization in the logger message
*/
template <class T>
LogStream& operator<<(const T& arg) {
if (_new_line) {
(*_log_stream) << "[ " << _prefix << " ] ";
_new_line = false;
}
(*_log_stream) << arg;
return *this;
}
// Specializing for LogStreamEndLine to support slog::endl
LogStream& operator<<(const LogStreamEndLine&);
// Specializing for LogStreamBoolAlpha to support slog::boolalpha
LogStream& operator<<(const LogStreamBoolAlpha&);
};
extern LogStream info;
extern LogStream warn;
extern LogStream err;
} // namespace slog