]>
Commit | Line | Data |
---|---|---|
e9772e16 KS |
1 | //===-- sanitizer_report_decorator.h ----------------------------*- C++ -*-===// |
2 | // | |
3 | // This file is distributed under the University of Illinois Open Source | |
4 | // License. See LICENSE.TXT for details. | |
5 | // | |
6 | //===----------------------------------------------------------------------===// | |
7 | // | |
8 | // Tags to decorate the sanitizer reports. | |
9 | // Currently supported tags: | |
10 | // * None. | |
11 | // * ANSI color sequences. | |
12 | // | |
13 | //===----------------------------------------------------------------------===// | |
14 | ||
de5a5fa1 MP |
15 | #ifndef SANITIZER_REPORT_DECORATOR_H |
16 | #define SANITIZER_REPORT_DECORATOR_H | |
e9772e16 | 17 | |
dee5ea7a KS |
18 | #include "sanitizer_common.h" |
19 | ||
e9772e16 | 20 | namespace __sanitizer { |
866e32ad | 21 | class SanitizerCommonDecorator { |
ef1b3fda KS |
22 | // FIXME: This is not portable. It assumes the special strings are printed to |
23 | // stdout, which is not the case on Windows (see SetConsoleTextAttribute()). | |
e9772e16 | 24 | public: |
866e32ad | 25 | SanitizerCommonDecorator() : ansi_(ColorizeReports()) {} |
de5a5fa1 | 26 | const char *Bold() const { return ansi_ ? "\033[1m" : ""; } |
866e32ad | 27 | const char *Default() const { return ansi_ ? "\033[1m\033[0m" : ""; } |
5d3805fc JJ |
28 | const char *Warning() const { return Red(); } |
29 | const char *MemoryByte() { return Magenta(); } | |
30 | ||
866e32ad | 31 | protected: |
de5a5fa1 MP |
32 | const char *Black() const { return ansi_ ? "\033[1m\033[30m" : ""; } |
33 | const char *Red() const { return ansi_ ? "\033[1m\033[31m" : ""; } | |
34 | const char *Green() const { return ansi_ ? "\033[1m\033[32m" : ""; } | |
35 | const char *Yellow() const { return ansi_ ? "\033[1m\033[33m" : ""; } | |
36 | const char *Blue() const { return ansi_ ? "\033[1m\033[34m" : ""; } | |
37 | const char *Magenta() const { return ansi_ ? "\033[1m\033[35m" : ""; } | |
38 | const char *Cyan() const { return ansi_ ? "\033[1m\033[36m" : ""; } | |
39 | const char *White() const { return ansi_ ? "\033[1m\033[37m" : ""; } | |
e9772e16 KS |
40 | private: |
41 | bool ansi_; | |
42 | }; | |
dee5ea7a | 43 | |
e9772e16 | 44 | } // namespace __sanitizer |
de5a5fa1 MP |
45 | |
46 | #endif // SANITIZER_REPORT_DECORATOR_H |