libcomps  ..
 All Data Structures Files Functions Variables Typedefs
comps_logger.h
Go to the documentation of this file.
1 /* libcomps - C alternative to yum.comps library
2  * Copyright (C) 2013 Jindrich Luza
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17  * USA
18  */
19 
25 #ifndef COMPS_LOGGER_H
26 #define COMPS_LOGGER_H
27 #include "comps_list.h"
28 #include "comps_elem.h"
29 #include "comps_types.h"
30 
31 typedef enum {COMPS_LOG_INFO, COMPS_LOG_ERROR,
32  COMPS_LOG_WARNING} COMPS_LogEntryType;
33 
39 typedef struct {
41  char * log_message;
43  unsigned int code;
45  unsigned int opt_code1;
47  unsigned int opt_code2;
49  unsigned int opt_code3;
51  unsigned type;
53 
54 //typedef struct COMPS_Logger COMPS_Logger;
55 
56 typedef struct __COMPS_LoggerMsg {
57  unsigned usedm : 2;
58  unsigned used1 : 2;
59  unsigned used2 : 2;
60  unsigned used3 : 2;
61  char * format;
62 } __COMPS_LoggerMsg;
63 
73 struct COMPS_Logger {
77  unsigned redirect2output;
78 };
79 
80 typedef enum {COMPS_ERR_NO_ERR,
81  COMPS_ERR_ELEM_UNKNOWN,
82  COMPS_ERR_ELEM_ALREADYSET,
83  COMPS_ERR_PARSER,
84  COMPS_ERR_DEFAULT_PARAM,
85  COMPS_ERR_USERVISIBLE_PARAM,
86  COMPS_ERR_PACKAGE_UNKNOWN,
87  COMPS_ERR_DEFAULT_MISSING,
88  COMPS_ERR_USERVISIBLE_MISSING,
89  COMPS_ERR_NAME_MISSING,
90  COMPS_ERR_ID_MISSING,
91  COMPS_ERR_DESC_MISSING,
92  COMPS_ERR_GROUPIDS_EMPTY,
93  COMPS_ERR_DTD_ELEM,
94  COMPS_ERR_DTD_SEQUENCE,
95  COMPS_ERR_DTD_ATTRS,
96  COMPS_ERR_DTD_NOCHILD,
97  COMPS_ERR_MALLOC,
98  COMPS_ERR_READFD,
99  COMPS_ERR_WRITEF,
100  COMPS_ERR_XMLGEN,
101  COMPS_ERR_NOPARENT,
102  COMPS_ERR_GROUPLIST_NOTSET,
103  COMPS_ERR_OPTIONLIST_NOTSET,
104  COMPS_ERR_ELEM_REQUIRED,
105  COMPS_ERR_LIST_EMPTY,
106  COMPS_ERR_TEXT_BETWEEN,
107  COMPS_ERR_NOCONTENT} COMPS_LogErrCode;
108 
109 COMPS_Logger * comps_log_create(unsigned redirect2out);
110 void comps_log_destroy(COMPS_Logger * log);
111 
112 COMPS_LoggerEntry * comps_log_entry_create(const char *msg, unsigned type,
113  COMPS_LogErrCode code, unsigned int optcode1,
114  unsigned int optcode2, unsigned int optcode3);
116 void comps_log_error(COMPS_Logger *logger, const char *msg,
117  COMPS_LogErrCode code, unsigned int optcode1,
118  unsigned int optcode2, unsigned int optcode3);
119 void comps_log_warning(COMPS_Logger *logger, const char *msg,
120  COMPS_LogErrCode code, unsigned int optcode1,
121  unsigned int optcode2, unsigned int optcode3);
122 void comps_log_info(COMPS_Logger *logger, const char *msg,
123  COMPS_LogErrCode code, unsigned int optcode1,
124  unsigned int optcode2, unsigned int optcode3);
125 void comps_log_entry_destroy(COMPS_LoggerEntry *entry);
126 void comps_log_entry_destroy_v(void *entry);
127 char* comps_log_str(COMPS_Logger *logger);
128 
129 #endif
130 
char * log_message
Definition: comps_logger.h:41
COMPS_List * logger_data
Definition: comps_logger.h:75
void comps_log_destroy(COMPS_Logger *log)
Definition: comps_logger.c:114
void comps_log_error(COMPS_Logger *logger, const char *msg, COMPS_LogErrCode code, unsigned int optcode1, unsigned int optcode2, unsigned int optcode3)
Definition: comps_logger.c:305
void comps_log_info(COMPS_Logger *logger, const char *msg, COMPS_LogErrCode code, unsigned int optcode1, unsigned int optcode2, unsigned int optcode3)
Definition: comps_logger.c:357
COMPS_Logger * comps_log_create(unsigned redirect2out)
Definition: comps_logger.c:98
char * comps_log_entry_str(COMPS_LoggerEntry *entry)
Definition: comps_logger.c:178
unsigned redirect2output
Definition: comps_logger.h:77
Definition: comps_list.h:76
unsigned int opt_code1
Definition: comps_logger.h:45
A Documented file. Details.
Definition: comps_logger.h:73
char * comps_log_str(COMPS_Logger *logger)
Definition: comps_logger.c:375
unsigned int code
Definition: comps_logger.h:43
Definition: comps_logger.h:39
COMPS_LoggerEntry * comps_log_entry_create(const char *msg, unsigned type, COMPS_LogErrCode code, unsigned int optcode1, unsigned int optcode2, unsigned int optcode3)
Definition: comps_logger.c:137
unsigned int opt_code3
Definition: comps_logger.h:49
unsigned int opt_code2
Definition: comps_logger.h:47
void comps_log_warning(COMPS_Logger *logger, const char *msg, COMPS_LogErrCode code, unsigned int optcode1, unsigned int optcode2, unsigned int optcode3)
Definition: comps_logger.c:333
unsigned type
Definition: comps_logger.h:51