Alexander Afanasyev | 4f9ea48 | 2012-03-15 11:57:29 -0700 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
Alexander Afanasyev | 8722d87 | 2014-07-02 13:00:29 -0700 | [diff] [blame^] | 3 | * Copyright (c) 2012-2014 University of California, Los Angeles |
Alexander Afanasyev | 4f9ea48 | 2012-03-15 11:57:29 -0700 | [diff] [blame] | 4 | * |
Alexander Afanasyev | 8722d87 | 2014-07-02 13:00:29 -0700 | [diff] [blame^] | 5 | * This file is part of ChronoSync, synchronization library for distributed realtime |
| 6 | * applications for NDN. |
Alexander Afanasyev | 4f9ea48 | 2012-03-15 11:57:29 -0700 | [diff] [blame] | 7 | * |
Alexander Afanasyev | 8722d87 | 2014-07-02 13:00:29 -0700 | [diff] [blame^] | 8 | * ChronoSync is free software: you can redistribute it and/or modify it under the terms |
| 9 | * of the GNU General Public License as published by the Free Software Foundation, either |
| 10 | * version 3 of the License, or (at your option) any later version. |
Alexander Afanasyev | 4f9ea48 | 2012-03-15 11:57:29 -0700 | [diff] [blame] | 11 | * |
Alexander Afanasyev | 8722d87 | 2014-07-02 13:00:29 -0700 | [diff] [blame^] | 12 | * ChronoSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 | * PURPOSE. See the GNU General Public License for more details. |
Alexander Afanasyev | 4f9ea48 | 2012-03-15 11:57:29 -0700 | [diff] [blame] | 15 | * |
Alexander Afanasyev | 8722d87 | 2014-07-02 13:00:29 -0700 | [diff] [blame^] | 16 | * You should have received a copy of the GNU General Public License along with |
| 17 | * ChronoSync, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | * @author Zhenkai Zhu <http://irl.cs.ucla.edu/~zhenkai/> |
| 20 | * @author Chaoyi Bian <bcy@pku.edu.cn> |
| 21 | * @author Alexander Afanasyev <http://lasr.cs.ucla.edu/afanasyev/index.html> |
Alexander Afanasyev | 4f9ea48 | 2012-03-15 11:57:29 -0700 | [diff] [blame] | 22 | */ |
| 23 | |
Alexander Afanasyev | ce00169 | 2013-07-14 11:34:41 -0700 | [diff] [blame] | 24 | #include "sync-logging.h" |
Alexander Afanasyev | 4f9ea48 | 2012-03-15 11:57:29 -0700 | [diff] [blame] | 25 | |
| 26 | #ifdef HAVE_LOG4CXX |
| 27 | |
| 28 | #include <log4cxx/logger.h> |
| 29 | #include <log4cxx/basicconfigurator.h> |
| 30 | #include <log4cxx/consoleappender.h> |
| 31 | #include <log4cxx/patternlayout.h> |
| 32 | #include <log4cxx/level.h> |
| 33 | #include <log4cxx/propertyconfigurator.h> |
| 34 | #include <log4cxx/defaultconfigurator.h> |
| 35 | #include <log4cxx/helpers/exception.h> |
| 36 | using namespace log4cxx; |
| 37 | using namespace log4cxx::helpers; |
| 38 | |
| 39 | #include <unistd.h> |
| 40 | |
| 41 | void |
| 42 | INIT_LOGGERS () |
| 43 | { |
| 44 | static bool configured = false; |
| 45 | |
| 46 | if (configured) return; |
Yingdi Yu | 7c64e5c | 2014-04-30 14:06:37 -0700 | [diff] [blame] | 47 | |
Alexander Afanasyev | 4f9ea48 | 2012-03-15 11:57:29 -0700 | [diff] [blame] | 48 | if (access ("log4cxx.properties", R_OK)==0) |
| 49 | PropertyConfigurator::configureAndWatch ("log4cxx.properties"); |
| 50 | else |
| 51 | { |
| 52 | PatternLayoutPtr layout (new PatternLayout ("%d{HH:mm:ss} %p %c{1} - %m%n")); |
| 53 | ConsoleAppenderPtr appender (new ConsoleAppender (layout)); |
| 54 | |
| 55 | BasicConfigurator::configure( appender ); |
| 56 | Logger::getRootLogger()->setLevel (log4cxx::Level::getInfo ()); |
| 57 | } |
| 58 | |
| 59 | configured = true; |
| 60 | } |
| 61 | |
| 62 | #endif |