tesseract  3.03
/usr/local/google/home/jbreiden/tesseract-ocr-read-only/training/tlog.h
Go to the documentation of this file.
00001 /**********************************************************************
00002  * File:        tlog.h
00003  * Description: Variant of printf with logging level controllable by a
00004  *              commandline flag.
00005  * Author:      Ranjith Unnikrishnan
00006  * Created:     Wed Nov 20 2013
00007  *
00008  * (C) Copyright 2013, Google Inc.
00009  ** Licensed under the Apache License, Version 2.0 (the "License");
00010  ** you may not use this file except in compliance with the License.
00011  ** You may obtain a copy of the License at
00012  ** http://www.apache.org/licenses/LICENSE-2.0
00013  ** Unless required by applicable law or agreed to in writing, software
00014  ** distributed under the License is distributed on an "AS IS" BASIS,
00015  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016  ** See the License for the specific language governing permissions and
00017  ** limitations under the License.
00018  *
00019  **********************************************************************/
00020 #ifndef TESSERACT_TRAINING_TLOG_H_
00021 #define TESSERACT_TRAINING_TLOG_H_
00022 
00023 #include "commandlineflags.h"
00024 #include "errcode.h"
00025 #include "tprintf.h"
00026 
00027 DECLARE_INT_PARAM_FLAG(tlog_level);
00028 
00029 // Variant guarded by the numeric logging level parameter FLAGS_tlog_level
00030 // (default 0).  Code using ParseCommandLineFlags() can control its value using
00031 // the --tlog_level commandline argument. Otherwise it must be specified in a
00032 // config file like other params.
00033 #define tlog(level, ...) {                        \
00034   if (FLAGS_tlog_level >= level) {                \
00035     tprintf_internal(__VA_ARGS__);                \
00036   }                                               \
00037 }
00038 
00039 #define TLOG_IS_ON(level) (FLAGS_tlog_level >= level)
00040 
00041 #define TLOG_FATAL(msg...)                                              \
00042   {                                                                     \
00043     tprintf(msg);                                                       \
00044     ASSERT_FAILED.error("", ABORT, "in file %s, line %d",               \
00045                         __FILE__, __LINE__);                            \
00046   }
00047 
00048 
00049 #endif  // TESSERACT_TRAINING_TLOG_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines