Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef FST_LIB_LOG_H__
00021 #define FST_LIB_LOG_H__
00022
00023 #include <cassert>
00024 #include <iostream>
00025 #include <string>
00026
00027 #include <fst/types.h>
00028 #include <fst/flags.h>
00029
00030 using std::string;
00031
00032 DECLARE_int32(v);
00033
00034 class LogMessage {
00035 public:
00036 LogMessage(const string &type) : fatal_(type == "FATAL") {
00037 std::cerr << type << ": ";
00038 }
00039 ~LogMessage() {
00040 std::cerr << std::endl;
00041 if(fatal_)
00042 exit(1);
00043 }
00044 std::ostream &stream() { return std::cerr; }
00045
00046 private:
00047 bool fatal_;
00048 };
00049
00050 #define LOG(type) LogMessage(#type).stream()
00051 #define VLOG(level) if ((level) <= FLAGS_v) LOG(INFO)
00052
00053
00054 inline void CHECK(bool x) { assert(x); }
00055
00056 #define CHECK_EQ(x, y) CHECK((x) == (y))
00057 #define CHECK_LT(x, y) CHECK((x) < (y))
00058 #define CHECK_GT(x, y) CHECK((x) > (y))
00059 #define CHECK_LE(x, y) CHECK((x) <= (y))
00060 #define CHECK_GE(x, y) CHECK((x) >= (y))
00061 #define CHECK_NE(x, y) CHECK((x) != (y))
00062
00063
00064 #define ATTRIBUTE_DEPRECATED __attribute__((deprecated))
00065
00066 #endif /// FST_LIB_LOG_H__
00067