blob: 59c7b2ab007c7c9b0ee07205c15e8b538d19bd1a [file] [log] [blame]
Jeff Thompsone2cd5872013-09-19 15:53:29 -07001/* -*- 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 Afanasyeve2dcdfd2014-02-07 15:53:28 -08009#include "common.hpp"
10
Jeff Thompsone2cd5872013-09-19 15:53:29 -070011#include "logging.hpp"
12
Jeff Thompsonb7523002013-10-09 10:25:00 -070013#ifdef NDN_CPP_HAVE_LOG4CXX
Jeff Thompsone2cd5872013-09-19 15:53:29 -070014
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>
23using namespace log4cxx;
24using namespace log4cxx::helpers;
25
26#include <unistd.h>
27
28void
29INIT_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