KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
logging_settings.hpp
Go to the documentation of this file.
1 // KRATOS ______ __ __ _____ __ __ __
2 // / ____/___ ____ / /_____ ______/ /_/ ___// /________ _______/ /___ ___________ _/ /
3 // / / / __ \/ __ \/ __/ __ `/ ___/ __/\__ \/ __/ ___/ / / / ___/ __/ / / / ___/ __ `/ /
4 // / /___/ /_/ / / / / /_/ /_/ / /__/ /_ ___/ / /_/ / / /_/ / /__/ /_/ /_/ / / / /_/ / /
5 // \____/\____/_/ /_/\__/\__,_/\___/\__//____/\__/_/ \__,_/\___/\__/\__,_/_/ \__,_/_/ MECHANICS
6 //
7 // License: BSD License
8 // license: ContactStructuralMechanicsApplication/license.txt
9 //
10 // Main authors: Mohamed Khalil
11 //
12 
13 #pragma once
14 
15 // only tested on mac console
16 // for linux, prefix \033 should be changed to \e
17 // colors
18 #define RESET "\033[0m"
19 #define BLACK "\033[30m"
20 #define RED "\033[31m"
21 #define GREEN "\033[32m"
22 #define YELLOW "\033[33m"
23 #define BLUE "\033[34m"
24 #define MAGENTA "\033[35m"
25 #define CYAN "\033[36m"
26 #define WHITE "\033[37m"
27 #define DK_GREY "\033[90m"
28 #define LT_GREY "\033[37m"
29 #define LT_RED "\033[91m"
30 #define LT_GREEN "\033[92m"
31 #define LT_YELLOW "\033[93m"
32 #define LT_BLUE "\033[94m"
33 #define LT_MAGENTA "\033[95m"
34 #define LT_CYAN "\033[96m"
35 
36 // formatting
37 #define BOLD "\033[1m"
38 #define DIM "\033[2m"
39 #define UNDERLINE "\033[4m"
40 
41 // output level
43 
44 // Logging macros
45 #define RESET_LOG_SETTINGS \
46  std::cout << RESET << std::endl;
47 
48 #define LOG_GENERAL(color, message, variable)\
49  std::cout << color << message << variable; \
50  RESET_LOG_SETTINGS
51 
52 #define LOG_DEBUG(variable)\
53  std::cout << BOLD << YELLOW << #variable << " : " << LT_YELLOW << variable; \
54  RESET_LOG_SETTINGS
55 
56 #define LOG_INFO(variable)\
57  std::cout << BOLD << GREEN << #variable << " : " << LT_GREEN << variable; \
58  RESET_LOG_SETTINGS
59 
60 #define LOG_WARNING(variable)\
61  std::cout << BOLD << RED << #variable << " : " << LT_RED << variable; \
62  RESET_LOG_SETTINGS
63 
64 #define LOG_DEBUG_HEADER(header, variable)\
65  std::cout << BOLD << UNDERLINE << YELLOW << #header; \
66  RESET_LOG_SETTINGS \
67  std::cout << BOLD << YELLOW << #variable << " : " << LT_YELLOW << variable\
68  RESET_LOG_SETTINGS
69 
70 #define LOG_INFO_HEADER(header, variable)\
71  std::cout << BOLD << UNDERLINE << GREEN << #header; \
72  RESET_LOG_SETTINGS \
73  std::cout << BOLD << GREEN << #variable << " : " << LT_GREEN << variable\
74  RESET_LOG_SETTINGS
75 
76 #define LOG_WARNING_HEADER(header, variable)\
77  std::cout << BOLD << UNDERLINE << RED << #header; \
78  RESET_LOG_SETTINGS \
79  std::cout << BOLD << RED << #variable << " : " << LT_RED << variable\
80  RESET_LOG_SETTINGS
81 
85 
86 #define DEBUG_MSG( message )\
87  std::cout << BOLD << GREEN << UNDERLINE << "DEBUG" << RESET << std::endl;\
88  std::cout << BOLD << GREEN << message << std::endl;\
89  RESET_LOG_SETTINGS
90 
91 #define INFO_MSG( message )\
92  std::cout << BOLD << DK_GREY << UNDERLINE << "INFO : " << RESET << std::endl;\
93  std::cout << BOLD << DK_GREY << message << std::endl;\
94  RESET_LOG_SETTINGS
95 
96 #define WARNING_MSG( message )\
97  std::cout << BOLD << YELLOW << UNDERLINE << "WARNING" << RESET << std::endl;\
98  std::cout << BOLD << YELLOW << message << std::endl;\
99  RESET_LOG_SETTINGS
100 
101 #define ERROR_MSG( message, function )\
102  std::cout << BOLD << RED << UNDERLINE << "ERROR from " << function << RESET << std::endl;\
103  std::cout << BOLD << RED << message << std::endl;\
104  RESET_LOG_SETTINGS
105 
106 
110 
111 /*
112  * DEFINE LOG SETTINGS
113  */
114 #define TENSOR_LOG_SETTINGS \
115  std::cout << CYAN;\
116  std::cout.precision(2);\
117 
118 /*
119  * DEFINE FUNCTIONALITIES
120  */
121 #define LOG_MATRIX_PRETTY( matrix )\
122  TENSOR_LOG_SETTINGS \
123  std::cout << #matrix << " : [ " << matrix.size1() << " x " << matrix.size2() << " ] :" << std::endl;\
124  for ( unsigned int i = 0; i < matrix.size1( ); ++i )\
125  {\
126  for ( unsigned int j = 0; j < matrix.size2( ); ++j )\
127  std::cout << std::scientific << matrix(i,j) << "\t";\
128  std::cout << std::endl;\
129  }\
130  RESET_LOG_SETTINGS
131 
132 #define LOG_VECTOR_PRETTY( vector )\
133  TENSOR_LOG_SETTINGS \
134  std::cout << #vector << " : " << std::scientific << vector;\
135  RESET_LOG_SETTINGS
136 
137 #define LOG_VECTOR3( array )\
138  TENSOR_LOG_SETTINGS \
139  std::cout << #array << " : " << std::scientific << array[0] << ", " << std::scientific << array[1] << ", " << std::scientific << array[2];\
140  RESET_LOG_SETTINGS
141 
142 #define LOG_VECTOR2( array )\
143  TENSOR_LOG_SETTINGS \
144  std::cout << #array << " : " << std::scientific << array[0] << ", " << std::scientific << array[1];\
145  RESET_LOG_SETTINGS
146 
147 #define LOG_SCALAR( scalar )\
148  TENSOR_LOG_SETTINGS \
149  std::cout << #scalar << " : " << std::scientific << scalar;\
150  RESET_LOG_SETTINGS
151 
152 
156 
157 /*
158  * DEFINE LOG SETTINGS
159  */
160 #define CONDITION_LOG_SETTINGS \
161  std::cout << BLUE << "Condition : " << std::endl; \
162  std::cout << LT_BLUE;\
163 
164 /*
165  * DEFINE FUNCTIONALITIES
166  */
167 #define LOG_CONDITION_HEADER( master, slave ) \
168  CONDITION_LOG_SETTINGS \
169  std::cout << "|_ Master : "; \
170  for( unsigned int i = 0; i < master.PointsNumber( ) - 1; ++i ) \
171  std::cout << master[i].Id( ) << ", "; \
172  std::cout << master[master.PointsNumber( ) - 1].Id( ) << "\n";\
173  std::cout << "|_ Slave : "; \
174  for( unsigned int i = 0; i < master.PointsNumber( ) - 1; ++i ) \
175  std::cout << slave[i].Id( ) << ", "; \
176  std::cout << slave[slave.PointsNumber( ) - 1].Id( ) << "\n";\
177  RESET_LOG_SETTINGS
178 
179 
LoggingLevel
Definition: logging_settings.hpp:42
@ info_warnings
Definition: logging_settings.hpp:42
@ system_matrices
Definition: logging_settings.hpp:42
@ debug
Definition: logging_settings.hpp:42
@ none
Definition: logging_settings.hpp:42