blob: bd1441455bafc0b6703449553eb8adf96f387610 [file] [log] [blame]
openvcdiff311c7142008-08-26 19:29:25 +00001// 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>
openvcdiff@gmail.com732fff22010-08-04 18:00:00 +000020#include <stdlib.h> // exit
openvcdiff311c7142008-08-26 19:29:25 +000021#include <iostream>
openvcdiff311c7142008-08-26 19:29:25 +000022
23namespace open_vcdiff {
24
openvcdiff311c7142008-08-26 19:29:25 +000025extern bool g_fatal_error_occurred;
openvcdiff311c7142008-08-26 19:29:25 +000026
27inline void CheckFatalError() {
28 if (g_fatal_error_occurred) {
openvcdiff@gmail.com732fff22010-08-04 18:00:00 +000029 std::cerr.flush();
30 exit(1);
openvcdiff311c7142008-08-26 19:29:25 +000031 }
32}
33
34} // namespace open_vcdiff
35
openvcdiff@gmail.com732fff22010-08-04 18:00:00 +000036#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();
openvcdiff311c7142008-08-26 19:29:25 +000047
48#endif // OPEN_VCDIFF_LOGGING_H_