Browse Source

removed logger and source subdirs

1.0.0
Georg Hopp 12 years ago
parent
commit
382518de25
  1. 5
      configure.ac
  2. 2
      include/Makefile.am
  3. 43
      include/tr/interface/logger.h
  4. 59
      include/tr/logger.h
  5. 19
      src/Makefile.am
  6. 0
      src/accept.c
  7. 0
      src/connect.c
  8. 0
      src/i_reader.c
  9. 0
      src/i_writer.c
  10. 0
      src/listen.c
  11. 9
      src/logger/Makefile.am
  12. 62
      src/logger/i_logger.c
  13. 57
      src/logger/logger.c
  14. 39
      src/logger/stderr.c
  15. 52
      src/logger/syslog.c
  16. 0
      src/nonblock.c
  17. 0
      src/read.c
  18. 0
      src/socket.c
  19. 9
      src/socket/Makefile.am
  20. 0
      src/stream.c
  21. 11
      src/stream/Makefile.am
  22. 0
      src/write.c

5
configure.ac

@ -11,7 +11,7 @@ AM_INIT_AUTOMAKE
AM_SILENT_RULES([yes])
AC_COPYRIGHT([Copyright © 2014 Georg Hopp])
AC_REVISION([0.0.0])
AC_CONFIG_SRCDIR([src/stream/stream.c])
AC_CONFIG_SRCDIR([src/stream.c])
AC_CONFIG_HEADERS([trio.h])
AC_CONFIG_MACRO_DIR([m4])
@ -61,8 +61,5 @@ AC_CONFIG_FILES([Makefile
docs/Makefile
tests/Makefile
src/Makefile
src/logger/Makefile
src/socket/Makefile
src/stream/Makefile
include/Makefile])
AC_OUTPUT

2
include/Makefile.am

@ -1,7 +1,5 @@
nobase_include_HEADERS = trio.h \
tr/logger.h \
tr/socket.h \
tr/stream.h \
tr/interface/logger.h \
tr/interface/reader.h \
tr/interface/writer.h

43
include/tr/interface/logger.h

@ -1,43 +0,0 @@
/**
* \file
* The logger interface.
*
* \author Georg Hopp
*
* \copyright
* Copyright © 2012 Georg Hopp
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __TR_INTERFACE_LOGGER_H__
#define __TR_INTERFACE_LOGGER_H__
#include <stdarg.h>
#include "trbase.h"
#include "tr/logger.h"
typedef void (* fptr_TR_log)(void *, TR_logger_level, const char * const);
TR_INTERFACE(TR_Logger) {
TR_IFID;
fptr_TR_log log;
};
extern void TR_loggerLog(void *, TR_logger_level, const char * const, ...);
#endif // __TR_INTERFACE_LOGGER_H__
// vim: set ts=4 sw=4:

59
include/tr/logger.h

@ -1,59 +0,0 @@
/**
* \file
* A generic logger class and two extended classes, One that logs to
* stderr and one that logs to the system syslog.
*
* \author Georg Hopp
*
* \copyright
* Copyright © 2012 Georg Hopp
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __TR_LOGGER_H__
#define __TR_LOGGER_H__
#include "trbase.h"
typedef enum {
TR_LOGGER_DEBUG=0,
TR_LOGGER_INFO,
TR_LOGGER_NOTICE,
TR_LOGGER_WARNING,
TR_LOGGER_ERR,
TR_LOGGER_CRIT,
TR_LOGGER_ALERT,
TR_LOGGER_EMERG
} TR_logger_level;
#include "tr/interface/logger.h"
extern const char * const TR_logger_level_str[];
TR_CLASS(TR_Logger) {
TR_logger_level min_level;
};
TR_CLASS(TR_LoggerStderr) {
TR_EXTENDS(TR_Logger);
};
TR_CLASS(TR_LoggerSyslog) {
TR_EXTENDS(TR_Logger);
};
#endif // __TR_LOGGER_H__
// vim: set ts=4 sw=4:

19
src/Makefile.am

@ -3,14 +3,19 @@ AUTOMAKE_OPTIONS = subdir-objects
AM_CFLAGS += -I../include/
TRIOLIBS = logger/liblogger.la \
stream/libstream.la \
socket/libsocket.la
TRIO = stream.c \
read.c \
write.c \
socket.c \
accept.c \
connect.c \
listen.c \
nonblock.c \
i_reader.c \
i_writer.c
lib_LTLIBRARIES = libtrio.la
libtrio_la_SOURCES =
libtrio_la_SOURCES = $(TRIO)
libtrio_la_CFLAGS = $(AM_CFLAGS)
libtrio_la_LIBADD = $(TRIOLIBS)
SUBDIRS = logger socket stream
libtrio_la_LIBADD =

0
src/socket/accept.c → src/accept.c

0
src/socket/connect.c → src/connect.c

0
src/stream/i_reader.c → src/i_reader.c

0
src/stream/i_writer.c → src/i_writer.c

0
src/socket/listen.c → src/listen.c

9
src/logger/Makefile.am

@ -1,9 +0,0 @@
ACLOCAL_AMFLAGS = -I m4
AUTOMAKE_OPTIONS = subdir-objects
AM_CFLAGS += -I../../include/
noinst_LTLIBRARIES = liblogger.la
liblogger_la_SOURCES = i_logger.c logger.c stderr.c syslog.c
liblogger_la_CFLAGS = $(AM_CFLAGS)

62
src/logger/i_logger.c

@ -1,62 +0,0 @@
/**
* \file
*
* \author Georg Hopp
*
* \copyright
* Copyright © 2012 Georg Hopp
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include "tr/logger.h"
#include "tr/interface/logger.h"
#include "trbase.h"
TR_CREATE_INTERFACE(TR_Logger, 1);
void
TR_loggerLog(
void * _object,
TR_logger_level level,
const char * const fmt,
...) {
TR_Logger object = _object;
if (level >= object->min_level) {
char * msg = NULL;
size_t msg_size = 0;
va_list params;
va_start(params, fmt);
msg_size = vsnprintf(NULL, msg_size, fmt, params);
va_end(params);
msg = TR_malloc(msg_size + 1);
va_start(params, fmt);
vsnprintf(msg, msg_size + 1, fmt, params);
va_end(params);
TR_CALL(_object, TR_Logger, log, level, msg);
TR_MEM_FREE(msg);
}
}
// vim: set ts=4 sw=4:

57
src/logger/logger.c

@ -1,57 +0,0 @@
/**
* \file
*
* \author Georg Hopp
*
* \copyright
* Copyright © 2012 Georg Hopp
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdarg.h>
#include "trbase.h"
#include "tr/logger.h"
#include "tr/interface/logger.h"
const
char * const
TR_logger_level_str[] = {
"DEBUG",
"INFO",
"NOTICE",
"WARNING",
"ERR",
"CRIT",
"ALERT",
"EMERG"
};
static
int
loggerCtor(void * _this, va_list * params)
{
TR_Logger this = _this;
this->min_level = va_arg(*params, int);
return 0;
}
static void loggerDtor(void * _this) {}
TR_INIT_IFACE(TR_Class, loggerCtor, loggerDtor, NULL);
TR_CREATE_CLASS(TR_Logger, NULL, TR_IF(TR_Class));
// vim: set ts=4 sw=4:

39
src/logger/stderr.c

@ -1,39 +0,0 @@
/**
* \file
*
* \author Georg Hopp
*
* \copyright
* Copyright © 2012 Georg Hopp
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include "trbase.h"
#include "tr/logger.h"
#include "tr/interface/logger.h"
static
void
logStderr(void * this, TR_logger_level level, const char * const msg)
{
fprintf(stderr, "[%s] %s\n", TR_logger_level_str[level], msg);
}
TR_INIT_IFACE(TR_Logger, logStderr);
TR_CREATE_CLASS(TR_LoggerStderr, TR_Logger, TR_IF(TR_Logger));
// vim: set ts=4 sw=4:

52
src/logger/syslog.c

@ -1,52 +0,0 @@
/**
* \file
*
* \author Georg Hopp
*
* \copyright
* Copyright © 2012 Georg Hopp
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <syslog.h>
#include "trbase.h"
#include "tr/logger.h"
#include "tr/interface/logger.h"
static
const
int syslog_priority[] = {
LOG_USER | LOG_DEBUG,
LOG_USER | LOG_INFO,
LOG_USER | LOG_NOTICE,
LOG_USER | LOG_WARNING,
LOG_USER | LOG_ERR,
LOG_USER | LOG_CRIT,
LOG_USER | LOG_ALERT,
LOG_USER | LOG_EMERG
};
static
void
logSyslog(void * this, TR_logger_level level, const char * const msg)
{
syslog(syslog_priority[level], "[%s] %s", TR_logger_level_str[level], msg);
}
TR_INIT_IFACE(TR_Logger, logSyslog);
TR_CREATE_CLASS(TR_LoggerSyslog, TR_Logger, TR_IF(TR_Logger));
// vim: set ts=4 sw=4:

0
src/socket/nonblock.c → src/nonblock.c

0
src/stream/read.c → src/read.c

0
src/socket/socket.c → src/socket.c

9
src/socket/Makefile.am

@ -1,9 +0,0 @@
ACLOCAL_AMFLAGS = -I m4
AUTOMAKE_OPTIONS = subdir-objects
AM_CFLAGS += -I../../include/
noinst_LTLIBRARIES = libsocket.la
libsocket_la_SOURCES = socket.c accept.c connect.c listen.c nonblock.c
libsocket_la_CFLAGS = $(AM_CFLAGS)

0
src/stream/stream.c → src/stream.c

11
src/stream/Makefile.am

@ -1,11 +0,0 @@
ACLOCAL_AMFLAGS = -I m4
AUTOMAKE_OPTIONS = subdir-objects
AM_CFLAGS += -I../../include/
STREAM = stream.c read.c write.c i_reader.c i_writer.c
noinst_LTLIBRARIES = libstream.la
libstream_la_SOURCES = $(STREAM)
libstream_la_CFLAGS = $(AM_CFLAGS)

0
src/stream/write.c → src/write.c

Loading…
Cancel
Save