1 /***************************************************************************
2  $RCSfile$
3                              -------------------
4     cvs         : $Id$
5     begin       : Sun Dec 05 2003
6     copyright   : (C) 2003 by Martin Preuss
7     email       : martin@libchipcard.de
8 
9  ***************************************************************************
10  *                                                                         *
11  *   This library is free software; you can redistribute it and/or         *
12  *   modify it under the terms of the GNU Lesser General Public            *
13  *   License as published by the Free Software Foundation; either          *
14  *   version 2.1 of the License, or (at your option) any later version.    *
15  *                                                                         *
16  *   This library 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 GNU     *
19  *   Lesser General Public License for more details.                       *
20  *                                                                         *
21  *   You should have received a copy of the GNU Lesser General Public      *
22  *   License along with this library; if not, write to the Free Software   *
23  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,                 *
24  *   MA  02111-1307  USA                                                   *
25  *                                                                         *
26  ***************************************************************************/
27 
28 #ifndef GWEN_LOGGER_P_H
29 #define GWEN_LOGGER_P_H
30 
31 #include "logger_l.h"
32 #include <gwenhywfar/buffer.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 
39 typedef struct GWEN_LOGGER_DOMAIN GWEN_LOGGER_DOMAIN;
40 typedef struct GWEN_LOGGER GWEN_LOGGER;
41 
42 
43 struct GWEN_LOGGER {
44   GWEN_LOGGER *next;
45   GWEN_LOGGER_DOMAIN *domain;
46   int enabled;
47   int open;
48   GWEN_LOGGER_LOGTYPE logType;
49   char *logFile;
50   char *logIdent;
51   GWEN_LOGGER_LEVEL logLevel;
52   GWEN_LOGGERFUNCTIONLOG logFunction;
53   uint32_t usage;
54 };
55 
56 
57 struct GWEN_LOGGER_DOMAIN {
58   GWEN_LOGGER_DOMAIN *next;
59   char *name;
60   GWEN_LOGGER *logger;
61 };
62 GWEN_LOGGER_DOMAIN *GWEN_LoggerDomain_new(const char *name);
63 void GWEN_LoggerDomain_free(GWEN_LOGGER_DOMAIN *ld);
64 GWEN_LOGGER_DOMAIN *GWEN_LoggerDomain_Find(const char *name);
65 void GWEN_LoggerDomain_Add(GWEN_LOGGER_DOMAIN *ld);
66 void GWEN_LoggerDomain_Del(GWEN_LOGGER_DOMAIN *ld);
67 GWEN_LOGGER *GWEN_LoggerDomain_GetLogger(const char *name);
68 
69 
70 int GWEN_Logger__CreateMessage(GWEN_LOGGER *lg,
71                                GWEN_LOGGER_LEVEL priority, const char *s,
72                                GWEN_BUFFER *mbuf);
73 
74 int GWEN_Logger__Log(GWEN_LOGGER *lg,
75                      GWEN_LOGGER_LEVEL priority, const char *s);
76 
77 
78 
79 GWEN_LOGGER *GWEN_Logger_new(GWEN_LOGGER_DOMAIN *domain);
80 
81 void GWEN_Logger_free(GWEN_LOGGER *lg);
82 
83 void GWEN_Logger_Attach(GWEN_LOGGER *lg);
84 
85 
86 /**
87  * Adds a logger to the given one. So if the old logger is to log something
88  * then the newly added logger will log the same message as well.
89  * The new logger must already be open (via @ref GWEN_Logger_Open).
90  */
91 GWENHYWFAR_API
92 void GWEN_Logger_AddLogger(GWEN_LOGGER *oldLogger, GWEN_LOGGER *newLogger);
93 
94 
95 #ifndef NO_DEPRECATED_SYMBOLS
96 /**
97  * DEPRECATED. Only sets the new default logger if it not already is
98  * set or if the new default logger is NULL.  You must call
99  * GWEN_Logger_Open on that logger prior to calling this function.
100  */
101 GWENHYWFAR_API
102 void GWEN_Logger_SetDefaultLogger(GWEN_LOGGER *lg) DEPRECATED ;
103 #endif // ifndef NO_DEPRECATED_SYMBOLS
104 
105 
106 #ifdef __cplusplus
107 }
108 #endif
109 
110 
111 #endif /* #ifndef GWEN_LOGGER_P_H */
112 
113 
114