Home | History | Annotate | Download | only in src
      1 // Copyright 2008 Google Inc.
      2 // Author: Lincoln Smith
      3 //
      4 // Licensed under the Apache License, Version 2.0 (the "License");
      5 // you may not use this file except in compliance with the License.
      6 // You may obtain a copy of the License at
      7 //
      8 //      http://www.apache.org/licenses/LICENSE-2.0
      9 //
     10 // Unless required by applicable law or agreed to in writing, software
     11 // distributed under the License is distributed on an "AS IS" BASIS,
     12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13 // See the License for the specific language governing permissions and
     14 // limitations under the License.
     15 
     16 #ifndef OPEN_VCDIFF_LOGGING_H_
     17 #define OPEN_VCDIFF_LOGGING_H_
     18 
     19 #include <config.h>
     20 #include <stdlib.h>  // exit
     21 #include <iostream>
     22 
     23 namespace open_vcdiff {
     24 
     25 extern bool g_fatal_error_occurred;
     26 
     27 inline void CheckFatalError() {
     28   if (g_fatal_error_occurred) {
     29     std::cerr.flush();
     30     exit(1);
     31   }
     32 }
     33 
     34 }  // namespace open_vcdiff
     35 
     36 #define VCD_WARNING std::cerr << "WARNING: "
     37 #define VCD_ERROR std::cerr << "ERROR: "
     38 #ifndef NDEBUG
     39 #define VCD_DFATAL open_vcdiff::g_fatal_error_occurred = true; \
     40                    std::cerr << "FATAL: "
     41 #else  // NDEBUG
     42 #define VCD_DFATAL VCD_ERROR
     43 #endif  // !NDEBUG
     44 
     45 #define VCD_ENDL std::endl; \
     46                  open_vcdiff::CheckFatalError();
     47 
     48 #endif  // OPEN_VCDIFF_LOGGING_H_
     49