Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
logging
tests
testlogging.cpp
Go to the documentation of this file.
1
// test mix of log4cpp and OCL::logging implementations
2
3
#include <iostream>
4
#include <
log4cpp/HierarchyMaintainer.hh
>
5
#include "
logging/Category.hpp
"
6
7
using namespace
RTT
;
8
9
int
main
(
int
argc,
char
** argv)
10
{
11
// use only OCL::logging Category's
12
log4cpp::HierarchyMaintainer::set_category_factory
(
13
OCL::logging::Category::createOCLCategory
);
14
15
std::string name =
"org.test.c1"
;
16
17
// what types do we get from the category itself?
18
std::cout <<
"\nFrom category???\n"
;
19
log4cpp::Category
& category2 =
log4cpp::Category::getInstance
(name);
20
std::cout <<
"category2 type "
<<
typeid
(category2).name() << std::endl;
21
std::cout <<
"category2 ptype "
<<
typeid
(&category2).name() << std::endl;
22
23
OCL::logging::Category
* category =
24
dynamic_cast<
OCL::logging::Category
*
>
(&category2);
25
if
(0 != category)
26
{
27
std::cout <<
"category type "
<<
typeid
(*category).name() << std::endl;
28
}
29
else
30
{
31
std::cout <<
"Unable cast"
<< std::endl;
32
}
33
34
// and directly?
35
std::cout <<
"\nDirectly ...\n"
;
36
category =
dynamic_cast<
OCL::logging::Category
*
>
(
37
&
log4cpp::Category::getInstance
(name));
38
if
(0 != category)
39
{
40
std::cout <<
"category type "
<<
typeid
(*category).name() << std::endl;
41
}
42
else
43
{
44
std::cout <<
"Unable cast"
<< std::endl;
45
}
46
47
// and through hierarchy maintainer?
48
std::cout <<
"\nThrough hierarchy maintainer ...\n"
;
49
log4cpp::Category
* p =
log4cpp::HierarchyMaintainer::getDefaultMaintainer
().
getExistingInstance
(name);
50
std::cout <<
"category ptype "
<<
typeid
(p).name() << std::endl;
51
std::cout <<
"category type "
<<
typeid
(*p).name() << std::endl;
52
category =
dynamic_cast<
OCL::logging::Category
*
>
(p);
53
if
(0 != category)
54
{
55
std::cout <<
"category type "
<<
typeid
(*category).name() << std::endl;
56
}
57
else
58
{
59
std::cout <<
"Unable cast"
<< std::endl;
60
}
61
62
category =
dynamic_cast<
OCL::logging::Category
*
>
(
63
log4cpp::HierarchyMaintainer::getDefaultMaintainer
().
getExistingInstance
(name));
64
if
(0 != category)
65
{
66
std::cout <<
"category type "
<<
typeid
(*category).name() << std::endl;
67
}
68
else
69
{
70
std::cout <<
"Unable cast"
<< std::endl;
71
}
72
73
return
0;
74
}
log4cpp::Category
log4cpp::HierarchyMaintainer::set_category_factory
static void set_category_factory(creator_function_t creator_function)
log4cpp::Category::getInstance
static Category & getInstance(const std::string &name)
log4cpp::HierarchyMaintainer::getExistingInstance
virtual Category * getExistingInstance(const std::string &name)
HierarchyMaintainer.hh
main
int main(int argc, char **argv)
Definition:
testlogging.cpp:9
OCL::logging::Category::createOCLCategory
static log4cpp::Category * createOCLCategory(const std::string &name, log4cpp::Category *parent, log4cpp::Priority::Value priority)
Definition:
Category.cpp:138
OCL::logging::Category
Definition:
Category.hpp:25
log4cpp::HierarchyMaintainer::getDefaultMaintainer
static HierarchyMaintainer & getDefaultMaintainer()
Category.hpp
RTT
ocl
Author(s): OCL Development Team
autogenerated on Mon Mar 23 2020 04:47:19