2013-01-10 13:44:08 +01:00
|
|
|
//===-- sanitizer_report_decorator.h ----------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Tags to decorate the sanitizer reports.
|
|
|
|
// Currently supported tags:
|
|
|
|
// * None.
|
|
|
|
// * ANSI color sequences.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2013-08-30 18:12:58 +02:00
|
|
|
#ifndef SANITIZER_REPORT_DECORATOR_H
|
|
|
|
#define SANITIZER_REPORT_DECORATOR_H
|
2013-01-10 13:44:08 +01:00
|
|
|
|
|
|
|
namespace __sanitizer {
|
|
|
|
class AnsiColorDecorator {
|
2013-11-04 22:33:31 +01:00
|
|
|
// FIXME: This is not portable. It assumes the special strings are printed to
|
|
|
|
// stdout, which is not the case on Windows (see SetConsoleTextAttribute()).
|
2013-01-10 13:44:08 +01:00
|
|
|
public:
|
|
|
|
explicit AnsiColorDecorator(bool use_ansi_colors) : ansi_(use_ansi_colors) { }
|
2013-08-30 18:12:58 +02:00
|
|
|
const char *Bold() const { return ansi_ ? "\033[1m" : ""; }
|
|
|
|
const char *Black() const { return ansi_ ? "\033[1m\033[30m" : ""; }
|
|
|
|
const char *Red() const { return ansi_ ? "\033[1m\033[31m" : ""; }
|
|
|
|
const char *Green() const { return ansi_ ? "\033[1m\033[32m" : ""; }
|
|
|
|
const char *Yellow() const { return ansi_ ? "\033[1m\033[33m" : ""; }
|
|
|
|
const char *Blue() const { return ansi_ ? "\033[1m\033[34m" : ""; }
|
|
|
|
const char *Magenta() const { return ansi_ ? "\033[1m\033[35m" : ""; }
|
|
|
|
const char *Cyan() const { return ansi_ ? "\033[1m\033[36m" : ""; }
|
|
|
|
const char *White() const { return ansi_ ? "\033[1m\033[37m" : ""; }
|
|
|
|
const char *Default() const { return ansi_ ? "\033[1m\033[0m" : ""; }
|
2013-01-10 13:44:08 +01:00
|
|
|
private:
|
|
|
|
bool ansi_;
|
|
|
|
};
|
|
|
|
} // namespace __sanitizer
|
2013-08-30 18:12:58 +02:00
|
|
|
|
|
|
|
#endif // SANITIZER_REPORT_DECORATOR_H
|