libwreport
2.4
|
00001 /* 00002 * wreport/notes - Collect notes about unusual processing 00003 * 00004 * Copyright (C) 2011 ARPA-SIM <urpsim@smr.arpa.emr.it> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00018 * 00019 * Author: Enrico Zini <enrico@enricozini.com> 00020 */ 00021 00022 #ifndef WREPORT_NOTES_H 00023 #define WREPORT_NOTES_H 00024 00025 #include <iosfwd> 00026 00027 #ifndef WREPORT_PRINTF_ATTRS 00028 #define WREPORT_PRINTF_ATTRS(a, b) __attribute__ ((format(printf, a, b))) 00029 #endif 00030 00031 namespace wreport { 00032 00039 namespace notes { 00040 00042 void set_target(std::ostream& out); 00043 00045 std::ostream* get_target(); 00046 00048 bool logs() throw (); 00049 00051 std::ostream& log() throw (); 00052 00054 void logf(const char* fmt, ...) WREPORT_PRINTF_ATTRS(1, 2); 00055 00062 struct Collect 00063 { 00067 std::ostream* old; 00068 00070 Collect(std::ostream& out) 00071 { 00072 old = get_target(); 00073 set_target(out); 00074 } 00075 ~Collect() 00076 { 00077 set_target(*old); 00078 } 00079 }; 00080 00081 } 00082 00083 } 00084 00085 /* vim:set ts=4 sw=4: */ 00086 #endif