diff --git a/src/Makefile.am b/src/Makefile.am index 07cfda814ad..aeaa3b51ca2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -353,6 +353,7 @@ noinst_HEADERS = \ include/buffer.h\ include/byteorder.h\ include/ceph_fs.h\ + include/color.h\ include/crc32c.h\ include/cstring.h\ include/encoding.h\ diff --git a/src/common/common_init.cc b/src/common/common_init.cc index 8ea3adfb2fa..1edaad65a5a 100644 --- a/src/common/common_init.cc +++ b/src/common/common_init.cc @@ -2,6 +2,8 @@ #include "config.h" #include "tls.h" +#include "include/color.h" + void common_init(std::vector& args, const char *module_type, bool daemon) { tls_init(); @@ -9,8 +11,8 @@ void common_init(std::vector& args, const char *module_type, bool d g_daemon = daemon; if (daemon) { - cout << " ** WARNING: Ceph is still under heavy development, and is only suitable for **\n"; - cout << " ** testing and review. Do not trust it with important data. **" << std::endl; + cout << TEXT_YELLOW << " ** WARNING: Ceph is still under heavy development, and is only suitable for **" << TEXT_NORMAL << std::endl; + cout << TEXT_YELLOW << " ** testing and review. Do not trust it with important data. **" << TEXT_NORMAL << std::endl; g_conf.daemonize = true; g_conf.log_to_stdout = false; diff --git a/src/cosd.cc b/src/cosd.cc index 21f423f51ef..c49908d0741 100644 --- a/src/cosd.cc +++ b/src/cosd.cc @@ -34,6 +34,8 @@ using namespace std; #include "common/Timer.h" #include "common/common_init.h" +#include "include/color.h" + void usage() { cerr << "usage: cosd -i osdid [--osd-data=path] [--osd-journal=path] [--mkfs]" << std::endl; @@ -99,9 +101,10 @@ int main(int argc, const char **argv) int w; int r = OSD::peek_super(g_conf.osd_data, magic, fsid, w); if (r < 0) { - cerr << " ** ERROR: unable to open OSD superblock on " << g_conf.osd_data << ": " << strerror(-r) << std::endl; + cerr << TEXT_RED << " ** " << TEXT_HAZARD << "ERROR: " << TEXT_RED + << "unable to open OSD superblock on " << g_conf.osd_data << ": " << strerror(-r) << TEXT_NORMAL << std::endl; if (r == -ENOTSUP) - cerr << " ** please verify that underlying storage supports xattrs" << std::endl; + cerr << TEXT_RED << " ** please verify that underlying storage supports xattrs" << TEXT_NORMAL << std::endl; derr(0) << "unable to open OSD superblock on " << g_conf.osd_data << ": " << strerror(-r) << dendl; exit(1); } diff --git a/src/include/color.h b/src/include/color.h new file mode 100644 index 00000000000..d267eeff6c7 --- /dev/null +++ b/src/include/color.h @@ -0,0 +1,13 @@ +#ifndef __COLOR_H +#define __COLOR_H + +#define TEXT_NORMAL "\033[0m" +#define TEXT_HAZARD "\033[5;31m" +#define TEXT_RED "\033[0;31m" +#define TEXT_GREEN "\033[0;32m" +#define TEXT_YELLOW "\033[0;33m" +#define TEXT_BLUE "\033[0;34m" +#define TEXT_MAGENTA "\033[0;35m" +#define TEXT_CYAN "\033[0;36m" + +#endif