Interface Documentation
Version: invalid
utils.hh
1 /*
2  @@@@@@@@ @@ @@@@@@ @@@@@@@@ @@
3  /@@///// /@@ @@////@@ @@////// /@@
4  /@@ /@@ @@@@@ @@ // /@@ /@@
5  /@@@@@@@ /@@ @@///@@/@@ /@@@@@@@@@/@@
6  /@@//// /@@/@@@@@@@/@@ ////////@@/@@
7  /@@ /@@/@@//// //@@ @@ /@@/@@
8  /@@ @@@//@@@@@@ //@@@@@@ @@@@@@@@ /@@
9  // /// ////// ////// //////// //
10 
11  Copyright (c) 2016, Triad National Security, LLC
12  All rights reserved.
13  */
14 #pragma once
15 
16 #include <flecsi-config.h>
17 
18 #include <string>
19 
20 #define _flog_util_stringify(s) #s
21 #define _flog_stringify(s) _flog_util_stringify(s)
22 #define _flog_concat(a, b) a##b
23 
24 #ifndef FLOG_ENABLE_COLOR_OUTPUT
25 
26 #define FLOG_COLOR_BLACK ""
27 #define FLOG_COLOR_DKGRAY ""
28 #define FLOG_COLOR_RED ""
29 #define FLOG_COLOR_LTRED ""
30 #define FLOG_COLOR_GREEN ""
31 #define FLOG_COLOR_LTGREEN ""
32 #define FLOG_COLOR_BROWN ""
33 #define FLOG_COLOR_YELLOW ""
34 #define FLOG_COLOR_BLUE ""
35 #define FLOG_COLOR_LTBLUE ""
36 #define FLOG_COLOR_PURPLE ""
37 #define FLOG_COLOR_LTPURPLE ""
38 #define FLOG_COLOR_CYAN ""
39 #define FLOG_COLOR_LTCYAN ""
40 #define FLOG_COLOR_LTGRAY ""
41 #define FLOG_COLOR_WHITE ""
42 #define FLOG_COLOR_PLAIN ""
43 
44 #define FLOG_OUTPUT_BLACK(s) s
45 #define FLOG_OUTPUT_DKGRAY(s) s
46 #define FLOG_OUTPUT_RED(s) s
47 #define FLOG_OUTPUT_LTRED(s) s
48 #define FLOG_OUTPUT_GREEN(s) s
49 #define FLOG_OUTPUT_LTGREEN(s) s
50 #define FLOG_OUTPUT_BROWN(s) s
51 #define FLOG_OUTPUT_YELLOW(s) s
52 #define FLOG_OUTPUT_BLUE(s) s
53 #define FLOG_OUTPUT_LTBLUE(s) s
54 #define FLOG_OUTPUT_PURPLE(s) s
55 #define FLOG_OUTPUT_LTPURPLE(s) s
56 #define FLOG_OUTPUT_CYAN(s) s
57 #define FLOG_OUTPUT_LTCYAN(s) s
58 #define FLOG_OUTPUT_LTGRAY(s) s
59 #define FLOG_OUTPUT_WHITE(s) s
60 
61 #else
62 
63 #define FLOG_COLOR_BLACK "\033[0;30m"
64 #define FLOG_COLOR_DKGRAY "\033[1;30m"
65 #define FLOG_COLOR_RED "\033[0;31m"
66 #define FLOG_COLOR_LTRED "\033[1;31m"
67 #define FLOG_COLOR_GREEN "\033[0;32m"
68 #define FLOG_COLOR_LTGREEN "\033[1;32m"
69 #define FLOG_COLOR_BROWN "\033[0;33m"
70 #define FLOG_COLOR_YELLOW "\033[1;33m"
71 #define FLOG_COLOR_BLUE "\033[0;34m"
72 #define FLOG_COLOR_LTBLUE "\033[1;34m"
73 #define FLOG_COLOR_PURPLE "\033[0;35m"
74 #define FLOG_COLOR_LTPURPLE "\033[1;35m"
75 #define FLOG_COLOR_CYAN "\033[0;36m"
76 #define FLOG_COLOR_LTCYAN "\033[1;36m"
77 #define FLOG_COLOR_LTGRAY "\033[0;37m"
78 #define FLOG_COLOR_WHITE "\033[1;37m"
79 #define FLOG_COLOR_PLAIN "\033[0m"
80 
81 #define FLOG_OUTPUT_BLACK(s) FLOG_COLOR_BLACK << s << FLOG_COLOR_PLAIN
82 #define FLOG_OUTPUT_DKGRAY(s) FLOG_COLOR_DKGRAY << s << FLOG_COLOR_PLAIN
83 #define FLOG_OUTPUT_RED(s) FLOG_COLOR_RED << s << FLOG_COLOR_PLAIN
84 #define FLOG_OUTPUT_LTRED(s) FLOG_COLOR_LTRED << s << FLOG_COLOR_PLAIN
85 #define FLOG_OUTPUT_GREEN(s) FLOG_COLOR_GREEN << s << FLOG_COLOR_PLAIN
86 #define FLOG_OUTPUT_LTGREEN(s) FLOG_COLOR_LTGREEN << s << FLOG_COLOR_PLAIN
87 #define FLOG_OUTPUT_BROWN(s) FLOG_COLOR_BROWN << s << FLOG_COLOR_PLAIN
88 #define FLOG_OUTPUT_YELLOW(s) FLOG_COLOR_YELLOW << s << FLOG_COLOR_PLAIN
89 #define FLOG_OUTPUT_BLUE(s) FLOG_COLOR_BLUE << s << FLOG_COLOR_PLAIN
90 #define FLOG_OUTPUT_LTBLUE(s) FLOG_COLOR_LTBLUE << s << FLOG_COLOR_PLAIN
91 #define FLOG_OUTPUT_PURPLE(s) FLOG_COLOR_PURPLE << s << FLOG_COLOR_PLAIN
92 #define FLOG_OUTPUT_LTPURPLE(s) FLOG_COLOR_LTPURPLE << s << FLOG_COLOR_PLAIN
93 #define FLOG_OUTPUT_CYAN(s) FLOG_COLOR_CYAN << s << FLOG_COLOR_PLAIN
94 #define FLOG_OUTPUT_LTCYAN(s) FLOG_COLOR_LTCYAN << s << FLOG_COLOR_PLAIN
95 #define FLOG_OUTPUT_LTGRAY(s) FLOG_COLOR_LTGRAY << s << FLOG_COLOR_PLAIN
96 #define FLOG_OUTPUT_WHITE(s) FLOG_COLOR_WHITE << s << FLOG_COLOR_PLAIN
97 
98 #endif // FLOG_ENABLE_COLOR_OUTPUT
99 
100 namespace flecsi {
101 namespace log {
102 
107 inline std::string
108 timestamp(bool underscores = false) {
109  char stamp[14];
110  time_t t = time(0);
111  std::string format = underscores ? "%m%d_%H%M%S" : "%m%d %H:%M:%S";
112  strftime(stamp, sizeof(stamp), format.c_str(), localtime(&t));
113  return std::string(stamp);
114 } // timestamp
115 
122 template<char C>
123 inline std::string
124 rstrip(const char * file) {
125  std::string tmp(file);
126  return tmp.substr(tmp.rfind(C) + 1);
127 } // rstrip
128 
129 #ifndef FLOG_SERIALIZATION_INTERVAL
130 #define FLOG_SERIALIZATION_INTERVAL 100
131 #endif
132 
133 #ifndef FLOG_SERIALIZATION_THRESHOLD
134 #define FLOG_SERIALIZATION_THRESHOLD 1024
135 #endif
136 
141 void send_to_one();
142 
143 } // namespace log
144 } // namespace flecsi
Definition: control.hh:31