dburgess | 82c46ff | 2011-10-07 02:40:51 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2009 Free Software Foundation, Inc. |
| 3 | * Copyright 2010 Kestrel Signal Processing, Inc. |
| 4 | * |
| 5 | * |
| 6 | * This software is distributed under the terms of the GNU Affero Public License. |
| 7 | * See the COPYING file in the main directory for details. |
| 8 | * |
| 9 | * This use of this software may be subject to additional restrictions. |
| 10 | * See the LEGAL file in the main directory for details. |
| 11 | |
| 12 | This program is free software: you can redistribute it and/or modify |
| 13 | it under the terms of the GNU Affero General Public License as published by |
| 14 | the Free Software Foundation, either version 3 of the License, or |
| 15 | (at your option) any later version. |
| 16 | |
| 17 | This program is distributed in the hope that it will be useful, |
| 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | GNU Affero General Public License for more details. |
| 21 | |
| 22 | You should have received a copy of the GNU Affero General Public License |
| 23 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 24 | |
| 25 | */ |
| 26 | |
| 27 | #include <iostream> |
| 28 | #include <iterator> |
| 29 | |
| 30 | #include "Logger.h" |
| 31 | #include "Configuration.h" |
| 32 | |
| 33 | ConfigurationTable gConfig; |
| 34 | //ConfigurationTable gConfig("example.config"); |
| 35 | |
| 36 | void printAlarms() |
| 37 | { |
| 38 | std::ostream_iterator<std::string> output( std::cout, "\n" ); |
| 39 | std::list<std::string> alarms = gGetLoggerAlarms(); |
kurtis.heimerl | 5a87247 | 2013-05-31 21:47:25 +0000 | [diff] [blame] | 40 | std::cout << "# alarms = " << alarms.size() << std::endl; |
dburgess | 82c46ff | 2011-10-07 02:40:51 +0000 | [diff] [blame] | 41 | std::copy( alarms.begin(), alarms.end(), output ); |
| 42 | } |
| 43 | |
| 44 | int main(int argc, char *argv[]) |
| 45 | { |
| 46 | gLogInit("LogTest","NOTICE",LOG_LOCAL7); |
| 47 | |
| 48 | LOG(EMERG) << " testing the logger."; |
| 49 | LOG(ALERT) << " testing the logger."; |
| 50 | LOG(CRIT) << " testing the logger."; |
| 51 | LOG(ERR) << " testing the logger."; |
| 52 | LOG(WARNING) << " testing the logger."; |
| 53 | LOG(NOTICE) << " testing the logger."; |
| 54 | LOG(INFO) << " testing the logger."; |
| 55 | LOG(DEBUG) << " testing the logger."; |
| 56 | std::cout << "\n\n\n"; |
| 57 | std::cout << "testing Alarms\n"; |
dburgess | 82c46ff | 2011-10-07 02:40:51 +0000 | [diff] [blame] | 58 | std::cout << "you should see three lines:" << std::endl; |
| 59 | printAlarms(); |
| 60 | std::cout << "----------- generating 20 alarms ----------" << std::endl; |
| 61 | for (int i = 0 ; i < 20 ; ++i) { |
| 62 | LOG(ALERT) << i; |
| 63 | } |
| 64 | std::cout << "you should see ten lines with the numbers 10..19:" << std::endl; |
| 65 | printAlarms(); |
| 66 | } |