Browse Source

remove old log stuff

personal/stbuehler/wip
Thomas Porzelt 14 years ago
parent
commit
58cf85f5d1
  1. 50
      include/lighttpd/log.h
  2. 20
      src/log.c
  3. 4
      src/server.c

50
include/lighttpd/log.h

@ -15,58 +15,23 @@ LI_API const char *remove_path(const char *path);
#define REMOVE_PATH(file) file
#endif
#define ERROR(srv, fmt, ...) \
log_write(srv, NULL, "%s.%d: (error) "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
#define INFO(srv, ...) \
log_write(srv, NULL, __VA_ARGS__)
#define TRACE(srv, fmt, ...) \
log_write(srv, NULL, "%s.%d: (trace) "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
#define SEGFAULT(srv, fmt, ...) \
do { \
log_write(srv, NULL, "%s.%d: (crashing) "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__); \
/* VALGRIND_PRINTF_BACKTRACE(fmt, __VA_ARGS__); */\
abort();\
} while(0)
#define CON_ERROR(con, fmt, ...) \
log_write(NULL, con, "%s.%d: (error) "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__) \
#define CON_TRACE(con, fmt, ...) \
log_write(NULL, con, "%s.%d: (trace) "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
#define CON_SEGFAULT(con, fmt, ...) \
do { \
log_write(NULL, con, "%s.%d: (crashing) "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__); \
/* VALGRIND_PRINTF_BACKTRACE(fmt, __VA_ARGS__); */ \
abort();\
} while(0)
#define VR_ERROR(vr, fmt, ...) CON_ERROR(vr->con, fmt, __VA_ARGS__)
#define VR_TRACE(vr, fmt, ...) CON_TRACE(vr->con, fmt, __VA_ARGS__)
#define VR_SEGFAULT(vr, fmt, ...) CON_SEGFAULT(vr->con, fmt, __VA_ARGS__)
#undef ERROR
#define ERROR(srv, fmt, ...) \
log_write_(srv, NULL, LOG_LEVEL_ERROR, LOG_FLAG_TIMETAMP, "(error) %s.%d: "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
/*#undef INFO
#define INFO(srv, fmt, ...) \
log_write_(srv, NULL, LOG_LEVEL_INFO, LOG_FLAG_TIMETAMP, "%s.%d: (info) "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
*/
#undef TRACE
log_write_(srv, NULL, LOG_LEVEL_INFO, LOG_FLAG_TIMETAMP, "(info) %s.%d: "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
#define TRACE(srv, fmt, ...) \
log_write_(srv, NULL, LOG_LEVEL_INFO, LOG_FLAG_TIMETAMP, "(trace) %s.%d: "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
log_write_(srv, NULL, LOG_LEVEL_INFO, LOG_FLAG_TIMETAMP, "(debug) %s.%d: "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
/*
#undef CON_ERROR
#define CON_ERROR(con, fmt, ...) \
log_write_(con->srv, con, LOG_LEVEL_ERROR, LOG_FLAG_TIMETAMP, "%s.%d: (error) "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
*/
#undef CON_TRACE
#define CON_TRACE(con, fmt, ...) \
log_write_(con->srv, con, LOG_LEVEL_DEBUG, LOG_FLAG_TIMETAMP, "%s.%d: (debug) "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
@ -74,7 +39,7 @@ LI_API const char *remove_path(const char *path);
/* TODO: perhaps make portable (detect if cc supports) */
#define __ATTRIBUTE_PRINTF_FORMAT(fmt, arg) __attribute__ ((__format__ (__printf__, fmt, arg)))
LI_API int log_write(server *srv, connection *con, const char *fmt, ...) __ATTRIBUTE_PRINTF_FORMAT(3, 4);
/*LI_API int log_write(server *srv, connection *con, const char *fmt, ...) __ATTRIBUTE_PRINTF_FORMAT(3, 4);*/
@ -184,6 +149,9 @@ void log_thread_wakeup(server *srv);
void log_init(server *srv);
void log_cleanup(server *srv);
/* log_write is used to directly write a message to a log target */
LI_API void log_write(server *srv, log_t *log, GString *msg);
/* log_write_ is used to write to the errorlog */
LI_API gboolean log_write_(server *srv, connection *con, log_level_t log_level, guint flags, const gchar *fmt, ...) __ATTRIBUTE_PRINTF_FORMAT(5, 6);
log_timestamp_t *log_timestamp_new(server *srv, GString *format);

20
src/log.c

@ -17,24 +17,18 @@ const char *remove_path(const char *path) {
}
#endif
int log_write(server* UNUSED_PARAM(srv), connection* UNUSED_PARAM(con), const char *fmt, ...) {
va_list ap;
GString *logline;
logline = g_string_sized_new(0);
va_start(ap, fmt);
g_string_vprintf(logline, fmt, ap);
va_end(ap);
void log_write(server *srv, log_t *log, GString *msg) {
log_entry_t *log_entry;
log_ref(srv, log);
g_string_append_len(logline, CONST_STR_LEN("\r\n"));
write(STDERR_FILENO, logline->str, logline->len);
g_string_free(logline, TRUE);
log_entry = g_slice_new(log_entry_t);
log_entry->log = log;
log_entry->msg = msg;
return 0;
g_async_queue_push(srv->logs.queue, log_entry);
}
gboolean log_write_(server *srv, connection *con, log_level_t log_level, guint flags, const gchar *fmt, ...) {
va_list ap;
GString *log_line;

4
src/server.c

@ -32,10 +32,10 @@ static void sigint_cb(struct ev_loop *loop, struct ev_signal *w, int revents) {
UNUSED(revents);
if (g_atomic_int_get(&srv->state) != SERVER_STOPPING) {
INFO(srv, "Got signal, shutdown");
INFO(srv, "%s", "Got signal, shutdown");
server_stop(srv);
} else {
INFO(srv, "Got second signal, force shutdown");
INFO(srv, "%s", "Got second signal, force shutdown");
/* reset default behaviour which will kill us the third time */
UNCATCH_SIGNAL(loop, INT);

Loading…
Cancel
Save