Fawkes API  Fawkes Development Version
logger.cpp
1 
2 /***************************************************************************
3  * logger.cpp - Logger aspect for Fawkes
4  *
5  * Created: Wed Feb 11 22:21:56 2009
6  * Copyright 2008-2009 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #include <aspect/logger.h>
25 
26 namespace fawkes {
27 #if 0 /* just to make Emacs auto-indent happy */
28 }
29 #endif
30 
31 /** @class LoggerAspect <aspect/logger.h>
32  * Thread aspect that allows to provide a logger to Fawkes.
33  * The logger will be added to the list of loggers and will get all the
34  * log messages.
35  * This aspect can be used for example to attach Fawkes to a custom logging
36  * facility.
37  *
38  * @ingroup Aspects
39  * @author Tim Niemueller
40  */
41 
42 
43 /** Constructor.
44  * @param logger Logger to add to the Fawkes loggers
45  */
47 {
48  add_aspect("LoggerAspect");
49  __logger = logger;
50 }
51 
52 /** Virtual empty destructor. */
54 {
55 }
56 
57 
58 /** Get time source.
59  * This method is called by the aspect initializer to get the time source
60  * the thread with this aspect provides.
61  * @return logger provide by the thread with this aspect
62  */
63 Logger *
65 {
66  return __logger;
67 }
68 
69 } // end namespace fawkes
Fawkes library namespace.
void add_aspect(const char *name)
Add an aspect to a thread.
Definition: aspect.cpp:52
LoggerAspect(Logger *logger) __attribute__((nonnull))
Constructor.
Definition: logger.cpp:46
virtual ~LoggerAspect()
Virtual empty destructor.
Definition: logger.cpp:53
Logger * get_logger() const
Get time source.
Definition: logger.cpp:64
Interface for logging.
Definition: logger.h:34