Blue Brain BioExplorer
Logs.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2024, EPFL/Blue Brain Project
3  *
4  * The Blue Brain BioExplorer is a tool for scientists to extract and analyse
5  * scientific data from visualization
6  *
7  * This file is part of Blue Brain BioExplorer <https://github.com/BlueBrain/BioExplorer>
8  *
9  * This library is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU Lesser General Public License version 3.0 as published
11  * by the Free Software Foundation.
12  *
13  * This library is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 
23 #pragma once
24 
25 #include <iostream>
26 
27 namespace core
28 {
29 #define PLUGIN_PREFIX "OPTIX_6_ENGINE "
30 #define PROGRESS_BAR_SIZE 50
31 
32 #define PLUGIN_ERROR(message) std::cerr << "E [" << PLUGIN_PREFIX << "] " << message << std::endl;
33 #define PLUGIN_WARN(message) std::cerr << "W [" << PLUGIN_PREFIX << "] " << message << std::endl;
34 #define PLUGIN_INFO(message) std::cout << "I [" << PLUGIN_PREFIX << "] " << message << std::endl;
35 
36 #ifdef NDEBUG
37 #define PLUGIN_DEBUG(message)
38 #else
39 #define PLUGIN_DEBUG(message) std::cout << "D [" << PLUGIN_PREFIX << "] " << message << std::endl;
40 #endif
41 
42 #define PLUGIN_TIMER(__time, __msg) \
43  std::cout << "T [" << PLUGIN_PREFIX << "] [" << __time << "] " << __msg << std::endl;
44 
45 #define PLUGIN_THROW(message) \
46  { \
47  throw std::runtime_error(message); \
48  }
49 
50 #define PLUGIN_PROGRESS(__msg, __progress, __maxValue) \
51  { \
52  std::cout << "I [" << PLUGIN_PREFIX << "] ["; \
53  const float __mv = float(__maxValue); \
54  const float __p = float(__progress + 1); \
55  const uint32_t __pos = std::min(PROGRESS_BAR_SIZE, int(__p / __mv * PROGRESS_BAR_SIZE)); \
56  for (uint32_t __i = 0; __i < PROGRESS_BAR_SIZE; ++__i) \
57  { \
58  if (__i < __pos) \
59  std::cout << "="; \
60  else if (__i == __pos) \
61  std::cout << ">"; \
62  else \
63  std::cout << " "; \
64  } \
65  std::cout << "] " << std::min(__pos * 2, uint32_t(PROGRESS_BAR_SIZE * 2)) << "% " << __msg << "\r"; \
66  std::cout.flush(); \
67  }
68 } // namespace core