Commit 86ac5e96 authored by Hardy Simpson's avatar Hardy Simpson

go on

parent 20f61b9c
[p] 使用valgrind测试性能
[ ] 和rsyslog对接的问题
[ ] hzlog的可定制
[ ] 分类匹配的可定制化, rcat
[ ] 兼容性问题 zlog.h内,__VA_ARGS__的跨平台
......@@ -11,11 +10,13 @@
[ ] gettid()
[ ] 性能对比, log4x, pantheios, glog
[ ] perl, python, go, c++支持
[ ] 去除auto tools的使用,自行makefile[redis]
[ ] redis内置绑定
[ ] redis对接,协议设计
[ ] 和rsyslog对接的问题
--- 1.1.4 ---
[ ] 增加版本内置(redis)
[ ] record忽略第二参数
[ ] 增加git/版本在代码中的标志(redis)
[o] 去除auto tools的使用,自行makefile[redis]
[o] 宏都小写化
[o] const
[x] zlog_set("section", "command");
......
AC_PREREQ(2.59)
AC_INIT([zlog], [1.1.3], [HardySimpson1984@gmail.com])
AM_INIT_AUTOMAKE([foreign -Wall -Werror])
AC_CONFIG_SRCDIR([libzlog/zlog.h])
AC_CONFIG_HEADER([config.h])
AC_GNU_SOURCE
# Checks for programs.
AC_PROG_CPP
AC_PROG_CC
AC_PROG_AWK
AC_PROG_INSTALL
AC_PROG_LIBTOOL
AC_PROG_LN_S
AC_PROG_MAKE_SET
# Checks for libraries.
AC_CHECK_LIB([pthread], [pthread_rwlock_wrlock], [PTREADLIB=-lpthread])
if test "x$PTREADLIB" != "x-lpthread"; then
AC_MSG_ERROR([You need libpthread in order to compile libzlog])
fi
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([fcntl.h limits.h stdint.h stdlib.h string.h strings.h sys/time.h syslog.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_STRUCT_TM
# Checks for library functions.
AC_FUNC_FORK
AC_FUNC_LSTAT
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_STAT
AC_FUNC_STRFTIME
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([gethostname gettimeofday localtime_r memmove memset setenv strchr strrchr strstr strtol])
if test "x$GCC" = "xyes"; then
CFLAGS="$CFLAGS -D_GNU_SOURCE -pthread"
fi
AC_ARG_ENABLE(test,
[AC_HELP_STRING([--enable-test], [Compile tests])],
enable_test=yes)
AM_CONDITIONAL(ENABLE_TEST, test x$enable_test = xyes)
AC_ARG_ENABLE(doc,
[AC_HELP_STRING([--enable-doc], [Create pdf from lyx])],
enable_doc=yes)
# Checks for lyx
AC_PATH_PROG(LYX, lyx, )
if test x$LYX = x; then
enable_doc=no
fi
AM_CONDITIONAL(ENABLE_DOC, test x$enable_doc = xyes)
AC_CONFIG_FILES([
zlog.pc
Makefile
libzlog/Makefile
tools/Makefile
test/Makefile
doc/Makefile
])
AC_OUTPUT
#! /bin/sh
# from configure,Makefile.am->Makefile, developer use
CFLAGS="-Wall -Werror -g -O2 -std=c99" ./configure --prefix=/opt/develop/ --enable-test --enable-doc
docdir = $(datadir)/doc/$(PACKAGE)
man3dir = $(mandir)/man3
doc_DATA = \
UsersGuide-EN.pdf \
UsersGuide-CN.pdf \
UsersGuide-EN.tex \
UsersGuide-CN.tex \
UsersGuide-EN.html \
UsersGuide-CN.html \
GettingStart-EN.txt \
GettingStart-CN.txt
EXTRA_DIST = $(doc_DATA) \
UsersGuide-EN.lyx \
UsersGuide-CN.lyx
doc = \
UsersGuide-EN.pdf \
UsersGuide-CN.pdf \
UsersGuide-EN.tex \
UsersGuide-CN.tex \
UsersGuide-EN.html \
UsersGuide-CN.html \
GettingStart-EN.txt \
GettingStart-CN.txt
all : $(doc)
UsersGuide-EN.pdf : UsersGuide-EN.lyx
lyx -f -e pdf2 $^
......@@ -22,12 +16,12 @@ UsersGuide-EN.pdf : UsersGuide-EN.lyx
UsersGuide-CN.pdf : UsersGuide-CN.lyx
lyx -f -e pdf4 $^
.lyx.tex :
%.tex : %.lyx
lyx -f -e pdflatex $<
.tex.html :
%.html : %.tex
hevea book.hva -s $<
hevea book.hva -s $<
clean-local :
clean :
-rm -f *.pdf *.haux *.html *.htoc *.tex
# Top level makefile, the real shit is at src/makefile
TARGETS=all test doc 32bit
TARGETS=noopt 32bit
all:
cd src && $(MAKE) $@
install: dummy
install:
cd src && $(MAKE) $@
$(TARGETS):
cd src && $(MAKE) $@
doc:
cd doc && $(MAKE)
test:
cd test && $(MAKE)
clean:
cd src && $(MAKE) $@
cd test && $(MAKE) $@
......@@ -15,10 +24,6 @@ clean:
distclean: clean
$(TARGETS):
cd src && $(MAKE) $@
src/help.h:
@./utils/generate-command-help.rb > $@
dummy:
.PHONY: doc install test
lib_LTLIBRARIES = libzlog.la
libzlog_la_SOURCES = \
zc_profile.c \
zc_profile.h \
zc_arraylist.c \
zc_arraylist.h \
zc_hashtable.c \
zc_hashtable.h \
zc_util.c \
zc_util.h \
zc_xplatform.c \
zc_xplatform.h \
zc_defs.h \
rotater.c \
rotater.h \
level.c \
level.h \
level_list.c \
level_list.h \
spec.c \
spec.h \
format.c \
format.h \
rule.c \
rule.h \
conf.c \
conf.h \
buf.c \
buf.h \
event.c \
event.h \
mdc.c \
mdc.h \
thread.c \
thread.h \
thread_list.c \
thread_list.h \
record.c \
record.h \
record_table.c \
record_table.h \
category.c \
category.h \
category_table.c \
category_table.h \
zlog.c
libzlog_la_LIBADD = $(PTREADLIB)
libzlog_la_LDFLAGS = -version-info 1:0:0
include_HEADERS = zlog.h
......@@ -34,14 +34,14 @@ ZLOG_MINOR=1
CC:=$(shell sh -c 'type $(CC) >/dev/null 2>/dev/null && echo $(CC) || echo gcc')
OPTIMIZATION?=-O2
WARNINGS=-Wall -Werror -Wstrict-prototypes
DEBUG?= -g -ggdb # will this slow down the run speed ?
DEBUG?= -g -ggdb
REAL_CFLAGS=$(OPTIMIZATION) -fPIC $(CFLAGS) $(WARNINGS) $(DEBUG)
REAL_LDFLAGS=$(LDFLAGS) -lpthread
DYLIBSUFFIX=so
STLIBSUFFIX=a
DYLIB_MINOR_NAME=$(LIBNAME).$(DYLIBSUFFIX).$(HIREDIS_MAJOR).$(HIREDIS_MINOR)
DYLIB_MAJOR_NAME=$(LIBNAME).$(DYLIBSUFFIX).$(HIREDIS_MAJOR)
DYLIB_MINOR_NAME=$(LIBNAME).$(DYLIBSUFFIX).$(ZLOG_MAJOR).$(ZLOG_MINOR)
DYLIB_MAJOR_NAME=$(LIBNAME).$(DYLIBSUFFIX).$(ZLOG_MAJOR)
DYLIBNAME=$(LIBNAME).$(DYLIBSUFFIX)
DYLIB_MAKE_CMD=$(CC) -shared -Wl,-soname,$(DYLIB_MINOR_NAME) -o $(DYLIBNAME) $(LDFLAGS)
STLIBNAME=$(LIBNAME).$(STLIBSUFFIX)
......@@ -179,4 +179,4 @@ coverage: gcov
noopt:
$(MAKE) OPTIMIZATION=""
.PHONY: all test check clean dep install 32bit gprof gcov noopt
.PHONY: all clean dep install 32bit gprof gcov noopt
# use autotools and xlc on aix never success, so use this for test
all_o = zlog.o event.o conf.o format.o rule.o level.o buf.o \
sd_rotate.o sd_error.o sd_list.o sd_xplatform.o sd_util.o
all : libzlog.so
libzlog.so : $(all_o)
xlc -G -o $@ $(all_o) -lpthread
zlog-chk-conf : zlog-chk-conf.o
xlc -brtl -o $@ zlog_chkconfig.o -L. -lzlog
.c.o :
xlc -c -o $@ -c $< -I.
clean :
-rm -f libzlog.so zlog-chk-conf zlog-chk-conf.o $(all_o)
install :
cp -f libzlog.so $(HOME)/lib
cp -f zlog_chkconfig $(HOME)/bin
cp -f zlog.h $(HOME)/include
cp -f shbin/* $(HOME)/shbin
all_o = \
buf.o \
category.o \
conf.o \
event.o \
format.o \
mdc.o \
level.o \
rotater.o \
rule.o \
spec.o \
thread.o \
zlog.o \
zc_arraylist.o \
zc_profile.o \
zc_hashtable.o \
zc_util.o \
zc_xplatform.o
all : libzlog.so
libzlog.so : $(all_o)
gcc -shared -o $@ $(all_o) -lpthread
.c.o :
gcc -g -Wall -Werror -D_GNU_SOURCE -fPIC -o $@ -c $< -I.
#-Werror
clean :
-rm -f libzlog.so $(all_o)
all_o = \
buf.o \
category.o \
category_table.o \
conf.o \
event.o \
format.o \
level.o \
level_list.o \
mdc.o \
rotater.o \
rule.o \
spec.o \
thread.o \
thread_table.o \
zc_arraylist.o \
zc_hashtable.o \
zc_profile.o \
zc_util.o \
zc_xplatform.o \
zlog.o \
all : libzlog.a
libzlog.a : $(all_o)
ar -rv $@ $(all_o)
.c.o :
gcc -pg -Wall -D_GNU_SOURCE -o $@ -c $< -I.
clean :
-rm -f libzlog.a $(all_o) zlog_chk_conf zlog_chk_conf.o
install :
cp -f libzlog.so $(HOME)/lib
cp -f zlog_chk_conf $(HOME)/bin
cp -f zlog.h $(HOME)/include
cp -f shbin/* $(HOME)/shbin
exe = \
test_tmp \
test_buf \
test_bitmap \
test_conf \
test_filemv \
test_hashtable \
......@@ -20,15 +21,15 @@ exe = \
test_default \
test_profile
.PHONY : clean all
all : $(exe)
$(exe) : %:%.o
gcc -O2 -g -o $@ $^ -L../libzlog/.libs -lzlog -lpthread -Wl,-rpath ../libzlog/.libs
gcc -O2 -g -static -o $@ $^ -L../src -lzlog -lpthread -Wl,-rpath ../src
.c.o :
gcc -O2 -g -Wall -D_GNU_SOURCE -o $@ -c $< -I. -I../libzlog
gcc -O2 -g -Wall -D_GNU_SOURCE -o $@ -c $< -I. -I../src
clean :
rm -f press.log* *.o $(exe)
.PHONY : clean all
......@@ -37,12 +37,12 @@ int main(int argc, char** argv)
aa[i/8] |= ~(0xFF << (8 - i % 8));
memset(aa + i/8 + 1, 0xFF, sizeof(aa) - i/8 - 1);
HDZLOG_INFO(aa, sizeof(aa));
hdzlog_info(aa, sizeof(aa));
DZLOG_INFO("%0x", aa[j/8]);
DZLOG_INFO("%0x", aa[j/8] >> 6);
dzlog_info("%0x", aa[j/8]);
dzlog_info("%0x", aa[j/8] >> 6);
DZLOG_INFO("%0x", ~((aa[j/8] >> (7 - j % 8)) & 0x01) );
dzlog_info("%0x", ~((aa[j/8] >> (7 - j % 8)) & 0x01) );
zlog_fini();
......
......@@ -44,7 +44,7 @@ int main(int argc, char** argv)
return -2;
}
ZLOG_INFO(zc, "hello, zlog");
zlog_info(zc, "hello, zlog");
zlog_fini();
printf("log end\n");
......
......@@ -30,7 +30,7 @@ int main(int argc, char** argv)
return -1;
}
DZLOG_INFO("hello, zlog");
dzlog_info("hello, zlog");
zlog_fini();
......
......@@ -38,7 +38,7 @@ int main(int argc, char** argv)
return -2;
}
ZLOG_INFO(zc, "hello, zlog");
zlog_info(zc, "hello, zlog");
zlog_fini();
......
......@@ -111,7 +111,7 @@ int main(int argc, char** argv)
rc = ReadTotalFile(fp, &dmp, &dmp_len);
while(ntimes--) HZLOG_DEBUG(zc, dmp, dmp_len);
while(ntimes--) hzlog_debug(zc, dmp, dmp_len);
fclose(fp);
free(dmp);
......
......@@ -44,7 +44,7 @@ int main(int argc, char** argv)
return -1;
}
ZLOG_INFO(zc, "before update");
zlog_info(zc, "before update");
sleep(3);
......@@ -53,7 +53,7 @@ int main(int argc, char** argv)
printf("update fail\n");
}
ZLOG_INFO(zc, "after update");
zlog_info(zc, "after update");
zlog_profile();
......
......@@ -38,9 +38,9 @@ int main(int argc, char** argv)
return -2;
}
ZLOG_TRACE(zc, "hello, zlog - trace");
ZLOG_DEBUG(zc, "hello, zlog - debug");
ZLOG_INFO(zc, "hello, zlog - info");
zlog_trace(zc, "hello, zlog - trace");
zlog_debug(zc, "hello, zlog - debug");
zlog_info(zc, "hello, zlog - info");
zlog_fini();
......
......@@ -27,7 +27,7 @@ enum {
/* must equals conf file setting */
};
#define ZLOG_TRACE(cat, format, args...) \
#define zlog_trace(cat, format, args...) \
zlog(cat, __FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
ZLOG_LEVEL_TRACE, format, ##args)
......
......@@ -44,15 +44,15 @@ int main(int argc, char** argv)
}
ZLOG_INFO(zc, "1.hello, zlog");
zlog_info(zc, "1.hello, zlog");
zlog_put_mdc("myname", "Zhang");
ZLOG_INFO(zc, "2.hello, zlog");
zlog_info(zc, "2.hello, zlog");
zlog_put_mdc("myname", "Li");
ZLOG_INFO(zc, "3.hello, zlog");
zlog_info(zc, "3.hello, zlog");
zlog_fini();
......
......@@ -33,7 +33,7 @@ void * work(void *ptr)
{
long j = loop_count;
while(j-- > 0) {
ZLOG_INFO(zc, "loglog");
zlog_info(zc, "loglog");
}
return 0;
}
......
......@@ -41,7 +41,7 @@ void * work(void *ptr)
zc = zlog_get_category(category);
while(j-- > 0) {
ZLOG_INFO(zc, "loglog");
zlog_info(zc, "loglog");
}
return 0;
}
......
......@@ -30,7 +30,7 @@ int main(int argc, char** argv)
return -1;
}
DZLOG_INFO("hello, zlog");
dzlog_info("hello, zlog");
zlog_profile();
......
......@@ -46,7 +46,7 @@ int main(int argc, char** argv)
return -2;
}
ZLOG_INFO(zc, "hello, zlog");
zlog_info(zc, "hello, zlog");
zlog_fini();
return 0;
}
......@@ -38,8 +38,8 @@ int main(int argc, char** argv)
return -2;
}
ZLOG_INFO(zc, "hello, zlog -- info");
ZLOG_ERROR(zc, "hello, zlog -- error");
zlog_info(zc, "hello, zlog -- info");
zlog_error(zc, "hello, zlog -- error");
zlog_fini();
......
......@@ -38,7 +38,7 @@ int main(int argc, char** argv)
return -2;
}
ZLOG_INFO(zc, "hello, zlog");
zlog_info(zc, "hello, zlog");
zlog_profile();
zlog_fini();
......
unset ZLOG_PROFILE_ERROR
unset ZLOG_PROFILE_DEBUG_LOG
#export ZLOG_PROFILE_DEBUG=err.log
#export ZLOG_PROFILE_ERROR=err.log
make -f makefile.linux clean
make -f makefile.linux
rm -f press*log
valgrind --tool=callgrind ./test_press_zlog 1 10 10000
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment