]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common: add some colors on startup (errors, warnings)
authorYehuda Sadeh <yehuda@hq.newdream.net>
Tue, 28 Apr 2009 18:02:55 +0000 (11:02 -0700)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Tue, 28 Apr 2009 18:02:55 +0000 (11:02 -0700)
src/Makefile.am
src/common/common_init.cc
src/cosd.cc
src/include/color.h [new file with mode: 0644]

index 07cfda814adc49a15925b314eb76bb1246c97a5e..aeaa3b51ca2be881026357ba6521e6d525c59362 100644 (file)
@@ -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\
index 8ea3adfb2faa544ba7460fd045d261e98bb3e25f..1edaad65a5abc1124395d55e25de21ce0d915f59 100644 (file)
@@ -2,6 +2,8 @@
 #include "config.h"
 #include "tls.h"
 
+#include "include/color.h"
+
 void common_init(std::vector<const char*>& args, const char *module_type, bool daemon)
 {
   tls_init();
@@ -9,8 +11,8 @@ void common_init(std::vector<const char*>& 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;
index 21f423f51efd27fca4e13f2b06ceee9f2d7ce0fc..c49908d0741fad44b58bcd72a92bb3624d5f7408 100644 (file)
@@ -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 (file)
index 0000000..d267eef
--- /dev/null
@@ -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