Jeff Thompson | e2cd587 | 2013-09-19 15:53:29 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2013 Regents of the University of California. |
| 4 | * @author: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 5 | * @author: Zhenkai Zhu <zhenkai@cs.ucla.edu> |
| 6 | * See COPYING for copyright and distribution information. |
| 7 | */ |
| 8 | |
Alexander Afanasyev | e2dcdfd | 2014-02-07 15:53:28 -0800 | [diff] [blame] | 9 | #include "common.hpp" |
| 10 | |
Jeff Thompson | e2cd587 | 2013-09-19 15:53:29 -0700 | [diff] [blame] | 11 | #include "logging.hpp" |
| 12 | |
Jeff Thompson | b752300 | 2013-10-09 10:25:00 -0700 | [diff] [blame] | 13 | #ifdef NDN_CPP_HAVE_LOG4CXX |
Jeff Thompson | e2cd587 | 2013-09-19 15:53:29 -0700 | [diff] [blame] | 14 | |
| 15 | #include <log4cxx/logger.h> |
| 16 | #include <log4cxx/basicconfigurator.h> |
| 17 | #include <log4cxx/consoleappender.h> |
| 18 | #include <log4cxx/patternlayout.h> |
| 19 | #include <log4cxx/level.h> |
| 20 | #include <log4cxx/propertyconfigurator.h> |
| 21 | #include <log4cxx/defaultconfigurator.h> |
| 22 | #include <log4cxx/helpers/exception.h> |
| 23 | using namespace log4cxx; |
| 24 | using namespace log4cxx::helpers; |
| 25 | |
| 26 | #include <unistd.h> |
| 27 | |
| 28 | void |
| 29 | INIT_LOGGERS () |
| 30 | { |
| 31 | static bool configured = false; |
| 32 | |
| 33 | if (configured) return; |
| 34 | |
| 35 | if (access ("log4cxx.properties", R_OK)==0) |
| 36 | PropertyConfigurator::configureAndWatch ("log4cxx.properties"); |
| 37 | else |
| 38 | { |
| 39 | PatternLayoutPtr layout (new PatternLayout ("%d{HH:mm:ss} %p %c{1} - %m%n")); |
| 40 | ConsoleAppenderPtr appender (new ConsoleAppender (layout)); |
| 41 | |
| 42 | BasicConfigurator::configure( appender ); |
| 43 | Logger::getRootLogger()->setLevel (log4cxx::Level::getInfo ()); |
| 44 | } |
| 45 | |
| 46 | configured = true; |
| 47 | } |
| 48 | |
| 49 | #endif |