testPropConfig.cpp
Go to the documentation of this file.
1 // testConfig.cpp : Derived from testPattern.cpp.
2 //
3 
4 #include <log4cpp/Portability.hh>
5 
6 #ifdef WIN32
7 #include <windows.h>
8 #endif
9 #ifdef LOG4CPP_HAVE_UNISTD_H
10 #include <unistd.h>
11 #endif
12 
13 #include <iostream>
14 
15 #include <log4cpp/Category.hh>
17 
18 int main(int argc, char* argv[])
19 {
20  try {
21  std::string initFileName;
22 #if defined(WIN32)
23  initFileName = "./log4cpp.nt.property";
24 #else
25  initFileName = "./log4cpp.property";
26 #endif
28  } catch(log4cpp::ConfigureFailure& f) {
29  std::cout << "Configure Problem " << f.what() << std::endl;
30  return -1;
31  }
32 
34 
35  log4cpp::Category& sub1 =
36  log4cpp::Category::getInstance(std::string("sub1"));
37 
38  log4cpp::Category& sub2 =
39  log4cpp::Category::getInstance(std::string("sub1.sub2"));
40 
41  root.error("root error");
42  root.warn("root warn");
43  sub1.error("sub1 error");
44  sub1.warn("sub1 warn");
45  // the following 2 should only be in A1, not A2
46  sub1.info("sub1 info");
47  sub1.debug("sub1 debug");
48 
49  // do a few so that the log rolls over
50  sub2.warn("sub2 warn 1");
51  sub2.warn("sub2 warn 2");
52  sub2.warn("sub2 warn 3");
53  sub2.warn("sub2 warn 4");
54  sub2.warn("sub2 warn 5");
55  sub2.warn("sub2 warn 6");
56  sub2.warn("sub2 warn 7");
57 
58 #if defined(WIN32)
59  log4cpp::Category& nt =
60  log4cpp::Category::getInstance(std::string("subNT"));
61  nt.error("subNT error");
62  nt.warn("subNT warn");
63  nt.debug("subNT debug");
64 #endif
65 
67 
68  return 0;
69 }
70 
void debug(const char *stringFormat,...)
Definition: Category.cpp:291
void warn(const char *stringFormat,...)
Definition: Category.cpp:333
static Category & getInstance(const std::string &name)
Definition: Category.cpp:35
static void shutdown()
Definition: Category.cpp:48
int main(int argc, char *argv[])
static Category & getRoot()
Definition: Category.cpp:23
void info(const char *stringFormat,...)
Definition: Category.cpp:305
void error(const char *stringFormat,...)
Definition: Category.cpp:347
static void configure(const std::string &initFileName)


log4cpp
Author(s): Stephen Roderick, Bastiaan Bakker, Cedric Le Goater, Steve Ostlind, Marcel Harkema, Walter Stroebel, Glenn Scott and Tony Cheung
autogenerated on Sun Jun 23 2019 19:10:00