Kannel: Open Source WAP and SMS gateway  $Revision: 5037 $
accesslog.h File Reference

Go to the source code of this file.

Functions

void alog_open (char *fname, int use_localtime, int use_markers)
 
void alog_close (void)
 
void alog_reopen (void)
 
void alog_use_localtime (void)
 
void alog_use_gmtime (void)
 
void alog (const char *fmt,...) PRINTFLIKE(1
 

Function Documentation

void alog ( const char *  fmt,
  ... 
)
void alog_close ( void  )

Definition at line 111 of file accesslog.c.

References alog(), file, gwlist_consume(), gwlist_destroy(), gwlist_lock(), gwlist_unlock(), and markers.

Referenced by alog_open(), and main().

112 {
113 
114  if (file != NULL) {
115  if (markers)
116  alog("Log ends");
118  /* wait for writers to complete */
120  fclose(file);
121  file = NULL;
123  gwlist_destroy(writers, NULL);
124  writers = NULL;
125  }
126 }
static int markers
Definition: accesslog.c:78
void gwlist_unlock(List *list)
Definition: list.c:354
void gwlist_lock(List *list)
Definition: list.c:347
void * gwlist_consume(List *list)
Definition: list.c:427
void alog(const char *fmt,...)
Definition: accesslog.c:206
static List * writers
Definition: accesslog.c:83
static FILE * file
Definition: accesslog.c:75
void gwlist_destroy(List *list, gwlist_item_destructor_t *destructor)
Definition: list.c:145
void alog_open ( char *  fname,
int  use_localtime,
int  use_markers 
)

Definition at line 129 of file accesslog.c.

References alog(), alog_close(), error(), file, filename, gwlist_create, info(), markers, use_localtime, and warning().

Referenced by init_bearerbox(), init_smsbox(), and init_wapbox().

130 {
131  FILE *f;
132 
133  use_localtime = use_localtm;
134  markers = use_markers;
135 
136  if (file != NULL) {
137  warning(0, "Opening an already opened access log");
138  alog_close();
139  }
140  if (strlen(fname) > FILENAME_MAX) {
141  error(0, "Access Log filename too long: `%s', cannot open.", fname);
142  return;
143  }
144 
145  if (writers == NULL)
147 
148  f = fopen(fname, "a");
149  if (f == NULL) {
150  error(errno, "Couldn't open logfile `%s'.", fname);
151  return;
152  }
153  file = f;
154  strcpy(filename, fname);
155  info(0, "Started access logfile `%s'.", filename);
156  if (markers)
157  alog("Log begins");
158 }
void error(int err, const char *fmt,...)
Definition: log.c:612
void info(int err, const char *fmt,...)
Definition: log.c:636
static int markers
Definition: accesslog.c:78
static char filename[FILENAME_MAX+1]
Definition: accesslog.c:76
static int use_localtime
Definition: accesslog.c:77
void warning(int err, const char *fmt,...)
Definition: log.c:624
void alog(const char *fmt,...)
Definition: accesslog.c:206
static List * writers
Definition: accesslog.c:83
static FILE * file
Definition: accesslog.c:75
void alog_close(void)
Definition: accesslog.c:111
#define gwlist_create()
Definition: list.h:136
void alog_reopen ( void  )

Definition at line 85 of file accesslog.c.

References alog(), error(), file, filename, gwlist_consume(), gwlist_lock(), gwlist_unlock(), and markers.

Referenced by main(), and signal_handler().

86 {
87  if (file == NULL)
88  return;
89 
90  if (markers)
91  alog("Log ends");
92 
94  /* wait for writers to complete */
96 
97  fclose(file);
98  file = fopen(filename, "a");
99 
101 
102  if (file == NULL) {
103  error(errno, "Couldn't re-open access logfile `%s'.", filename);
104  }
105  else if (markers) {
106  alog("Log begins");
107  }
108 }
void error(int err, const char *fmt,...)
Definition: log.c:612
static int markers
Definition: accesslog.c:78
static char filename[FILENAME_MAX+1]
Definition: accesslog.c:76
void gwlist_unlock(List *list)
Definition: list.c:354
void gwlist_lock(List *list)
Definition: list.c:347
void * gwlist_consume(List *list)
Definition: list.c:427
void alog(const char *fmt,...)
Definition: accesslog.c:206
static List * writers
Definition: accesslog.c:83
static FILE * file
Definition: accesslog.c:75
void alog_use_gmtime ( void  )

Definition at line 167 of file accesslog.c.

References use_localtime.

168 {
169  use_localtime = 0;
170 }
static int use_localtime
Definition: accesslog.c:77
void alog_use_localtime ( void  )

Definition at line 161 of file accesslog.c.

References use_localtime.

162 {
163  use_localtime = 1;
164 }
static int use_localtime
Definition: accesslog.c:77
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.