mirror of http://192.168.1.51:8099/lmh188/twain3.0
2021.4.14 修改尺寸检测禁用问题
添加立思辰G73S,G62S系列 修改DPI过高后设置幅面过大自动跳回双面扫描问题 2021.4.17 添加G300,G400尺寸检测 2021.4.18 修改异常后G300,G400继续读取dsp状态问题 2021.4.29 增加log4记录,修改300 400有无纸检测部分逻辑 2021.5.10 修改取图延时为30s 添加进度指示器扫描张数提示 2021.5.11 修改自动颜色识别下对折功能灰度彩色合并崩溃问题 2021.5.12 修复log4cplusS多次全局初始化崩溃问题 添加扫描仪计数张数与接收图片数对比功能 2021.5.13 修改hidedlg.exe,调整弹窗模式
This commit is contained in:
parent
a3b3b636ad
commit
3a62d3d51b
|
@ -0,0 +1,81 @@
|
|||
## Generated by Autogen from Makefile.am.tpl
|
||||
log4cplusincdir = $(includedir)
|
||||
|
||||
nobase_log4cplusinc_HEADERS = \
|
||||
log4cplus/appender.h \
|
||||
log4cplus/asyncappender.h \
|
||||
log4cplus/boost/deviceappender.hxx \
|
||||
log4cplus/callbackappender.h \
|
||||
log4cplus/clfsappender.h \
|
||||
log4cplus/clogger.h \
|
||||
log4cplus/config.hxx \
|
||||
log4cplus/config/defines.hxx \
|
||||
log4cplus/config/macosx.h \
|
||||
log4cplus/config/win32.h \
|
||||
log4cplus/config/windowsh-inc-full.h \
|
||||
log4cplus/config/windowsh-inc.h \
|
||||
log4cplus/configurator.h \
|
||||
log4cplus/consoleappender.h \
|
||||
log4cplus/fileappender.h \
|
||||
log4cplus/fstreams.h \
|
||||
log4cplus/helpers/appenderattachableimpl.h \
|
||||
log4cplus/helpers/connectorthread.h \
|
||||
log4cplus/helpers/fileinfo.h \
|
||||
log4cplus/helpers/lockfile.h \
|
||||
log4cplus/helpers/loglog.h \
|
||||
log4cplus/helpers/pointer.h \
|
||||
log4cplus/helpers/property.h \
|
||||
log4cplus/helpers/queue.h \
|
||||
log4cplus/helpers/snprintf.h \
|
||||
log4cplus/helpers/socket.h \
|
||||
log4cplus/helpers/socketbuffer.h \
|
||||
log4cplus/helpers/stringhelper.h \
|
||||
log4cplus/helpers/thread-config.h \
|
||||
log4cplus/helpers/timehelper.h \
|
||||
log4cplus/hierarchy.h \
|
||||
log4cplus/hierarchylocker.h \
|
||||
log4cplus/initializer.h \
|
||||
log4cplus/internal/customloglevelmanager.h \
|
||||
log4cplus/internal/cygwin-win32.h \
|
||||
log4cplus/internal/env.h \
|
||||
log4cplus/internal/internal.h \
|
||||
log4cplus/internal/socket.h \
|
||||
log4cplus/layout.h \
|
||||
log4cplus/log4cplus.h \
|
||||
log4cplus/log4judpappender.h \
|
||||
log4cplus/logger.h \
|
||||
log4cplus/loggingmacros.h \
|
||||
log4cplus/loglevel.h \
|
||||
log4cplus/mdc.h \
|
||||
log4cplus/msttsappender.h \
|
||||
log4cplus/ndc.h \
|
||||
log4cplus/nteventlogappender.h \
|
||||
log4cplus/nullappender.h \
|
||||
log4cplus/qt4debugappender.h \
|
||||
log4cplus/qt5debugappender.h \
|
||||
log4cplus/socketappender.h \
|
||||
log4cplus/spi/appenderattachable.h \
|
||||
log4cplus/spi/factory.h \
|
||||
log4cplus/spi/filter.h \
|
||||
log4cplus/spi/loggerfactory.h \
|
||||
log4cplus/spi/loggerimpl.h \
|
||||
log4cplus/spi/loggingevent.h \
|
||||
log4cplus/spi/objectregistry.h \
|
||||
log4cplus/spi/rootlogger.h \
|
||||
log4cplus/streams.h \
|
||||
log4cplus/syslogappender.h \
|
||||
log4cplus/tchar.h \
|
||||
log4cplus/thread/impl/syncprims-cxx11.h \
|
||||
log4cplus/thread/impl/syncprims-impl.h \
|
||||
log4cplus/thread/impl/syncprims-pmsm.h \
|
||||
log4cplus/thread/impl/threads-impl.h \
|
||||
log4cplus/thread/impl/tls.h \
|
||||
log4cplus/thread/syncprims-pub-impl.h \
|
||||
log4cplus/thread/syncprims.h \
|
||||
log4cplus/thread/threads.h \
|
||||
log4cplus/tracelogger.h \
|
||||
log4cplus/tstring.h \
|
||||
log4cplus/version.h \
|
||||
log4cplus/win32consoleappender.h \
|
||||
log4cplus/win32debugappender.h
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
AutoGen definitions Makefile.am.tpl;
|
||||
|
||||
src-dirs = { name = log4cplus; };
|
|
@ -0,0 +1,25 @@
|
|||
[= AutoGen5 template -*- Mode: scheme -*-
|
||||
am
|
||||
=][=
|
||||
(use-modules (ice-9 ftw))
|
||||
=]## Generated by Autogen from [= (tpl-file) =]
|
||||
log4cplusincdir = $(includedir)
|
||||
|
||||
nobase_log4cplusinc_HEADERS = \
|
||||
[= FOR src-dirs =][=
|
||||
(let ((files (list)))
|
||||
(define (emit-am-file-ftw-cb filename statinfo flag)
|
||||
(begin
|
||||
(if (or (string-suffix-ci? ".h" filename)
|
||||
(string-suffix-ci? ".hxx" filename))
|
||||
(set! files (append! files (list filename))))
|
||||
#t))
|
||||
(begin
|
||||
(ftw (get "name") emit-am-file-ftw-cb)
|
||||
;; Add the generated header as it will not be found by file search.
|
||||
(append! files (list "log4cplus/config/defines.hxx"))
|
||||
(set! files (sort! files string-ci<?))
|
||||
(emit "\t"
|
||||
(join " \\\n\t" files)
|
||||
"\n")))
|
||||
=][= ENDFOR =]
|
|
@ -0,0 +1,677 @@
|
|||
# Makefile.in generated by automake 1.16.3 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2020 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
VPATH = @srcdir@
|
||||
am__is_gnu_make = { \
|
||||
if test -z '$(MAKELEVEL)'; then \
|
||||
false; \
|
||||
elif test -n '$(MAKE_HOST)'; then \
|
||||
true; \
|
||||
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
|
||||
true; \
|
||||
else \
|
||||
false; \
|
||||
fi; \
|
||||
}
|
||||
am__make_running_with_option = \
|
||||
case $${target_option-} in \
|
||||
?) ;; \
|
||||
*) echo "am__make_running_with_option: internal error: invalid" \
|
||||
"target option '$${target_option-}' specified" >&2; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
has_opt=no; \
|
||||
sane_makeflags=$$MAKEFLAGS; \
|
||||
if $(am__is_gnu_make); then \
|
||||
sane_makeflags=$$MFLAGS; \
|
||||
else \
|
||||
case $$MAKEFLAGS in \
|
||||
*\\[\ \ ]*) \
|
||||
bs=\\; \
|
||||
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
|
||||
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
|
||||
esac; \
|
||||
fi; \
|
||||
skip_next=no; \
|
||||
strip_trailopt () \
|
||||
{ \
|
||||
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
|
||||
}; \
|
||||
for flg in $$sane_makeflags; do \
|
||||
test $$skip_next = yes && { skip_next=no; continue; }; \
|
||||
case $$flg in \
|
||||
*=*|--*) continue;; \
|
||||
-*I) strip_trailopt 'I'; skip_next=yes;; \
|
||||
-*I?*) strip_trailopt 'I';; \
|
||||
-*O) strip_trailopt 'O'; skip_next=yes;; \
|
||||
-*O?*) strip_trailopt 'O';; \
|
||||
-*l) strip_trailopt 'l'; skip_next=yes;; \
|
||||
-*l?*) strip_trailopt 'l';; \
|
||||
-[dEDm]) skip_next=yes;; \
|
||||
-[JT]) skip_next=yes;; \
|
||||
esac; \
|
||||
case $$flg in \
|
||||
*$$target_option*) has_opt=yes; break;; \
|
||||
esac; \
|
||||
done; \
|
||||
test $$has_opt = yes
|
||||
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
|
||||
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
target_triplet = @target@
|
||||
subdir = include
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \
|
||||
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
|
||||
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
|
||||
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \
|
||||
$(top_srcdir)/m4/ax_c_ifdef.m4 \
|
||||
$(top_srcdir)/m4/ax_append_flag.m4 \
|
||||
$(top_srcdir)/m4/ax_cflags_warn_all.m4 \
|
||||
$(top_srcdir)/m4/ax_type_socklen_t.m4 \
|
||||
$(top_srcdir)/m4/ax_compiler_vendor.m4 \
|
||||
$(top_srcdir)/m4/ax_cflags_gcc_option.m4 \
|
||||
$(top_srcdir)/m4/ax_cflags_sun_option.m4 \
|
||||
$(top_srcdir)/m4/ax_cflags_aix_option.m4 \
|
||||
$(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/ax_declspec.m4 \
|
||||
$(top_srcdir)/m4/ax_tls_support.m4 \
|
||||
$(top_srcdir)/m4/ax_macro_function.m4 \
|
||||
$(top_srcdir)/m4/ax_gethostbyname_r.m4 \
|
||||
$(top_srcdir)/m4/ax_getaddrinfo.m4 \
|
||||
$(top_srcdir)/m4/ax_log4cplus_wrappers.m4 \
|
||||
$(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/ax_pkg_swig.m4 \
|
||||
$(top_srcdir)/m4/ax_python_devel.m4 \
|
||||
$(top_srcdir)/m4/ax_swig_multi_module_support.m4 \
|
||||
$(top_srcdir)/m4/ax_cxx_compile_stdcxx_17.m4 \
|
||||
$(top_srcdir)/m4/ax_gcc_func_attribute.m4 \
|
||||
$(top_srcdir)/m4/ax_gcc_var_attribute.m4 \
|
||||
$(top_srcdir)/tests/configure.m4 $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(nobase_log4cplusinc_HEADERS)
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = $(top_builddir)/include/log4cplus/config.h \
|
||||
$(top_builddir)/include/log4cplus/config/defines.hxx
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
AM_V_P = $(am__v_P_@AM_V@)
|
||||
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
|
||||
am__v_P_0 = false
|
||||
am__v_P_1 = :
|
||||
AM_V_GEN = $(am__v_GEN_@AM_V@)
|
||||
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
|
||||
am__v_GEN_0 = @echo " GEN " $@;
|
||||
am__v_GEN_1 =
|
||||
AM_V_at = $(am__v_at_@AM_V@)
|
||||
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
|
||||
am__v_at_0 = @
|
||||
am__v_at_1 =
|
||||
SOURCES =
|
||||
am__can_run_installinfo = \
|
||||
case $$AM_UPDATE_INFO_DIR in \
|
||||
n|no|NO) false;; \
|
||||
*) (install-info --version) >/dev/null 2>&1;; \
|
||||
esac
|
||||
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
|
||||
am__vpath_adj = case $$p in \
|
||||
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
*) f=$$p;; \
|
||||
esac;
|
||||
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
|
||||
am__install_max = 40
|
||||
am__nobase_strip_setup = \
|
||||
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
|
||||
am__nobase_strip = \
|
||||
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
|
||||
am__nobase_list = $(am__nobase_strip_setup); \
|
||||
for p in $$list; do echo "$$p $$p"; done | \
|
||||
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
|
||||
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
|
||||
if (++n[$$2] == $(am__install_max)) \
|
||||
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
|
||||
END { for (dir in files) print dir, files[dir] }'
|
||||
am__base_list = \
|
||||
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
|
||||
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
|
||||
am__uninstall_files_from_dir = { \
|
||||
test -z "$$files" \
|
||||
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|
||||
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
|
||||
$(am__cd) "$$dir" && rm -f $$files; }; \
|
||||
}
|
||||
am__installdirs = "$(DESTDIR)$(log4cplusincdir)"
|
||||
HEADERS = $(nobase_log4cplusinc_HEADERS)
|
||||
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
|
||||
# Read a list of newline-separated strings from the standard input,
|
||||
# and print each of them once, without duplicates. Input order is
|
||||
# *not* preserved.
|
||||
am__uniquify_input = $(AWK) '\
|
||||
BEGIN { nonempty = 0; } \
|
||||
{ items[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in items) print i; }; } \
|
||||
'
|
||||
# Make sure the list of sources is unique. This is necessary because,
|
||||
# e.g., the same source file might be shared among _SOURCES variables
|
||||
# for different programs/libraries.
|
||||
am__define_uniq_tagged_files = \
|
||||
list='$(am__tagged_files)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | $(am__uniquify_input)`
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
|
||||
AR = @AR@
|
||||
AS = @AS@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOM4TE = @AUTOM4TE@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@
|
||||
AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@
|
||||
BUILD_WITH_WCHAR_T_SUPPORT = @BUILD_WITH_WCHAR_T_SUPPORT@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
DUMPBIN = @DUMPBIN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
ENABLE_THREADS = @ENABLE_THREADS@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
HAVE_CXX17 = @HAVE_CXX17@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LOG4CPLUS_AIX_XLC_LDFLAGS = @LOG4CPLUS_AIX_XLC_LDFLAGS@
|
||||
LOG4CPLUS_LTO_CXXFLAGS = @LOG4CPLUS_LTO_CXXFLAGS@
|
||||
LOG4CPLUS_LTO_LDFLAGS = @LOG4CPLUS_LTO_LDFLAGS@
|
||||
LOG4CPLUS_NDEBUG = @LOG4CPLUS_NDEBUG@
|
||||
LOG4CPLUS_PROFILING_CXXFLAGS = @LOG4CPLUS_PROFILING_CXXFLAGS@
|
||||
LOG4CPLUS_PROFILING_LDFLAGS = @LOG4CPLUS_PROFILING_LDFLAGS@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
LT_RELEASE = @LT_RELEASE@
|
||||
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
|
||||
LT_VERSION = @LT_VERSION@
|
||||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MANIFEST_TOOL = @MANIFEST_TOOL@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NM = @NM@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
OTOOL = @OTOOL@
|
||||
OTOOL64 = @OTOOL64@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_URL = @PACKAGE_URL@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
PKG_CONFIG = @PKG_CONFIG@
|
||||
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
|
||||
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
|
||||
PTHREAD_CXXFLAGS = @PTHREAD_CXXFLAGS@
|
||||
PTHREAD_LIBS = @PTHREAD_LIBS@
|
||||
PYTHON = @PYTHON@
|
||||
PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@
|
||||
PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
|
||||
PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@
|
||||
PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@
|
||||
PYTHON_LDFLAGS = @PYTHON_LDFLAGS@
|
||||
PYTHON_PLATFORM = @PYTHON_PLATFORM@
|
||||
PYTHON_PREFIX = @PYTHON_PREFIX@
|
||||
PYTHON_SITE_PKG = @PYTHON_SITE_PKG@
|
||||
PYTHON_VERSION = @PYTHON_VERSION@
|
||||
QT5_CFLAGS = @QT5_CFLAGS@
|
||||
QT5_LIBS = @QT5_LIBS@
|
||||
QT_CFLAGS = @QT_CFLAGS@
|
||||
QT_LIBS = @QT_LIBS@
|
||||
RANLIB = @RANLIB@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
SWIG = @SWIG@
|
||||
SWIG_FLAGS = @SWIG_FLAGS@
|
||||
SWIG_LIB = @SWIG_LIB@
|
||||
VERSION = @VERSION@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
ax_pthread_config = @ax_pthread_config@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
builddir = @builddir@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
pkgpyexecdir = @pkgpyexecdir@
|
||||
pkgpythondir = @pkgpythondir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
pyexecdir = @pyexecdir@
|
||||
pythondir = @pythondir@
|
||||
runstatedir = @runstatedir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target = @target@
|
||||
target_alias = @target_alias@
|
||||
target_cpu = @target_cpu@
|
||||
target_os = @target_os@
|
||||
target_vendor = @target_vendor@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
log4cplusincdir = $(includedir)
|
||||
nobase_log4cplusinc_HEADERS = \
|
||||
log4cplus/appender.h \
|
||||
log4cplus/asyncappender.h \
|
||||
log4cplus/boost/deviceappender.hxx \
|
||||
log4cplus/callbackappender.h \
|
||||
log4cplus/clfsappender.h \
|
||||
log4cplus/clogger.h \
|
||||
log4cplus/config.hxx \
|
||||
log4cplus/config/defines.hxx \
|
||||
log4cplus/config/macosx.h \
|
||||
log4cplus/config/win32.h \
|
||||
log4cplus/config/windowsh-inc-full.h \
|
||||
log4cplus/config/windowsh-inc.h \
|
||||
log4cplus/configurator.h \
|
||||
log4cplus/consoleappender.h \
|
||||
log4cplus/fileappender.h \
|
||||
log4cplus/fstreams.h \
|
||||
log4cplus/helpers/appenderattachableimpl.h \
|
||||
log4cplus/helpers/connectorthread.h \
|
||||
log4cplus/helpers/fileinfo.h \
|
||||
log4cplus/helpers/lockfile.h \
|
||||
log4cplus/helpers/loglog.h \
|
||||
log4cplus/helpers/pointer.h \
|
||||
log4cplus/helpers/property.h \
|
||||
log4cplus/helpers/queue.h \
|
||||
log4cplus/helpers/snprintf.h \
|
||||
log4cplus/helpers/socket.h \
|
||||
log4cplus/helpers/socketbuffer.h \
|
||||
log4cplus/helpers/stringhelper.h \
|
||||
log4cplus/helpers/thread-config.h \
|
||||
log4cplus/helpers/timehelper.h \
|
||||
log4cplus/hierarchy.h \
|
||||
log4cplus/hierarchylocker.h \
|
||||
log4cplus/initializer.h \
|
||||
log4cplus/internal/customloglevelmanager.h \
|
||||
log4cplus/internal/cygwin-win32.h \
|
||||
log4cplus/internal/env.h \
|
||||
log4cplus/internal/internal.h \
|
||||
log4cplus/internal/socket.h \
|
||||
log4cplus/layout.h \
|
||||
log4cplus/log4cplus.h \
|
||||
log4cplus/log4judpappender.h \
|
||||
log4cplus/logger.h \
|
||||
log4cplus/loggingmacros.h \
|
||||
log4cplus/loglevel.h \
|
||||
log4cplus/mdc.h \
|
||||
log4cplus/msttsappender.h \
|
||||
log4cplus/ndc.h \
|
||||
log4cplus/nteventlogappender.h \
|
||||
log4cplus/nullappender.h \
|
||||
log4cplus/qt4debugappender.h \
|
||||
log4cplus/qt5debugappender.h \
|
||||
log4cplus/socketappender.h \
|
||||
log4cplus/spi/appenderattachable.h \
|
||||
log4cplus/spi/factory.h \
|
||||
log4cplus/spi/filter.h \
|
||||
log4cplus/spi/loggerfactory.h \
|
||||
log4cplus/spi/loggerimpl.h \
|
||||
log4cplus/spi/loggingevent.h \
|
||||
log4cplus/spi/objectregistry.h \
|
||||
log4cplus/spi/rootlogger.h \
|
||||
log4cplus/streams.h \
|
||||
log4cplus/syslogappender.h \
|
||||
log4cplus/tchar.h \
|
||||
log4cplus/thread/impl/syncprims-cxx11.h \
|
||||
log4cplus/thread/impl/syncprims-impl.h \
|
||||
log4cplus/thread/impl/syncprims-pmsm.h \
|
||||
log4cplus/thread/impl/threads-impl.h \
|
||||
log4cplus/thread/impl/tls.h \
|
||||
log4cplus/thread/syncprims-pub-impl.h \
|
||||
log4cplus/thread/syncprims.h \
|
||||
log4cplus/thread/threads.h \
|
||||
log4cplus/tracelogger.h \
|
||||
log4cplus/tstring.h \
|
||||
log4cplus/version.h \
|
||||
log4cplus/win32consoleappender.h \
|
||||
log4cplus/win32debugappender.h
|
||||
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
|
||||
&& { if test -f $@; then exit 0; else break; fi; }; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign include/Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
|
||||
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(am__aclocal_m4_deps):
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
install-nobase_log4cplusincHEADERS: $(nobase_log4cplusinc_HEADERS)
|
||||
@$(NORMAL_INSTALL)
|
||||
@list='$(nobase_log4cplusinc_HEADERS)'; test -n "$(log4cplusincdir)" || list=; \
|
||||
if test -n "$$list"; then \
|
||||
echo " $(MKDIR_P) '$(DESTDIR)$(log4cplusincdir)'"; \
|
||||
$(MKDIR_P) "$(DESTDIR)$(log4cplusincdir)" || exit 1; \
|
||||
fi; \
|
||||
$(am__nobase_list) | while read dir files; do \
|
||||
xfiles=; for file in $$files; do \
|
||||
if test -f "$$file"; then xfiles="$$xfiles $$file"; \
|
||||
else xfiles="$$xfiles $(srcdir)/$$file"; fi; done; \
|
||||
test -z "$$xfiles" || { \
|
||||
test "x$$dir" = x. || { \
|
||||
echo " $(MKDIR_P) '$(DESTDIR)$(log4cplusincdir)/$$dir'"; \
|
||||
$(MKDIR_P) "$(DESTDIR)$(log4cplusincdir)/$$dir"; }; \
|
||||
echo " $(INSTALL_HEADER) $$xfiles '$(DESTDIR)$(log4cplusincdir)/$$dir'"; \
|
||||
$(INSTALL_HEADER) $$xfiles "$(DESTDIR)$(log4cplusincdir)/$$dir" || exit $$?; }; \
|
||||
done
|
||||
|
||||
uninstall-nobase_log4cplusincHEADERS:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(nobase_log4cplusinc_HEADERS)'; test -n "$(log4cplusincdir)" || list=; \
|
||||
$(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \
|
||||
dir='$(DESTDIR)$(log4cplusincdir)'; $(am__uninstall_files_from_dir)
|
||||
|
||||
ID: $(am__tagged_files)
|
||||
$(am__define_uniq_tagged_files); mkid -fID $$unique
|
||||
tags: tags-am
|
||||
TAGS: tags
|
||||
|
||||
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
|
||||
set x; \
|
||||
here=`pwd`; \
|
||||
$(am__define_uniq_tagged_files); \
|
||||
shift; \
|
||||
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
if test $$# -gt 0; then \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
"$$@" $$unique; \
|
||||
else \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$unique; \
|
||||
fi; \
|
||||
fi
|
||||
ctags: ctags-am
|
||||
|
||||
CTAGS: ctags
|
||||
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
|
||||
$(am__define_uniq_tagged_files); \
|
||||
test -z "$(CTAGS_ARGS)$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& $(am__cd) $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) "$$here"
|
||||
cscopelist: cscopelist-am
|
||||
|
||||
cscopelist-am: $(am__tagged_files)
|
||||
list='$(am__tagged_files)'; \
|
||||
case "$(srcdir)" in \
|
||||
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
|
||||
*) sdir=$(subdir)/$(srcdir) ;; \
|
||||
esac; \
|
||||
for i in $$list; do \
|
||||
if test -f "$$i"; then \
|
||||
echo "$(subdir)/$$i"; \
|
||||
else \
|
||||
echo "$$sdir/$$i"; \
|
||||
fi; \
|
||||
done >> $(top_builddir)/cscope.files
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
all-am: Makefile $(HEADERS)
|
||||
installdirs:
|
||||
for dir in "$(DESTDIR)$(log4cplusincdir)"; do \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
done
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-am
|
||||
install-strip:
|
||||
if test -z '$(STRIP)'; then \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
install; \
|
||||
else \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
|
||||
fi
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic clean-libtool mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-generic distclean-tags
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-am
|
||||
|
||||
html-am:
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am: install-nobase_log4cplusincHEADERS
|
||||
|
||||
install-dvi: install-dvi-am
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am:
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
install-html-am:
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-info-am:
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-am
|
||||
|
||||
install-pdf-am:
|
||||
|
||||
install-ps: install-ps-am
|
||||
|
||||
install-ps-am:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-nobase_log4cplusincHEADERS
|
||||
|
||||
.MAKE: install-am install-strip
|
||||
|
||||
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
|
||||
clean-libtool cscopelist-am ctags ctags-am distclean \
|
||||
distclean-generic distclean-libtool distclean-tags dvi dvi-am \
|
||||
html html-am info info-am install install-am install-data \
|
||||
install-data-am install-dvi install-dvi-am install-exec \
|
||||
install-exec-am install-html install-html-am install-info \
|
||||
install-info-am install-man install-nobase_log4cplusincHEADERS \
|
||||
install-pdf install-pdf-am install-ps install-ps-am \
|
||||
install-strip installcheck installcheck-am installdirs \
|
||||
maintainer-clean maintainer-clean-generic mostlyclean \
|
||||
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
|
||||
tags tags-am uninstall uninstall-am \
|
||||
uninstall-nobase_log4cplusincHEADERS
|
||||
|
||||
.PRECIOUS: Makefile
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
|
@ -0,0 +1,340 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: appender.h
|
||||
// Created: 6/2001
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2001-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_APPENDER_HEADER_
|
||||
#define LOG4CPLUS_APPENDER_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/layout.h>
|
||||
#include <log4cplus/loglevel.h>
|
||||
#include <log4cplus/tstring.h>
|
||||
#include <log4cplus/helpers/pointer.h>
|
||||
#include <log4cplus/spi/filter.h>
|
||||
#include <log4cplus/helpers/lockfile.h>
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
|
||||
|
||||
namespace log4cplus {
|
||||
|
||||
|
||||
namespace helpers
|
||||
{
|
||||
|
||||
class Properties;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This class is used to "handle" errors encountered in an {@link
|
||||
* log4cplus::Appender}.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT ErrorHandler
|
||||
{
|
||||
public:
|
||||
ErrorHandler ();
|
||||
virtual ~ErrorHandler() = 0;
|
||||
virtual void error(const log4cplus::tstring& err) = 0;
|
||||
virtual void reset() = 0;
|
||||
};
|
||||
|
||||
|
||||
class LOG4CPLUS_EXPORT OnlyOnceErrorHandler
|
||||
: public ErrorHandler
|
||||
{
|
||||
public:
|
||||
// Ctor
|
||||
OnlyOnceErrorHandler();
|
||||
virtual ~OnlyOnceErrorHandler ();
|
||||
virtual void error(const log4cplus::tstring& err);
|
||||
virtual void reset();
|
||||
|
||||
private:
|
||||
bool firstTime;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Extend this class for implementing your own strategies for printing log
|
||||
* statements.
|
||||
*
|
||||
* <h3>Properties</h3>
|
||||
* <dl>
|
||||
*
|
||||
* <dt><tt>layout</tt></dt>
|
||||
* <dd>This property specifies message layout used by
|
||||
* Appender.
|
||||
* \sa Layout
|
||||
* </dd>
|
||||
*
|
||||
* <dt><tt>filters</tt></dt>
|
||||
* <dd>This property specifies possibly multiple filters used by
|
||||
* Appender. Each of multple filters and its properties is under a
|
||||
* numbered subkey of filters key. E.g.:
|
||||
* <tt>filters.<em>1</em>=log4cplus::spi::LogLevelMatchFilter</tt>. Filter
|
||||
* subkey numbers must be consecutive.</dd>
|
||||
*
|
||||
* <dt><tt>Threshold</tt></dt>
|
||||
* <dd>This property specifies log level threshold. Events with
|
||||
* lower log level than the threshold will not be logged by
|
||||
* appender.</dd>
|
||||
*
|
||||
* <dt><tt>UseLockFile</tt></dt>
|
||||
* <dd>Set this property to <tt>true</tt> if you want your output
|
||||
* through this appender to be synchronized between multiple
|
||||
* processes. When this property is set to true then log4cplus
|
||||
* uses OS specific facilities (e.g., <code>lockf()</code>) to
|
||||
* provide inter-process locking. With the exception of
|
||||
* FileAppender and its derived classes, it is also necessary to
|
||||
* provide path to a lock file using the <tt>LockFile</tt>
|
||||
* property.
|
||||
* \sa FileAppender
|
||||
* </dd>
|
||||
*
|
||||
* <dt><tt>LockFile</tt></dt>
|
||||
* <dd>This property specifies lock file, file used for
|
||||
* inter-process synchronization of log file access. The property
|
||||
* is only used when <tt>UseLockFile</tt> is set to true. Then it
|
||||
* is mandatory.
|
||||
* \sa FileAppender
|
||||
* </dd>
|
||||
*
|
||||
* <dt><tt>AsyncAppend</tt></dt>
|
||||
* <dd>Set this property to <tt>true</tt> if you want all appends using
|
||||
* this appender to be done asynchronously. Default is <tt>false</tt>.</dd>
|
||||
*
|
||||
* </dl>
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT Appender
|
||||
: public virtual log4cplus::helpers::SharedObject
|
||||
{
|
||||
public:
|
||||
// Ctor
|
||||
Appender();
|
||||
Appender(const log4cplus::helpers::Properties & properties);
|
||||
|
||||
// Dtor
|
||||
virtual ~Appender();
|
||||
|
||||
/**
|
||||
* This function is for derived appenders to call from their
|
||||
* destructors. All classes derived from `Appender` class
|
||||
* _must_ call this function from their destructors. It
|
||||
* ensures that appenders will get properly closed during
|
||||
* shutdown by call to `close()` function before they are
|
||||
* destroyed.
|
||||
*/
|
||||
void destructorImpl();
|
||||
|
||||
// Methods
|
||||
/**
|
||||
* Release any resources allocated within the appender such as file
|
||||
* handles, network connections, etc.
|
||||
*
|
||||
* It is a programming error to append to a closed appender.
|
||||
*/
|
||||
virtual void close() = 0;
|
||||
|
||||
/**
|
||||
* Check if this appender is in closed state.
|
||||
*/
|
||||
bool isClosed() const;
|
||||
|
||||
/**
|
||||
* This method performs threshold checks and invokes filters before
|
||||
* delegating actual logging to the subclasses specific {@link
|
||||
* #append} method.
|
||||
*/
|
||||
void syncDoAppend(const log4cplus::spi::InternalLoggingEvent& event);
|
||||
|
||||
/**
|
||||
* This method performs book keeping related to asynchronous logging
|
||||
* and executes `syncDoAppend()` to do the actual logging.
|
||||
*/
|
||||
|
||||
void asyncDoAppend(const log4cplus::spi::InternalLoggingEvent& event);
|
||||
|
||||
/**
|
||||
* This function checks `async` flag. It either executes
|
||||
* `syncDoAppend()` directly or enqueues its execution to thread pool
|
||||
* thread.
|
||||
*/
|
||||
void doAppend(const log4cplus::spi::InternalLoggingEvent& event);
|
||||
|
||||
/**
|
||||
* Get the name of this appender. The name uniquely identifies the
|
||||
* appender.
|
||||
*/
|
||||
virtual log4cplus::tstring getName();
|
||||
|
||||
/**
|
||||
* Set the name of this appender. The name is used by other
|
||||
* components to identify this appender.
|
||||
*/
|
||||
virtual void setName(const log4cplus::tstring& name);
|
||||
|
||||
/**
|
||||
* Set the {@link ErrorHandler} for this Appender.
|
||||
*/
|
||||
virtual void setErrorHandler(std::unique_ptr<ErrorHandler> eh);
|
||||
|
||||
/**
|
||||
* Return the currently set {@link ErrorHandler} for this
|
||||
* Appender.
|
||||
*/
|
||||
virtual ErrorHandler* getErrorHandler();
|
||||
|
||||
/**
|
||||
* Set the layout for this appender. Note that some appenders have
|
||||
* their own (fixed) layouts or do not use one. For example, the
|
||||
* SocketAppender ignores the layout set here.
|
||||
*/
|
||||
virtual void setLayout(std::unique_ptr<Layout> layout);
|
||||
|
||||
/**
|
||||
* Returns the layout of this appender. The value may be NULL.
|
||||
*
|
||||
* This class owns the returned pointer.
|
||||
*/
|
||||
virtual Layout* getLayout();
|
||||
|
||||
/**
|
||||
* Set the filter chain on this Appender.
|
||||
*/
|
||||
void setFilter(log4cplus::spi::FilterPtr f);
|
||||
|
||||
/**
|
||||
* Get the filter chain on this Appender.
|
||||
*/
|
||||
log4cplus::spi::FilterPtr getFilter() const;
|
||||
|
||||
/**
|
||||
* Add filter at the end of the filters chain.
|
||||
*/
|
||||
void addFilter (log4cplus::spi::FilterPtr f);
|
||||
|
||||
/**
|
||||
* Add filter at the end of the filters chain.
|
||||
*/
|
||||
void addFilter (std::function<
|
||||
spi::FilterResult (const log4cplus::spi::InternalLoggingEvent &)>);
|
||||
|
||||
/**
|
||||
* Returns this appenders threshold LogLevel. See the {@link
|
||||
* #setThreshold} method for the meaning of this option.
|
||||
*/
|
||||
LogLevel getThreshold() const { return threshold; }
|
||||
|
||||
/**
|
||||
* Set the threshold LogLevel. All log events with lower LogLevel
|
||||
* than the threshold LogLevel are ignored by the appender.
|
||||
*
|
||||
* In configuration files this option is specified by setting the
|
||||
* value of the <b>Threshold</b> option to a LogLevel
|
||||
* string, such as "DEBUG", "INFO" and so on.
|
||||
*/
|
||||
void setThreshold(LogLevel th) { threshold = th; }
|
||||
|
||||
/**
|
||||
* Check whether the message LogLevel is below the appender's
|
||||
* threshold. If there is no threshold set, then the return value is
|
||||
* always <code>true</code>.
|
||||
*/
|
||||
bool isAsSevereAsThreshold(LogLevel ll) const {
|
||||
return ((ll != NOT_SET_LOG_LEVEL) && (ll >= threshold));
|
||||
}
|
||||
|
||||
/**
|
||||
* This method waits for all events that are being asynchronously
|
||||
* logged to finish.
|
||||
*/
|
||||
void waitToFinishAsyncLogging();
|
||||
|
||||
protected:
|
||||
// Methods
|
||||
/**
|
||||
* Subclasses of <code>Appender</code> should implement this
|
||||
* method to perform actual logging.
|
||||
* @see doAppend method.
|
||||
*/
|
||||
virtual void append(const log4cplus::spi::InternalLoggingEvent& event) = 0;
|
||||
|
||||
tstring & formatEvent (const log4cplus::spi::InternalLoggingEvent& event) const;
|
||||
|
||||
// Data
|
||||
/** The layout variable does not need to be set if the appender
|
||||
* implementation has its own layout. */
|
||||
std::unique_ptr<Layout> layout;
|
||||
|
||||
/** Appenders are named. */
|
||||
log4cplus::tstring name;
|
||||
|
||||
/** There is no LogLevel threshold filtering by default. */
|
||||
LogLevel threshold;
|
||||
|
||||
/** The first filter in the filter chain. Set to <code>null</code>
|
||||
* initially. */
|
||||
log4cplus::spi::FilterPtr filter;
|
||||
|
||||
/** It is assumed and enforced that errorHandler is never null. */
|
||||
std::unique_ptr<ErrorHandler> errorHandler;
|
||||
|
||||
//! Optional system wide synchronization lock.
|
||||
std::unique_ptr<helpers::LockFile> lockFile;
|
||||
|
||||
//! Use lock file for inter-process synchronization of access
|
||||
//! to log file.
|
||||
bool useLockFile;
|
||||
|
||||
//! Asynchronous append.
|
||||
bool async;
|
||||
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
std::atomic<std::size_t> in_flight;
|
||||
std::mutex in_flight_mutex;
|
||||
std::condition_variable in_flight_condition;
|
||||
#endif
|
||||
|
||||
/** Is this appender closed? */
|
||||
bool closed;
|
||||
|
||||
private:
|
||||
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
void subtract_in_flight();
|
||||
#endif
|
||||
};
|
||||
|
||||
/** This is a pointer to an Appender. */
|
||||
typedef helpers::SharedObjectPtr<Appender> SharedAppenderPtr;
|
||||
|
||||
} // end namespace log4cplus
|
||||
|
||||
#endif // LOG4CPLUS_APPENDER_HEADER_
|
|
@ -0,0 +1,97 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4cplus
|
||||
// File: asyncappender.h
|
||||
// Created: 1/2009
|
||||
// Author: Vaclav Haisman
|
||||
//
|
||||
//
|
||||
// Copyright (C) 2009-2017, Vaclav Haisman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
//
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_ASYNCAPPENDER_H
|
||||
#define LOG4CPLUS_ASYNCAPPENDER_H
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#ifndef LOG4CPLUS_SINGLE_THREADED
|
||||
|
||||
#include <log4cplus/helpers/queue.h>
|
||||
#include <log4cplus/appender.h>
|
||||
#include <log4cplus/thread/threads.h>
|
||||
#include <log4cplus/helpers/appenderattachableimpl.h>
|
||||
|
||||
|
||||
namespace log4cplus
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
This `Appender` is a wrapper to which other appenders can be attached. The
|
||||
attached appendres are then appended to from a separate thread which reads
|
||||
events appended to this appender from a queue.
|
||||
|
||||
\sa helpers::AppenderAttachableImpl
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT AsyncAppender
|
||||
: public Appender
|
||||
, public helpers::AppenderAttachableImpl
|
||||
{
|
||||
public:
|
||||
AsyncAppender (SharedAppenderPtr const & app, unsigned max_len);
|
||||
AsyncAppender (helpers::Properties const &);
|
||||
virtual ~AsyncAppender ();
|
||||
|
||||
virtual void close ();
|
||||
|
||||
protected:
|
||||
virtual void append (spi::InternalLoggingEvent const &);
|
||||
|
||||
void init_queue_thread (unsigned);
|
||||
|
||||
thread::AbstractThreadPtr queue_thread;
|
||||
thread::QueuePtr queue;
|
||||
|
||||
private:
|
||||
AsyncAppender (AsyncAppender const &);
|
||||
AsyncAppender & operator = (AsyncAppender const &);
|
||||
};
|
||||
|
||||
|
||||
typedef helpers::SharedObjectPtr<AsyncAppender> AsyncAppenderPtr;
|
||||
|
||||
|
||||
} // namespace log4cplus
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_SINGLE_THREADED
|
||||
|
||||
#endif // LOG4CPLUS_ASYNCAPPENDER_H
|
|
@ -0,0 +1,201 @@
|
|||
// Copyright (C) 2009-2017, Vaclav Haisman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef LOG4CPLUS_BOOST_DEVICEAPPENDER_HXX
|
||||
#define LOG4CPLUS_BOOST_DEVICEAPPENDER_HXX
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
#include <boost/iostreams/operations.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <log4cplus/appender.h>
|
||||
|
||||
|
||||
namespace log4cplus
|
||||
{
|
||||
|
||||
|
||||
namespace device_appender_detail
|
||||
{
|
||||
|
||||
|
||||
template <typename T>
|
||||
struct device_type_traits
|
||||
{
|
||||
typedef T & device_type;
|
||||
|
||||
static
|
||||
device_type
|
||||
unwrap (device_type x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
struct device_type_traits<boost::shared_ptr<T> >
|
||||
{
|
||||
typedef boost::shared_ptr<T> device_type;
|
||||
|
||||
static
|
||||
T &
|
||||
unwrap (device_type const & ptr)
|
||||
{
|
||||
return *ptr;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace device_appender_detail
|
||||
|
||||
|
||||
template <typename Device>
|
||||
class DeviceAppender
|
||||
: public Appender
|
||||
{
|
||||
public:
|
||||
typedef device_appender_detail::device_type_traits<Device> device_traits;
|
||||
typedef typename device_traits::device_type device_type;
|
||||
|
||||
template <typename D>
|
||||
DeviceAppender (D & d, bool close_device = true)
|
||||
: device (d)
|
||||
, close_flag (close_device)
|
||||
{ }
|
||||
|
||||
template <typename D>
|
||||
DeviceAppender (boost::shared_ptr<D> const & d, bool close_device = true)
|
||||
: device (d)
|
||||
, close_flag (close_device)
|
||||
{ }
|
||||
|
||||
template <typename D>
|
||||
DeviceAppender (D & d, const helpers::Properties & props)
|
||||
: Appender (props)
|
||||
, device (d)
|
||||
{
|
||||
if (props.exists (LOG4CPLUS_TEXT ("CloseDevice")))
|
||||
close_flag = true;
|
||||
else
|
||||
close_flag = false;
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
DeviceAppender (boost::shared_ptr<D> const & d,
|
||||
const helpers::Properties & props)
|
||||
: Appender (props)
|
||||
, device (d)
|
||||
{
|
||||
if (props.exists (LOG4CPLUS_TEXT ("CloseDevice")))
|
||||
close_flag = true;
|
||||
else
|
||||
close_flag = false;
|
||||
}
|
||||
|
||||
virtual
|
||||
~DeviceAppender ()
|
||||
{ }
|
||||
|
||||
virtual
|
||||
void
|
||||
close ()
|
||||
{
|
||||
if (close_flag)
|
||||
boost::iostreams::close (device_traits::unwrap (device));
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual
|
||||
void
|
||||
append (log4cplus::spi::InternalLoggingEvent const & event)
|
||||
{
|
||||
tstring & str = formatEvent (event);
|
||||
boost::iostreams::write (device_traits::unwrap (device),
|
||||
str.c_str (), str.size ());
|
||||
}
|
||||
|
||||
device_type device;
|
||||
bool close_flag;
|
||||
|
||||
private:
|
||||
DeviceAppender (DeviceAppender const &);
|
||||
DeviceAppender & operator = (DeviceAppender const &);
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline
|
||||
SharedAppenderPtr
|
||||
make_device_appender (T & d, bool close_device = true)
|
||||
{
|
||||
SharedAppenderPtr app (new DeviceAppender<T> (d, close_device));
|
||||
return app;
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline
|
||||
SharedAppenderPtr
|
||||
make_device_appender (T & d, const helpers::Properties & props)
|
||||
{
|
||||
SharedAppenderPtr app (new DeviceAppender<T> (d, props));
|
||||
return app;
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline
|
||||
SharedAppenderPtr
|
||||
make_device_appender_sp (boost::shared_ptr<T> const & p,
|
||||
bool close_device = true)
|
||||
{
|
||||
SharedAppenderPtr app (
|
||||
new DeviceAppender<boost::shared_ptr<T> > (p, close_device));
|
||||
return app;
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline
|
||||
SharedAppenderPtr
|
||||
make_device_appender_sp (boost::shared_ptr<T> const & p,
|
||||
const helpers::Properties & props)
|
||||
{
|
||||
SharedAppenderPtr app (
|
||||
new DeviceAppender<boost::shared_ptr<T> > (p, props));
|
||||
return app;
|
||||
}
|
||||
|
||||
|
||||
} // namespace log4cplus
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_BOOST_DEVICEAPPENDER_HXX
|
|
@ -0,0 +1,73 @@
|
|||
// -*- C++ -*-
|
||||
// Copyright (C) 2015-2017, Vaclav Haisman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_CALLBACK_APPENDER_HEADER_
|
||||
#define LOG4CPLUS_CALLBACK_APPENDER_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/appender.h>
|
||||
#include <log4cplus/clogger.h>
|
||||
|
||||
|
||||
namespace log4cplus {
|
||||
|
||||
/**
|
||||
* Send log events to a C function callback.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT CallbackAppender
|
||||
: public Appender {
|
||||
public:
|
||||
CallbackAppender();
|
||||
CallbackAppender(log4cplus_log_event_callback_t callback, void * cookie);
|
||||
CallbackAppender(const log4cplus::helpers::Properties&);
|
||||
|
||||
virtual ~CallbackAppender();
|
||||
virtual void close();
|
||||
|
||||
void setCookie(void *);
|
||||
void setCallback(log4cplus_log_event_callback_t);
|
||||
|
||||
protected:
|
||||
virtual void append(const log4cplus::spi::InternalLoggingEvent& event);
|
||||
|
||||
private:
|
||||
log4cplus_log_event_callback_t callback;
|
||||
void * cookie;
|
||||
|
||||
// Disallow copying of instances of this class
|
||||
CallbackAppender(const CallbackAppender&) = delete;
|
||||
CallbackAppender& operator=(const CallbackAppender&) = delete;
|
||||
};
|
||||
|
||||
} // end namespace log4cplus
|
||||
|
||||
#endif // LOG4CPLUS_CALLBACK_APPENDER_HEADER_
|
|
@ -0,0 +1,98 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4cplus
|
||||
// File: clfsappender.h
|
||||
// Created: 5/2012
|
||||
// Author: Vaclav Zeman
|
||||
//
|
||||
//
|
||||
// Copyright (C) 2012-2017, Vaclav Zeman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
//
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_CLFSAPPENDER_H
|
||||
#define LOG4CPLUS_CLFSAPPENDER_H
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/appender.h>
|
||||
|
||||
|
||||
#if defined (LOG4CPLUS_CLFSAPPENDER_BUILD_DLL)
|
||||
# if defined (INSIDE_LOG4CPLUS_CLFSAPPENDER)
|
||||
# define LOG4CPLUS_CLFSAPPENDER_EXPORT __declspec(dllexport)
|
||||
# else
|
||||
# define LOG4CPLUS_CLFSAPPENDER_EXPORT __declspec(dllimport)
|
||||
# endif
|
||||
#else
|
||||
# define LOG4CPLUS_CLFSAPPENDER_EXPORT
|
||||
#endif
|
||||
|
||||
|
||||
namespace log4cplus
|
||||
{
|
||||
|
||||
|
||||
class LOG4CPLUS_CLFSAPPENDER_EXPORT CLFSAppender
|
||||
: public Appender
|
||||
{
|
||||
public:
|
||||
CLFSAppender (tstring const & logname, unsigned long logsize,
|
||||
unsigned long buffersize);
|
||||
explicit CLFSAppender (helpers::Properties const &);
|
||||
virtual ~CLFSAppender ();
|
||||
|
||||
virtual void close ();
|
||||
|
||||
static void registerAppender ();
|
||||
|
||||
protected:
|
||||
virtual void append (spi::InternalLoggingEvent const &);
|
||||
|
||||
void init (tstring const & logname, unsigned long logsize,
|
||||
unsigned long buffersize);
|
||||
|
||||
struct Data;
|
||||
|
||||
Data * data;
|
||||
|
||||
private:
|
||||
CLFSAppender (CLFSAppender const &);
|
||||
CLFSAppender & operator = (CLFSAppender const &);
|
||||
};
|
||||
|
||||
|
||||
typedef helpers::SharedObjectPtr<CLFSAppender> CLFSAppenderPtr;
|
||||
|
||||
|
||||
} // namespace log4cplus
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_CLFSAPPENDER_H
|
|
@ -0,0 +1,126 @@
|
|||
// -*- C -*-
|
||||
/**
|
||||
* Module: Log4CPLUS
|
||||
* File: clogger.h
|
||||
* Created: 01/2011
|
||||
* Author: Jens Rehsack
|
||||
*
|
||||
*
|
||||
* Copyright 2011-2017 Jens Rehsack & Tad E. Smith
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** @file
|
||||
* This header defines the C API for log4cplus and the logging macros. */
|
||||
|
||||
#ifndef LOG4CPLUS_CLOGGERHEADER_
|
||||
#define LOG4CPLUS_CLOGGERHEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
// TODO UNICDE capable
|
||||
|
||||
typedef void * log4cplus_logger_t;
|
||||
typedef log4cplus_logger_t logger_t;
|
||||
|
||||
typedef int log4cplus_loglevel_t;
|
||||
typedef log4cplus_loglevel_t loglevel_t;
|
||||
|
||||
#define L4CP_OFF_LOG_LEVEL 60000
|
||||
#define L4CP_FATAL_LOG_LEVEL 50000
|
||||
#define L4CP_ERROR_LOG_LEVEL 40000
|
||||
#define L4CP_WARN_LOG_LEVEL 30000
|
||||
#define L4CP_INFO_LOG_LEVEL 20000
|
||||
#define L4CP_DEBUG_LOG_LEVEL 10000
|
||||
#define L4CP_TRACE_LOG_LEVEL 0
|
||||
#define L4CP_ALL_LOG_LEVEL TRACE_LOG_LEVEL
|
||||
#define L4CP_NOT_SET_LOG_LEVEL -1
|
||||
|
||||
#ifdef UNICODE
|
||||
typedef wchar_t log4cplus_char_t;
|
||||
#else
|
||||
typedef char log4cplus_char_t;
|
||||
#endif // UNICODE
|
||||
|
||||
#if ! defined (LOG4CPLUS_TEXT)
|
||||
#ifdef UNICODE
|
||||
# define LOG4CPLUS_TEXT2(STRING) L##STRING
|
||||
#else
|
||||
# define LOG4CPLUS_TEXT2(STRING) STRING
|
||||
#endif // UNICODE
|
||||
#define LOG4CPLUS_TEXT(STRING) LOG4CPLUS_TEXT2(STRING)
|
||||
#endif // LOG4CPLUS_TEXT
|
||||
|
||||
LOG4CPLUS_EXPORT void * log4cplus_initialize(void);
|
||||
LOG4CPLUS_EXPORT int log4cplus_deinitialize(void * initializer);
|
||||
|
||||
LOG4CPLUS_EXPORT int log4cplus_file_configure(const log4cplus_char_t *pathname);
|
||||
LOG4CPLUS_EXPORT int log4cplus_file_reconfigure(const log4cplus_char_t *pathname);
|
||||
LOG4CPLUS_EXPORT int log4cplus_str_configure(const log4cplus_char_t *config);
|
||||
LOG4CPLUS_EXPORT int log4cplus_str_reconfigure(const log4cplus_char_t *config);
|
||||
LOG4CPLUS_EXPORT int log4cplus_basic_configure(void);
|
||||
LOG4CPLUS_EXPORT int log4cplus_basic_reconfigure(int logToStdErr);
|
||||
LOG4CPLUS_EXPORT void log4cplus_shutdown(void);
|
||||
|
||||
LOG4CPLUS_EXPORT int log4cplus_logger_exists(const log4cplus_char_t *name);
|
||||
LOG4CPLUS_EXPORT int log4cplus_logger_is_enabled_for(
|
||||
const log4cplus_char_t *name, log4cplus_loglevel_t ll);
|
||||
|
||||
LOG4CPLUS_EXPORT int log4cplus_logger_log(const log4cplus_char_t *name,
|
||||
log4cplus_loglevel_t ll, const log4cplus_char_t *msgfmt, ...)
|
||||
LOG4CPLUS_FORMAT_ATTRIBUTE (__printf__, 3, 4);
|
||||
|
||||
LOG4CPLUS_EXPORT int log4cplus_logger_log_str(const log4cplus_char_t *name,
|
||||
log4cplus_loglevel_t ll, const log4cplus_char_t *msg);
|
||||
|
||||
LOG4CPLUS_EXPORT int log4cplus_logger_force_log(const log4cplus_char_t *name,
|
||||
log4cplus_loglevel_t ll, const log4cplus_char_t *msgfmt, ...)
|
||||
LOG4CPLUS_FORMAT_ATTRIBUTE (__printf__, 3, 4);
|
||||
|
||||
LOG4CPLUS_EXPORT int log4cplus_logger_force_log_str(const log4cplus_char_t *name,
|
||||
log4cplus_loglevel_t ll, const log4cplus_char_t *msg);
|
||||
|
||||
//! CallbackAppender callback type.
|
||||
typedef void (* log4cplus_log_event_callback_t)(void * cookie,
|
||||
log4cplus_char_t const * message, log4cplus_char_t const * loggerName,
|
||||
log4cplus_loglevel_t ll, log4cplus_char_t const * thread,
|
||||
log4cplus_char_t const * thread2,
|
||||
unsigned long long timestamp_secs, unsigned long timestamp_usecs,
|
||||
log4cplus_char_t const * file, log4cplus_char_t const * function, int line);
|
||||
|
||||
LOG4CPLUS_EXPORT int log4cplus_add_callback_appender(
|
||||
const log4cplus_char_t * logger, log4cplus_log_event_callback_t callback,
|
||||
void * cookie);
|
||||
|
||||
// Custom LogLevel
|
||||
LOG4CPLUS_EXPORT int log4cplus_add_log_level(unsigned int ll,
|
||||
const log4cplus_char_t *ll_name);
|
||||
LOG4CPLUS_EXPORT int log4cplus_remove_log_level(unsigned int ll,
|
||||
const log4cplus_char_t *ll_name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*?LOG4CPLUS_CLOGGERHEADER_*/
|
|
@ -0,0 +1,335 @@
|
|||
/* include/log4cplus/config.h.in. Generated from configure.in by autoheader. */
|
||||
|
||||
#ifndef LOG4CPLUS_CONFIG_H
|
||||
|
||||
#define LOG4CPLUS_CONFIG_H
|
||||
|
||||
/* Defined if the compiler supports C99 style variadic macros with
|
||||
__VA_ARGS__. */
|
||||
/* #undef HAS_C99_VARIADIC_MACROS */
|
||||
|
||||
/* Defined if the compiler supports GNU style variadic macros. */
|
||||
/* #undef HAS_GNU_VARIADIC_MACROS */
|
||||
|
||||
/* Define to 1 if you have the `clock_gettime' function. */
|
||||
#undef HAVE_CLOCK_GETTIME
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#cmakedefine HAVE_DLFCN_H 1
|
||||
|
||||
/* Define to 1 if you have the `ftime' function. */
|
||||
#cmakedefine HAVE_FTIME 1
|
||||
|
||||
/* */
|
||||
#cmakedefine HAVE_GETADDRINFO 1
|
||||
|
||||
/* */
|
||||
#cmakedefine HAVE_GETHOSTBYNAME_R 1
|
||||
|
||||
/* Define to 1 if you have the `getpid' function. */
|
||||
#cmakedefine HAVE_GETPID 1
|
||||
|
||||
/* Define to 1 if you have the `gettimeofday' function. */
|
||||
#cmakedefine HAVE_GETTIMEOFDAY 1
|
||||
|
||||
/* Define to 1 if you have the `gmtime_r' function. */
|
||||
#cmakedefine HAVE_GMTIME_R 1
|
||||
|
||||
/* Define to 1 if you have the `htonl' function. */
|
||||
#cmakedefine HAVE_HTONL 1
|
||||
|
||||
/* Define to 1 if you have the `htons' function. */
|
||||
#cmakedefine HAVE_HTONS 1
|
||||
|
||||
/* Define to 1 if you have the `iconv' function. */
|
||||
#cmakedefine HAVE_ICONV 1
|
||||
|
||||
/* Define to 1 if you have the `iconv_close' function. */
|
||||
#cmakedefine HAVE_ICONV_CLOSE 1
|
||||
|
||||
/* Define to 1 if you have the `iconv_open' function. */
|
||||
#cmakedefine HAVE_ICONV_OPEN 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#cmakedefine HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the `advapi32' library (-ladvapi32). */
|
||||
#cmakedefine HAVE_LIBADVAPI32 1
|
||||
|
||||
/* Define to 1 if you have the `libiconv' function. */
|
||||
/* #undef HAVE_LIBICONV */
|
||||
|
||||
/* Define to 1 if you have the `libiconv_close' function. */
|
||||
/* #undef HAVE_LIBICONV_CLOSE */
|
||||
|
||||
/* Define to 1 if you have the `libiconv_open' function. */
|
||||
/* #undef HAVE_LIBICONV_OPEN */
|
||||
|
||||
/* Define to 1 if you have the `kernel32' library (-lkernel32). */
|
||||
#cmakedefine HAVE_LIBKERNEL32 1
|
||||
|
||||
/* Define to 1 if you have the `nsl' library (-lnsl). */
|
||||
#cmakedefine HAVE_LIBNSL 1
|
||||
|
||||
/* Define to 1 if you have the `rt' library (-lrt). */
|
||||
#cmakedefine HAVE_LIBRT 1
|
||||
|
||||
/* Define to 1 if you have the `socket' library (-lsocket). */
|
||||
#cmakedefine HAVE_LIBSOCKET 1
|
||||
|
||||
/* Define to 1 if you have the `ws2_32' library (-lws2_32). */
|
||||
#cmakedefine HAVE_LIBWS2_32 1
|
||||
|
||||
/* Define to 1 if you have the `localtime_r' function. */
|
||||
#cmakedefine HAVE_LOCALTIME_R 1
|
||||
|
||||
/* Define to 1 if you have the `lstat' function. */
|
||||
#cmakedefine HAVE_LSTAT 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#cmakedefine HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the `ntohl' function. */
|
||||
#cmakedefine HAVE_NTOHL 1
|
||||
|
||||
/* Define to 1 if you have the `ntohs' function. */
|
||||
#cmakedefine HAVE_NTOHS 1
|
||||
|
||||
/* Define if you have POSIX threads libraries and header files. */
|
||||
#undef HAVE_PTHREAD
|
||||
|
||||
/* Define to 1 if you have the `stat' function. */
|
||||
#cmakedefine HAVE_STAT 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#cmakedefine HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#cmakedefine HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#cmakedefine HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#cmakedefine HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#cmakedefine HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#cmakedefine HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#cmakedefine HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to 1 if you have the `vfprintf_s' function. */
|
||||
#cmakedefine HAVE_VFPRINTF_S 1
|
||||
|
||||
/* Define to 1 if you have the `vfwprintf_s' function. */
|
||||
#cmakedefine HAVE_VFWPRINTF_S 1
|
||||
|
||||
/* Define to 1 if you have the `vsnprintf' function. */
|
||||
#cmakedefine HAVE_VSNPRINTF 1
|
||||
|
||||
/* Define to 1 if you have the `vsprintf_s' function. */
|
||||
#cmakedefine HAVE_VSPRINTF_S 1
|
||||
|
||||
/* Define to 1 if you have the `vswprintf_s' function. */
|
||||
#cmakedefine HAVE_VSWPRINTF_S 1
|
||||
|
||||
/* Define to 1 if you have the `_vsnprintf' function. */
|
||||
#cmakedefine HAVE__VSNPRINTF 1
|
||||
|
||||
/* Define to 1 if you have the `_vsnprintf_s' function. */
|
||||
#cmakedefine HAVE__VSNPRINTF_S 1
|
||||
|
||||
/* Define to 1 if you have the `_vsnwprintf_s' function. */
|
||||
#cmakedefine HAVE__VSNWPRINTF_S 1
|
||||
|
||||
/* Defined if the compiler supports __FUNCTION__ macro. */
|
||||
#cmakedefine HAVE___FUNCTION___MACRO 1
|
||||
|
||||
/* Defined if the compiler supports __PRETTY_FUNCTION__ macro. */
|
||||
#cmakedefine HAVE___PRETTY_FUNCTION___MACRO 1
|
||||
|
||||
/* Defined if the compiler provides __sync_add_and_fetch(). */
|
||||
#cmakedefine HAVE___SYNC_ADD_AND_FETCH 1
|
||||
|
||||
/* Defined if the compiler provides __sync_sub_and_fetch(). */
|
||||
#cmakedefine HAVE___SYNC_SUB_AND_FETCH 1
|
||||
|
||||
/* Defined for --enable-debugging builds. */
|
||||
#undef LOG4CPLUS_DEBUGGING
|
||||
|
||||
/* Defined if the compiler understands __declspec(dllimport) or
|
||||
__attribute__((visibility("default"))) construct. */
|
||||
#define LOG4CPLUS_DECLSPEC_EXPORT @LOG4CPLUS_DECLSPEC_EXPORT@
|
||||
|
||||
/* Defined if the compiler understands __declspec(dllexport) or construct. */
|
||||
#define LOG4CPLUS_DECLSPEC_IMPORT @LOG4CPLUS_DECLSPEC_IMPORT@ /**/
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_CLOCK_GETTIME 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_ENAMETOOLONG 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_ERRNO_H 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_FTIME 1
|
||||
|
||||
/* */
|
||||
#define LOG4CPLUS_HAVE_FUNCTION_MACRO 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_GETADDRINFO 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_GETHOSTBYNAME_R 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_GETPID 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_GETTID 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_GETTIMEOFDAY 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_GMTIME_R 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_HTONL 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_HTONS 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_ICONV 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_ICONV_CLOSE 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_ICONV_H 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_ICONV_OPEN 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_LIMITS_H 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_LOCALTIME_R 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_LSTAT 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_NETDB_H 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_NETINET_IN_H 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_NETINET_TCP_H 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_NTOHL 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_NTOHS 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_PRETTY_FUNCTION_MACRO 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_STAT 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_STDARG_H 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_STDIO_H 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_STDLIB_H 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_SYSLOG_H 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_SYS_SOCKET_H 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_SYS_STAT_H 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_SYS_SYSCALL_H 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_SYS_TIMEB_H 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_SYS_TIME_H 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_TIME_H 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_UNISTD_H 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_VFPRINTF_S 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_VFWPRINTF_S 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_VSNPRINTF 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_VSPRINTF_S 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_VSWPRINTF_S 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE_WCHAR_H 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE__VSNPRINTF 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE__VSNPRINTF_S 1
|
||||
|
||||
/* */
|
||||
#cmakedefine LOG4CPLUS_HAVE__VSNWPRINTF_S 1
|
||||
|
||||
/* Define if this is a single-threaded library. */
|
||||
#undef LOG4CPLUS_SINGLE_THREADED
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_USE_PTHREADS
|
||||
|
||||
/* Define for compilers/standard libraries that support more than just the "C"
|
||||
locale. */
|
||||
#undef LOG4CPLUS_WORKING_LOCALE
|
||||
|
||||
/* Define to necessary symbol if this constant uses a non-standard name on
|
||||
your system. */
|
||||
#undef PTHREAD_CREATE_JOINABLE
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. Seems to be unused*/
|
||||
#cmakedefine STDC_HEADERS 1
|
||||
|
||||
/* Define to int if undefined. */
|
||||
#cmakedefine socklen_t int
|
||||
|
||||
#endif // LOG4CPLUS_CONFIG_H
|
|
@ -0,0 +1,471 @@
|
|||
/* include/log4cplus/config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
#ifndef LOG4CPLUS_CONFIG_H
|
||||
|
||||
#define LOG4CPLUS_CONFIG_H
|
||||
|
||||
/* define if the compiler supports basic C++11 syntax */
|
||||
#undef HAVE_CXX11
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define to 1 if you have the `fcntl' function. */
|
||||
#undef HAVE_FCNTL
|
||||
|
||||
/* Define to 1 if you have the `flock' function. */
|
||||
#undef HAVE_FLOCK
|
||||
|
||||
/* Define to 1 if you have the `ftime' function. */
|
||||
#undef HAVE_FTIME
|
||||
|
||||
/* Define to 1 if the system has the `constructor' function attribute */
|
||||
#undef HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR
|
||||
|
||||
/* Define to 1 if the system has the `constructor_priority' function attribute
|
||||
*/
|
||||
#undef HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR_PRIORITY
|
||||
|
||||
/* */
|
||||
#undef HAVE_GETADDRINFO
|
||||
|
||||
/* */
|
||||
#undef HAVE_GETHOSTBYNAME_R
|
||||
|
||||
/* Define to 1 if you have the `getpid' function. */
|
||||
#undef HAVE_GETPID
|
||||
|
||||
/* Define to 1 if you have the `gmtime_r' function. */
|
||||
#undef HAVE_GMTIME_R
|
||||
|
||||
/* Define to 1 if you have the `htonl' function. */
|
||||
#undef HAVE_HTONL
|
||||
|
||||
/* Define to 1 if you have the `htons' function. */
|
||||
#undef HAVE_HTONS
|
||||
|
||||
/* Define to 1 if you have the `iconv' function. */
|
||||
#undef HAVE_ICONV
|
||||
|
||||
/* Define to 1 if you have the `iconv_close' function. */
|
||||
#undef HAVE_ICONV_CLOSE
|
||||
|
||||
/* Define to 1 if you have the `iconv_open' function. */
|
||||
#undef HAVE_ICONV_OPEN
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the `advapi32' library (-ladvapi32). */
|
||||
#undef HAVE_LIBADVAPI32
|
||||
|
||||
/* Define to 1 if you have the `libiconv' function. */
|
||||
#undef HAVE_LIBICONV
|
||||
|
||||
/* Define to 1 if you have the `libiconv_close' function. */
|
||||
#undef HAVE_LIBICONV_CLOSE
|
||||
|
||||
/* Define to 1 if you have the `libiconv_open' function. */
|
||||
#undef HAVE_LIBICONV_OPEN
|
||||
|
||||
/* Define to 1 if you have the `kernel32' library (-lkernel32). */
|
||||
#undef HAVE_LIBKERNEL32
|
||||
|
||||
/* Define to 1 if you have the `oleaut32' library (-loleaut32). */
|
||||
#undef HAVE_LIBOLEAUT32
|
||||
|
||||
/* Define to 1 if you have the `ws2_32' library (-lws2_32). */
|
||||
#undef HAVE_LIBWS2_32
|
||||
|
||||
/* Define to 1 if you have the `localtime_r' function. */
|
||||
#undef HAVE_LOCALTIME_R
|
||||
|
||||
/* Define to 1 if you have the `lockf' function. */
|
||||
#undef HAVE_LOCKF
|
||||
|
||||
/* Define to 1 if you have the `lstat' function. */
|
||||
#undef HAVE_LSTAT
|
||||
|
||||
/* Define to 1 if you have the `mbstowcs' function. */
|
||||
#undef HAVE_MBSTOWCS
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the `ntohl' function. */
|
||||
#undef HAVE_NTOHL
|
||||
|
||||
/* Define to 1 if you have the `ntohs' function. */
|
||||
#undef HAVE_NTOHS
|
||||
|
||||
/* Define to 1 if you have the `OutputDebugStringW' function. */
|
||||
#undef HAVE_OUTPUTDEBUGSTRINGW
|
||||
|
||||
/* Define to 1 if you have the `pipe' function. */
|
||||
#undef HAVE_PIPE
|
||||
|
||||
/* Define to 1 if you have the `pipe2' function. */
|
||||
#undef HAVE_PIPE2
|
||||
|
||||
/* Define to 1 if you have the `poll' function. */
|
||||
#undef HAVE_POLL
|
||||
|
||||
/* Define if you have POSIX threads libraries and header files. */
|
||||
#undef HAVE_PTHREAD
|
||||
|
||||
/* Have PTHREAD_PRIO_INHERIT. */
|
||||
#undef HAVE_PTHREAD_PRIO_INHERIT
|
||||
|
||||
/* If available, contains the Python version number currently in use. */
|
||||
#undef HAVE_PYTHON
|
||||
|
||||
/* Define to 1 if you have the `shutdown' function. */
|
||||
#undef HAVE_SHUTDOWN
|
||||
|
||||
/* Define to 1 if you have the `stat' function. */
|
||||
#undef HAVE_STAT
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Defined if the compiler understands __thread or __declspec(thread)
|
||||
construct. */
|
||||
#undef HAVE_TLS_SUPPORT
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to 1 if the system has the `init_priority' variable attribute */
|
||||
#undef HAVE_VAR_ATTRIBUTE_INIT_PRIORITY
|
||||
|
||||
/* Define to 1 if you have the `vfprintf_s' function. */
|
||||
#undef HAVE_VFPRINTF_S
|
||||
|
||||
/* Define to 1 if you have the `vfwprintf_s' function. */
|
||||
#undef HAVE_VFWPRINTF_S
|
||||
|
||||
/* Define to 1 if you have the `vsnprintf' function. */
|
||||
#undef HAVE_VSNPRINTF
|
||||
|
||||
/* Define to 1 if you have the `vsnwprintf' function. */
|
||||
#undef HAVE_VSNWPRINTF
|
||||
|
||||
/* Define to 1 if you have the `vsprintf_s' function. */
|
||||
#undef HAVE_VSPRINTF_S
|
||||
|
||||
/* Define to 1 if you have the `vswprintf_s' function. */
|
||||
#undef HAVE_VSWPRINTF_S
|
||||
|
||||
/* Define to 1 if you have the `wcstombs' function. */
|
||||
#undef HAVE_WCSTOMBS
|
||||
|
||||
/* Define to 1 if you have the `_vsnprintf' function. */
|
||||
#undef HAVE__VSNPRINTF
|
||||
|
||||
/* Define to 1 if you have the `_vsnprintf_s' function. */
|
||||
#undef HAVE__VSNPRINTF_S
|
||||
|
||||
/* Define to 1 if you have the `_vsnwprintf' function. */
|
||||
#undef HAVE__VSNWPRINTF
|
||||
|
||||
/* Define to 1 if you have the `_vsnwprintf_s' function. */
|
||||
#undef HAVE__VSNWPRINTF_S
|
||||
|
||||
/* Defined if the compiler supports __FUNCTION__ macro. */
|
||||
#undef HAVE___FUNCTION___MACRO
|
||||
|
||||
/* Defined if the compiler supports __func__ symbol. */
|
||||
#undef HAVE___FUNC___SYMBOL
|
||||
|
||||
/* Defined if the compiler supports __PRETTY_FUNCTION__ macro. */
|
||||
#undef HAVE___PRETTY_FUNCTION___MACRO
|
||||
|
||||
/* Defined for --enable-debugging builds. */
|
||||
#undef LOG4CPLUS_DEBUGGING
|
||||
|
||||
/* Defined if the compiler understands __declspec(dllimport) or
|
||||
__attribute__((visibility("default"))) or __global construct. */
|
||||
#undef LOG4CPLUS_DECLSPEC_EXPORT
|
||||
|
||||
/* Defined if the compiler understands __declspec(dllimport) or
|
||||
__attribute__((visibility("default"))) or __global construct. */
|
||||
#undef LOG4CPLUS_DECLSPEC_IMPORT
|
||||
|
||||
/* Defined if the compiler understands __attribute__((visibility("hidden")))
|
||||
or __hidden construct. */
|
||||
#undef LOG4CPLUS_DECLSPEC_PRIVATE
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_ARPA_INET_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_ENAMETOOLONG
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_ERRNO_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_FCNTL
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_FCNTL_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_FLOCK
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_FTIME
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_FUNCTION_MACRO
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR_PRIORITY
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_FUNC_SYMBOL
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_GETADDRINFO
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_GETHOSTBYNAME_R
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_GETPID
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_GETTID
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_GMTIME_R
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_HTONL
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_HTONS
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_ICONV
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_ICONV_CLOSE
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_ICONV_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_ICONV_OPEN
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_LIMITS_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_LOCALTIME_R
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_LOCKF
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_LSTAT
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_MBSTOWCS
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_NETDB_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_NETINET_IN_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_NETINET_TCP_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_NTOHL
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_NTOHS
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_OUTPUTDEBUGSTRING
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_PIPE
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_PIPE2
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_POLL
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_POLL_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_PRETTY_FUNCTION_MACRO
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_SHUTDOWN
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_STAT
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_STDARG_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_STDIO_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_STDLIB_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_SYSLOG_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_SYS_FILE_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_SYS_SOCKET_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_SYS_STAT_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_SYS_SYSCALL_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_SYS_TIMEB_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_SYS_TIME_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_SYS_TYPES_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_TIME_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_TLS_SUPPORT
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_UNISTD_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_VAR_ATTRIBUTE_INIT_PRIORITY
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_VFPRINTF_S
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_VFWPRINTF_S
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_VSNPRINTF
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_VSNWPRINTF
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_VSPRINTF_S
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_VSWPRINTF_S
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_WCHAR_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_WCSTOMBS
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE__VSNPRINTF
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE__VSNPRINTF_S
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE__VSNWPRINTF
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE__VSNWPRINTF_S
|
||||
|
||||
/* Define if this is a single-threaded library. */
|
||||
#undef LOG4CPLUS_SINGLE_THREADED
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_THREAD_LOCAL_VAR
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_USE_PTHREADS
|
||||
|
||||
/* Define when iconv() is available. */
|
||||
#undef LOG4CPLUS_WITH_ICONV
|
||||
|
||||
/* Defined to enable unit tests. */
|
||||
#undef LOG4CPLUS_WITH_UNIT_TESTS
|
||||
|
||||
/* Define for C99 compilers/standard libraries that support more than just the
|
||||
"C" locale. */
|
||||
#undef LOG4CPLUS_WORKING_C_LOCALE
|
||||
|
||||
/* Define for compilers/standard libraries that support more than just the "C"
|
||||
locale. */
|
||||
#undef LOG4CPLUS_WORKING_LOCALE
|
||||
|
||||
/* Define to the sub-directory where libtool stores uninstalled libraries. */
|
||||
#undef LT_OBJDIR
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#undef PACKAGE_URL
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Define to necessary symbol if this constant uses a non-standard name on
|
||||
your system. */
|
||||
#undef PTHREAD_CREATE_JOINABLE
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Defined to the actual TLS support construct. */
|
||||
#undef TLS_SUPPORT_CONSTRUCT
|
||||
|
||||
/* Substitute for socklen_t */
|
||||
#undef socklen_t
|
||||
|
||||
#endif // LOG4CPLUS_CONFIG_H
|
|
@ -0,0 +1,211 @@
|
|||
// Copyright (C) 2009-2017, Vaclav Haisman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef LOG4CPLUS_CONFIG_HXX
|
||||
#define LOG4CPLUS_CONFIG_HXX
|
||||
|
||||
#if defined (_WIN32)
|
||||
# include <log4cplus/config/win32.h>
|
||||
#elif (defined(__MWERKS__) && defined(__MACOS__))
|
||||
# include <log4cplus/config/macosx.h>
|
||||
#else
|
||||
# include <log4cplus/config/defines.hxx>
|
||||
#endif
|
||||
|
||||
# if ! defined (LOG4CPLUS_WORKING_LOCALE) \
|
||||
&& ! defined (LOG4CPLUS_WORKING_C_LOCALE) \
|
||||
&& ! defined (LOG4CPLUS_WITH_ICONV)
|
||||
# define LOG4CPLUS_POOR_MANS_CHCONV
|
||||
#endif
|
||||
|
||||
#ifndef LOG4CPLUS_DECLSPEC_EXPORT
|
||||
#define LOG4CPLUS_DECLSPEC_EXPORT /* empty */
|
||||
#endif
|
||||
|
||||
#ifndef LOG4CPLUS_DECLSPEC_IMPORT
|
||||
#define LOG4CPLUS_DECLSPEC_IMPORT /* empty */
|
||||
#endif
|
||||
|
||||
#ifndef LOG4CPLUS_DECLSPEC_PRIVATE
|
||||
#define LOG4CPLUS_DECLSPEC_PRIVATE /* empty */
|
||||
#endif
|
||||
|
||||
#define LOG4CPLUS_PRIVATE LOG4CPLUS_DECLSPEC_PRIVATE
|
||||
|
||||
#if !defined(_WIN32)
|
||||
# define LOG4CPLUS_USE_BSD_SOCKETS
|
||||
# if !defined(LOG4CPLUS_SINGLE_THREADED)
|
||||
# define LOG4CPLUS_USE_PTHREADS
|
||||
# endif
|
||||
# if defined (INSIDE_LOG4CPLUS)
|
||||
# define LOG4CPLUS_EXPORT LOG4CPLUS_DECLSPEC_EXPORT
|
||||
# else
|
||||
# define LOG4CPLUS_EXPORT LOG4CPLUS_DECLSPEC_IMPORT
|
||||
# endif // defined (INSIDE_LOG4CPLUS)
|
||||
|
||||
#endif // !_WIN32
|
||||
|
||||
#if defined (LOG4CPLUS_INLINES_ARE_EXPORTED) \
|
||||
&& defined (LOG4CPLUS_BUILD_DLL)
|
||||
# define LOG4CPLUS_INLINE_EXPORT inline
|
||||
#else
|
||||
# define LOG4CPLUS_INLINE_EXPORT
|
||||
#endif
|
||||
|
||||
#if defined (UNICODE)
|
||||
# if defined (_MSC_VER) && _MSC_VER >= 1400
|
||||
# define LOG4CPLUS_FSTREAM_ACCEPTS_WCHAR_T
|
||||
# endif
|
||||
# if defined (_MSC_VER) && _MSC_VER >= 1600
|
||||
# define LOG4CPLUS_HAVE_CODECVT_UTF8_FACET
|
||||
# define LOG4CPLUS_HAVE_CODECVT_UTF16_FACET
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// C++11 stuff
|
||||
|
||||
#if ! defined (__has_feature)
|
||||
//! __has_feature(X) is Clangs way for testing features.
|
||||
//! Define it to 0 if it does not exist.
|
||||
# define __has_feature(X) 0
|
||||
#endif
|
||||
|
||||
#if __has_feature (cxx_noexcept) \
|
||||
|| (defined (__GNUC__) \
|
||||
&& (__GNUC__ > 4 \
|
||||
|| __GNUC__ == 4 && __GNUC_MINOR__ >= 6)) \
|
||||
|| (defined (_MSC_VER) && _MSC_VER >= 1900)
|
||||
# define LOG4CPLUS_NOEXCEPT noexcept
|
||||
# define LOG4CPLUS_NOEXCEPT_FALSE noexcept(false)
|
||||
#else
|
||||
# define LOG4CPLUS_NOEXCEPT /* empty */
|
||||
# define LOG4CPLUS_NOEXCEPT_FALSE /* empty */
|
||||
#endif
|
||||
|
||||
#if ! defined (UNICODE) && defined (__GNUC__) && __GNUC__ >= 3
|
||||
# define LOG4CPLUS_FORMAT_ATTRIBUTE(archetype, format_index, first_arg_index) \
|
||||
__attribute__ ((format (archetype, format_index, first_arg_index)))
|
||||
#else
|
||||
# define LOG4CPLUS_FORMAT_ATTRIBUTE(archetype, fmt_index, first_arg_index) \
|
||||
/* empty */
|
||||
#endif
|
||||
|
||||
#if defined (__GNUC__) \
|
||||
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) \
|
||||
&& ! defined (__INTEL_COMPILER) \
|
||||
&& ! defined (__CUDACC__)
|
||||
# define LOG4CPLUS_CALLER_FILE() __builtin_FILE ()
|
||||
# define LOG4CPLUS_CALLER_LINE() __builtin_LINE ()
|
||||
# define LOG4CPLUS_CALLER_FUNCTION() __builtin_FUNCTION ()
|
||||
#else
|
||||
# define LOG4CPLUS_CALLER_FILE() (nullptr)
|
||||
# define LOG4CPLUS_CALLER_LINE() (-1)
|
||||
# define LOG4CPLUS_CALLER_FUNCTION() (nullptr)
|
||||
#endif
|
||||
|
||||
#if defined (__GNUC__) && __GNUC__ >= 3
|
||||
# define LOG4CPLUS_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
|
||||
# define LOG4CPLUS_ATTRIBUTE_PURE __attribute__ ((__pure__))
|
||||
# define LOG4CPLUS_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__))
|
||||
# define LOG4CPLUS_BUILTIN_EXPECT(exp, c) __builtin_expect ((exp), (c))
|
||||
#else
|
||||
# if ! defined (LOG4CPLUS_ATTRIBUTE_NORETURN)
|
||||
# define LOG4CPLUS_ATTRIBUTE_NORETURN /* empty */
|
||||
# endif
|
||||
# define LOG4CPLUS_ATTRIBUTE_PURE /* empty */
|
||||
# define LOG4CPLUS_ATTRIBUTE_DEPRECATED /* empty */
|
||||
# define LOG4CPLUS_BUILTIN_EXPECT(exp, c) (exp)
|
||||
#endif
|
||||
|
||||
#define LOG4CPLUS_LIKELY(cond) LOG4CPLUS_BUILTIN_EXPECT(!! (cond), 1)
|
||||
#define LOG4CPLUS_UNLIKELY(cond) LOG4CPLUS_BUILTIN_EXPECT(!! (cond), 0)
|
||||
|
||||
#if defined (_MSC_VER) \
|
||||
|| (defined (__BORLANDC__) && __BORLANDC__ >= 0x0650) \
|
||||
|| (defined (__COMO__) && __COMO_VERSION__ >= 400) /* ??? */ \
|
||||
|| (defined (__DMC__) && __DMC__ >= 0x700) /* ??? */ \
|
||||
|| (defined (__clang__) && __clang_major__ >= 3) \
|
||||
|| (defined (__GNUC__) && (__GNUC__ >= 4 \
|
||||
|| (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)))
|
||||
# define LOG4CPLUS_HAVE_PRAGMA_ONCE
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR_PRIORITY)
|
||||
# define LOG4CPLUS_CONSTRUCTOR_FUNC(prio) \
|
||||
__attribute__ ((__constructor__ ((prio))))
|
||||
#elif defined (LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR)
|
||||
# define LOG4CPLUS_CONSTRUCTOR_FUNC(prio) \
|
||||
__attribute__ ((__constructor__))
|
||||
#else
|
||||
# define LOG4CPLUS_CONSTRUCTOR_FUNC(prio) /* empty */
|
||||
#endif
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_VAR_ATTRIBUTE_INIT_PRIORITY)
|
||||
# define LOG4CPLUS_INIT_PRIORITY(prio) \
|
||||
__attribute__ ((__init_priority__ ((prio))))
|
||||
#else
|
||||
# define LOG4CPLUS_INIT_PRIORITY(prio) /* empty */
|
||||
#endif
|
||||
|
||||
#define LOG4CPLUS_INIT_PRIORITY_BASE (65535 / 2)
|
||||
|
||||
#include <log4cplus/helpers/thread-config.h>
|
||||
|
||||
#if defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
#define LOG4CPLUS_THREADED(x)
|
||||
#else
|
||||
#define LOG4CPLUS_THREADED(x) x
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#include <cstddef>
|
||||
|
||||
namespace log4cplus
|
||||
{
|
||||
|
||||
//! Per thread cleanup function. Users should call this function before
|
||||
//! a thread ends its execution. It frees resources allocated in thread local
|
||||
//! storage. It is important only for multi-threaded static library builds
|
||||
//! of log4cplus and user threads. In all other cases the clean up is provided
|
||||
//! automatically by other means.
|
||||
LOG4CPLUS_EXPORT void threadCleanup ();
|
||||
|
||||
//! Initializes log4cplus.
|
||||
//!
|
||||
//! \note using `log4cplus::Initializer` is preferred
|
||||
LOG4CPLUS_EXPORT void initialize ();
|
||||
|
||||
//! Deinitializes log4cplus.
|
||||
//!
|
||||
//! \note using `log4cplus::Initializer` is preferred
|
||||
LOG4CPLUS_EXPORT void deinitialize ();
|
||||
|
||||
//! Set thread pool size.
|
||||
LOG4CPLUS_EXPORT void setThreadPoolSize (std::size_t pool_size);
|
||||
|
||||
} // namespace log4cplus
|
||||
|
||||
#endif
|
||||
|
||||
#endif // LOG4CPLUS_CONFIG_HXX
|
|
@ -0,0 +1,250 @@
|
|||
#ifndef LOG4CPLUS_CONFIG_DEFINES_HXX
|
||||
#define LOG4CPLUS_CONFIG_DEFINES_HXX
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_SYSLOG_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_ARPA_INET_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_NETINET_IN_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_NETINET_TCP_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_SYS_TIMEB_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_SYS_TIME_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_SYS_TYPES_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_SYS_STAT_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_SYS_SYSCALL_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_SYS_FILE_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_TIME_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_SYS_SOCKET_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_NETDB_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_UNISTD_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_FCNTL_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_STDARG_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_STDIO_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_STDLIB_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_ERRNO_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_WCHAR_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_ICONV_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_LIMITS_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_FTIME
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_GETADDRINFO
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_GETHOSTBYNAME_R
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_GETPID
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_GMTIME_R
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_HTONL
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_HTONS
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_LOCALTIME_R
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_LSTAT
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_FCNTL
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_LOCKF
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_FLOCK
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_NTOHL
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_NTOHS
|
||||
|
||||
/* Define to 1 if you have the `shutdown' function. */
|
||||
#undef LOG4CPLUS_HAVE_SHUTDOWN
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_PIPE
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_PIPE2
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_ACCEPT4
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_POLL
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_POLL_H
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_STAT
|
||||
|
||||
/* Define if this is a single-threaded library. */
|
||||
#undef LOG4CPLUS_SINGLE_THREADED
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_USE_PTHREADS
|
||||
|
||||
/* Define for compilers/standard libraries that support more than just the "C"
|
||||
locale. */
|
||||
#undef LOG4CPLUS_WORKING_LOCALE
|
||||
|
||||
/* Define for C99 compilers/standard libraries that support more than just the
|
||||
"C" locale. */
|
||||
#undef LOG4CPLUS_WORKING_C_LOCALE
|
||||
|
||||
/* Define to int if undefined. */
|
||||
#undef socklen_t
|
||||
|
||||
/* Defined for --enable-debugging builds. */
|
||||
#undef LOG4CPLUS_DEBUGGING
|
||||
|
||||
/* Defined if the compiler understands __declspec(dllexport) or
|
||||
__attribute__((visibility("default"))) construct. */
|
||||
#undef LOG4CPLUS_DECLSPEC_EXPORT
|
||||
|
||||
/* Defined if the compiler understands __declspec(dllimport) or
|
||||
__attribute__((visibility("default"))) construct. */
|
||||
#undef LOG4CPLUS_DECLSPEC_IMPORT
|
||||
|
||||
/* Defined if the compiler understands
|
||||
__attribute__((visibility("hidden"))) construct. */
|
||||
#undef LOG4CPLUS_DECLSPEC_PRIVATE
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_TLS_SUPPORT
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_THREAD_LOCAL_VAR
|
||||
|
||||
/* Defined if the host OS provides ENAMETOOLONG errno value. */
|
||||
#undef LOG4CPLUS_HAVE_ENAMETOOLONG
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE_VSNPRINTF
|
||||
|
||||
/* Define to 1 if you have the `vsnwprintf' function. */
|
||||
#undef LOG4CPLUS_HAVE_VSNWPRINTF
|
||||
|
||||
/* Define to 1 if you have the `_vsnwprintf' function. */
|
||||
#undef LOG4CPLUS_HAVE__VSNWPRINTF
|
||||
|
||||
/* */
|
||||
#undef LOG4CPLUS_HAVE__VSNPRINTF
|
||||
|
||||
/* Define to 1 if you have the `vfprintf_s' function. */
|
||||
#undef LOG4CPLUS_HAVE_VFPRINTF_S
|
||||
|
||||
/* Define to 1 if you have the `vfwprintf_s' function. */
|
||||
#undef LOG4CPLUS_HAVE_VFWPRINTF_S
|
||||
|
||||
/* Define to 1 if you have the `vsprintf_s' function. */
|
||||
#undef LOG4CPLUS_HAVE_VSPRINTF_S
|
||||
|
||||
/* Define to 1 if you have the `vswprintf_s' function. */
|
||||
#undef LOG4CPLUS_HAVE_VSWPRINTF_S
|
||||
|
||||
/* Define to 1 if you have the `_vsnprintf_s' function. */
|
||||
#undef LOG4CPLUS_HAVE__VSNPRINTF_S
|
||||
|
||||
/* Define to 1 if you have the `_vsnwprintf_s' function. */
|
||||
#undef LOG4CPLUS_HAVE__VSNWPRINTF_S
|
||||
|
||||
/* Defined if the compiler supports __FUNCTION__ macro. */
|
||||
#undef LOG4CPLUS_HAVE_FUNCTION_MACRO
|
||||
|
||||
/* Defined if the compiler supports __PRETTY_FUNCTION__ macro. */
|
||||
#undef LOG4CPLUS_HAVE_PRETTY_FUNCTION_MACRO
|
||||
|
||||
/* Defined if the compiler supports __func__ symbol. */
|
||||
#undef LOG4CPLUS_HAVE_FUNC_SYMBOL
|
||||
|
||||
/* Define to 1 if you have the `mbstowcs' function. */
|
||||
#undef LOG4CPLUS_HAVE_MBSTOWCS
|
||||
|
||||
/* Define to 1 if you have the `wcstombs' function. */
|
||||
#undef LOG4CPLUS_HAVE_WCSTOMBS
|
||||
|
||||
/* Define to 1 if you have Linux style syscall(SYS_gettid). */
|
||||
#undef LOG4CPLUS_HAVE_GETTID
|
||||
|
||||
/* Define when iconv() is available. */
|
||||
#undef LOG4CPLUS_WITH_ICONV
|
||||
|
||||
/* Define to 1 if you have the `iconv' function. */
|
||||
#undef LOG4CPLUS_HAVE_ICONV
|
||||
|
||||
/* Define to 1 if you have the `iconv_close' function. */
|
||||
#undef LOG4CPLUS_HAVE_ICONV_CLOSE
|
||||
|
||||
/* Define to 1 if you have the `iconv_open' function. */
|
||||
#undef LOG4CPLUS_HAVE_ICONV_OPEN
|
||||
|
||||
/* Define to 1 if you have the `OutputDebugString' function. */
|
||||
#undef LOG4CPLUS_HAVE_OUTPUTDEBUGSTRING
|
||||
|
||||
/* Define to 1 if the system has the `constructor' function attribute
|
||||
with priority */
|
||||
#undef LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR_PRIORITY
|
||||
|
||||
/* Define to 1 if the system has the `constructor' function attribute */
|
||||
#undef LOG4CPLUS_HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR
|
||||
|
||||
/* Define to 1 if the system has the `init_priority' variable attribute */
|
||||
#undef LOG4CPLUS_HAVE_VAR_ATTRIBUTE_INIT_PRIORITY
|
||||
|
||||
/* Defined to enable unit tests. */
|
||||
#undef LOG4CPLUS_WITH_UNIT_TESTS
|
||||
|
||||
#endif // LOG4CPLUS_CONFIG_DEFINES_HXX
|
|
@ -0,0 +1,37 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: config-macosx.h
|
||||
// Created: 7/2003
|
||||
// Author: Christopher R. Bailey
|
||||
//
|
||||
//
|
||||
// Copyright 2003-2017 Christopher R. Bailey
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_CONFIG_MACOSX_HEADER_
|
||||
#define LOG4CPLUS_CONFIG_MACOSX_HEADER_
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if (defined(__APPLE__) || (defined(__MWERKS__) && defined(__MACOS__)))
|
||||
|
||||
#define LOG4CPLUS_HAVE_GETTIMEOFDAY 1
|
||||
#define socklen_t int
|
||||
|
||||
#endif // MACOSX
|
||||
#endif // LOG4CPLUS_CONFIG_MACOSX_HEADER_
|
|
@ -0,0 +1,194 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: config-win32.h
|
||||
// Created: 4/2003
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2003-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_CONFIG_WIN32_HEADER_
|
||||
#define LOG4CPLUS_CONFIG_WIN32_HEADER_
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if defined (__MINGW32__) || defined (__MINGW64__)
|
||||
# include <_mingw.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#if (defined (_MSC_VER) && _MSC_VER > 1400) \
|
||||
|| (defined (__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR >= 3)
|
||||
# define LOG4CPLUS_HAVE_INTRIN_H
|
||||
#endif
|
||||
|
||||
// Time related functions and headers.
|
||||
#define LOG4CPLUS_HAVE_TIME_H
|
||||
#define LOG4CPLUS_HAVE_SYS_TIMEB_H
|
||||
#define LOG4CPLUS_HAVE_FTIME
|
||||
#if defined (_MSC_VER) || defined (__BORLANDC__)
|
||||
#define LOG4CPLUS_HAVE_GMTIME_S
|
||||
#endif
|
||||
|
||||
// Use Winsock on Windows.
|
||||
#define LOG4CPLUS_USE_WINSOCK
|
||||
|
||||
// Enable Win32DebugAppender
|
||||
#define LOG4CPLUS_HAVE_OUTPUTDEBUGSTRING
|
||||
|
||||
// Enable Win32ConsoleAppender.
|
||||
#define LOG4CPLUS_HAVE_WIN32_CONSOLE
|
||||
|
||||
#define LOG4CPLUS_HAVE_SYS_TYPES_H
|
||||
#define LOG4CPLUS_HAVE_SYS_LOCKING_H
|
||||
#define LOG4CPLUS_HAVE_FCNTL_H
|
||||
#define LOG4CPLUS_HAVE_IO_H
|
||||
#define LOG4CPLUS_HAVE_STDIO_H
|
||||
#define LOG4CPLUS_HAVE_WCHAR_H
|
||||
#define LOG4CPLUS_HAVE_STDARG_H
|
||||
#define LOG4CPLUS_HAVE_STDLIB_H
|
||||
#define LOG4CPLUS_HAVE_ERRNO_H
|
||||
#define LOG4CPLUS_HAVE_SYS_STAT_H
|
||||
#define LOG4CPLUS_HAVE_TIME_H
|
||||
#define LOG4CPLUS_HAVE_STDLIB_H
|
||||
#define LOG4CPLUS_HAVE_DIRECT_H
|
||||
|
||||
// MSVC has both and so does MinGW.
|
||||
#define LOG4CPLUS_HAVE_VSNPRINTF
|
||||
#define LOG4CPLUS_HAVE__VSNPRINTF
|
||||
#define LOG4CPLUS_HAVE__VSNWPRINTF
|
||||
|
||||
// Limit the use of foo_s() functions to builds using Visual Studio
|
||||
// 2005 and its run time library. In MinGW land, limit the foo_s()
|
||||
// functions to MinGw-w64 toolchain and __MSVCRT_VERSION__ >= 0x0900.
|
||||
#if (defined (_MSC_VER) && _MSC_VER >= 1400) \
|
||||
|| (defined (__MSVCRT_VERSION__) && __MSVCRT_VERSION__ >= 0x0900 \
|
||||
&& defined (__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR >= 2)
|
||||
// MS secure versions of vprintf().
|
||||
# define LOG4CPLUS_HAVE_VSPRINTF_S
|
||||
# define LOG4CPLUS_HAVE_VSWPRINTF_S
|
||||
|
||||
// MS secure versions of vfprintf().
|
||||
# define LOG4CPLUS_HAVE_VFPRINTF_S
|
||||
# define LOG4CPLUS_HAVE_VFWPRINTF_S
|
||||
|
||||
// MS secure versions of vsnprintf().
|
||||
# define LOG4CPLUS_HAVE_VSNPRINTF_S
|
||||
# define LOG4CPLUS_HAVE__VSNPRINTF_S
|
||||
# define LOG4CPLUS_HAVE__VSNWPRINTF_S
|
||||
|
||||
// MS secure version of _tsopen().
|
||||
# define LOG4CPLUS_HAVE__TSOPEN_S
|
||||
#endif
|
||||
|
||||
#if defined (_MSC_VER) && _MSC_VER >= 1400
|
||||
// MS printf-like functions supporting positional parameters.
|
||||
# define LOG4CPLUS_HAVE__VSPRINTF_P
|
||||
# define LOG4CPLUS_HAVE__VSWPRINTF_P
|
||||
#endif
|
||||
|
||||
#if defined (_MSC_VER)
|
||||
# define LOG4CPLUS_HAVE_LOCALTIME_S
|
||||
#endif
|
||||
|
||||
#define LOG4CPLUS_HAVE__TSOPEN
|
||||
|
||||
#define LOG4CPLUS_DLLMAIN_HINSTANCE HINSTANCE
|
||||
#define LOG4CPLUS_HAVE_NT_EVENT_LOG
|
||||
|
||||
// log4cplus_EXPORTS is used by the CMake build system. DLL_EXPORT is
|
||||
// used by the autotools build system.
|
||||
#if (defined (log4cplus_EXPORTS) || defined (log4cplusU_EXPORTS) \
|
||||
|| (defined (DLL_EXPORT) && defined (INSIDE_LOG4CPLUS))) \
|
||||
&& ! defined (LOG4CPLUS_STATIC)
|
||||
# undef LOG4CPLUS_BUILD_DLL
|
||||
# define LOG4CPLUS_BUILD_DLL
|
||||
#endif
|
||||
|
||||
#if ! defined (LOG4CPLUS_BUILD_DLL)
|
||||
# undef LOG4CPLUS_STATIC
|
||||
# define LOG4CPLUS_STATIC
|
||||
#endif
|
||||
|
||||
#if defined (LOG4CPLUS_STATIC) && defined (LOG4CPLUS_BUILD_DLL)
|
||||
# error LOG4CPLUS_STATIC and LOG4CPLUS_BUILD_DLL cannot be defined both.
|
||||
#endif
|
||||
|
||||
#if defined (LOG4CPLUS_BUILD_DLL)
|
||||
# if defined (INSIDE_LOG4CPLUS)
|
||||
# define LOG4CPLUS_EXPORT __declspec(dllexport)
|
||||
# else
|
||||
# define LOG4CPLUS_EXPORT __declspec(dllimport)
|
||||
# endif
|
||||
#else
|
||||
# define LOG4CPLUS_EXPORT
|
||||
#endif
|
||||
|
||||
#ifndef LOG4CPLUS_SINGLE_THREADED
|
||||
# define LOG4CPLUS_USE_WIN32_THREADS
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
// Warning about: identifier was truncated to '255' characters in the debug information
|
||||
# pragma warning( disable : 4786 )
|
||||
// Warning about: <type1> needs to have dll-interface to be used by clients of class <type2>
|
||||
# pragma warning( disable : 4251 )
|
||||
|
||||
# define LOG4CPLUS_INLINES_ARE_EXPORTED
|
||||
|
||||
# if _MSC_VER >= 1400
|
||||
# define LOG4CPLUS_WORKING_LOCALE
|
||||
# define LOG4CPLUS_HAVE_FUNCTION_MACRO
|
||||
# define LOG4CPLUS_HAVE_FUNCSIG_MACRO
|
||||
# define LOG4CPLUS_ATTRIBUTE_NORETURN __declspec(noreturn)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (__GNUC__)
|
||||
# undef LOG4CPLUS_INLINES_ARE_EXPORTED
|
||||
# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
|
||||
# define LOG4CPLUS_HAVE_PRETTY_FUNCTION_MACRO
|
||||
# define LOG4CPLUS_HAVE_FUNC_SYMBOL
|
||||
# endif
|
||||
// This has worked for some versions of MinGW with GCC 4.7+ but it
|
||||
// appears to be broken again in 4.8.x. Thus, we disable this for GCC
|
||||
// completely forever.
|
||||
//
|
||||
//# define LOG4CPLUS_INLINES_ARE_EXPORTED
|
||||
# define LOG4CPLUS_HAVE_FUNCTION_MACRO
|
||||
# if defined (__MINGW32__)
|
||||
# define LOG4CPLUS_WORKING_C_LOCALE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (__BORLANDC__) && __BORLANDC__ >= 0x0650
|
||||
# define LOG4CPLUS_HAVE_FUNCTION_MACRO
|
||||
#endif // __BORLANDC__
|
||||
|
||||
#if ! defined (LOG4CPLUS_DISABLE_DLL_RUNTIME_WARNING)
|
||||
# if defined (LOG4CPLUS_STATIC) && defined (_MSC_VER) && ! defined (_DLL)
|
||||
# pragma message("You are not using DLL C run time library. " \
|
||||
"You must call log4cplus::initialize() once before " \
|
||||
"you use any other log4cplus API.")
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif // _WIN32
|
||||
#endif // LOG4CPLUS_CONFIG_WIN32_HEADER_
|
|
@ -0,0 +1,42 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: windowsh-inc.h
|
||||
// Created: 9/2018
|
||||
// Author: Vaclav Haisman
|
||||
//
|
||||
//
|
||||
// Copyright (C) 2018, Vaclav Haisman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// NOTE: This file is a fragment intentionally left without include guards.
|
||||
|
||||
#if defined (_WIN32)
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <windows.h>
|
||||
#if defined (LOG4CPLUS_HAVE_INTRIN_H)
|
||||
#include <intrin.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// NOTE: This file is a fragment intentionally left without include guards.
|
|
@ -0,0 +1,159 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: windowsh-inc.h
|
||||
// Created: 4/2010
|
||||
// Author: Vaclav Zeman
|
||||
//
|
||||
//
|
||||
// Copyright (C) 2010-2017, Vaclav Zeman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// NOTE: This file is a fragment intentionally left without include guards.
|
||||
|
||||
#if defined (_WIN32)
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
#undef NOGDICAPMASKS
|
||||
#define NOGDICAPMASKS
|
||||
|
||||
#undef NOVIRTUALKEYCODES
|
||||
#define NOVIRTUALKEYCODES
|
||||
|
||||
#undef NOWINMESSAGES
|
||||
#define NOWINMESSAGES
|
||||
|
||||
#undef NOWINSTYLES
|
||||
#define NOWINSTYLES
|
||||
|
||||
#undef NOSYSMETRICS
|
||||
#define NOSYSMETRICS
|
||||
|
||||
#undef NOMENUS
|
||||
#define NOMENUS
|
||||
|
||||
#undef NOICONS
|
||||
#define NOICONS
|
||||
|
||||
#undef NOKEYSTATES
|
||||
#define NOKEYSTATES
|
||||
|
||||
#undef NOSYSCOMMANDS
|
||||
#define NOSYSCOMMANDS
|
||||
|
||||
#undef NORASTEROPS
|
||||
#define NORASTEROPS
|
||||
|
||||
#undef NOSHOWWINDOW
|
||||
#define NOSHOWWINDOW
|
||||
|
||||
#undef NOATOM
|
||||
#define NOATOM
|
||||
|
||||
#undef NOCLIPBOARD
|
||||
#define NOCLIPBOARD
|
||||
|
||||
#undef NOCOLOR
|
||||
#define NOCOLOR
|
||||
|
||||
#undef NOCTLMGR
|
||||
#define NOCTLMGR
|
||||
|
||||
#undef NODRAWTEXT
|
||||
#define NODRAWTEXT
|
||||
|
||||
#undef NOGDI
|
||||
#define NOGDI
|
||||
|
||||
#undef NOKERNEL
|
||||
#define NOKERNEL
|
||||
|
||||
#undef NOUSER
|
||||
#define NOUSER
|
||||
|
||||
#undef NONLS
|
||||
#define NONLS
|
||||
|
||||
#undef NOMB
|
||||
#define NOMB
|
||||
|
||||
#undef NOMEMMGR
|
||||
#define NOMEMMGR
|
||||
|
||||
#undef NOMETAFILE
|
||||
#define NOMETAFILE
|
||||
|
||||
#undef NOMINMAX
|
||||
#define NOMINMAX
|
||||
|
||||
#undef NOMSG
|
||||
#define NOMSG
|
||||
|
||||
#undef NOOPENFILE
|
||||
#define NOOPENFILE
|
||||
|
||||
#undef NOSCROLL
|
||||
#define NOSCROLL
|
||||
|
||||
#undef NOSERVICE
|
||||
#define NOSERVICE
|
||||
|
||||
#undef NOSOUND
|
||||
#define NOSOUND
|
||||
|
||||
#undef NOTEXTMETRIC
|
||||
#define NOTEXTMETRIC
|
||||
|
||||
#undef NOWH
|
||||
#define NOWH
|
||||
|
||||
#undef NOWINOFFSETS
|
||||
#define NOWINOFFSETS
|
||||
|
||||
#undef NOCOMM
|
||||
#define NOCOMM
|
||||
|
||||
#undef NOKANJI
|
||||
#define NOKANJI
|
||||
|
||||
#undef NOHELP
|
||||
#define NOHELP
|
||||
|
||||
#undef NOPROFILER
|
||||
#define NOPROFILER
|
||||
|
||||
#undef NODEFERWINDOWPOS
|
||||
#define NODEFERWINDOWPOS
|
||||
|
||||
#undef NOMCX
|
||||
#define NOMCX
|
||||
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <windows.h>
|
||||
#if defined (LOG4CPLUS_HAVE_INTRIN_H)
|
||||
#include <intrin.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// NOTE: This file is a fragment intentionally left without include guards.
|
|
@ -0,0 +1,378 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: configurator.h
|
||||
// Created: 3/2003
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2003-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_CONFIGURATOR_HEADER_
|
||||
#define LOG4CPLUS_CONFIGURATOR_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/appender.h>
|
||||
#include <log4cplus/logger.h>
|
||||
#include <log4cplus/helpers/pointer.h>
|
||||
#include <log4cplus/helpers/property.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
|
||||
namespace log4cplus
|
||||
{
|
||||
class Hierarchy;
|
||||
|
||||
|
||||
/**
|
||||
* Provides configuration from an external file. See configure() for
|
||||
* the expected format.
|
||||
*
|
||||
* <em>All option values admit variable substitution.</em> For
|
||||
* example, if <code>userhome</code> environment property is set to
|
||||
* <code>/home/xyz</code> and the File option is set to the string
|
||||
* <code>${userhome}/test.log</code>, then File option will be
|
||||
* interpreted as the string <code>/home/xyz/test.log</code>.
|
||||
*
|
||||
* The syntax of variable substitution is similar to that of UNIX
|
||||
* shells. The string between an opening <b>"${"</b> and
|
||||
* closing <b>"}"</b> is interpreted as a key. Its value is
|
||||
* searched in the environment properties. The corresponding value replaces
|
||||
* the ${variableName} sequence.
|
||||
*
|
||||
* Configuration files also recognize <code>include
|
||||
* <i>file.properties</i></code> directive that allow composing
|
||||
* configuration from multiple files. There is no cyclic includes
|
||||
* detection mechanism to stop unbound recursion.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT PropertyConfigurator
|
||||
{
|
||||
public:
|
||||
enum PCFlags
|
||||
{
|
||||
fRecursiveExpansion = (1 << 0)
|
||||
, fShadowEnvironment = (1 << 1)
|
||||
, fAllowEmptyVars = (1 << 2)
|
||||
|
||||
// These encoding related options occupy 2 bits of the flags
|
||||
// and are mutually exclusive. These flags are synchronized with
|
||||
// PFlags in Properties.
|
||||
|
||||
, fEncodingShift = 3
|
||||
, fEncodingMask = 0x3
|
||||
, fUnspecEncoding = (0 << fEncodingShift)
|
||||
#if defined (LOG4CPLUS_HAVE_CODECVT_UTF8_FACET) && defined (UNICODE)
|
||||
, fUTF8 = (1 << fEncodingShift)
|
||||
#endif
|
||||
#if (defined (LOG4CPLUS_HAVE_CODECVT_UTF16_FACET) || defined (_WIN32)) \
|
||||
&& defined (UNICODE)
|
||||
, fUTF16 = (2 << fEncodingShift)
|
||||
#endif
|
||||
#if defined (LOG4CPLUS_HAVE_CODECVT_UTF32_FACET) && defined (UNICODE)
|
||||
, fUTF32 = (3 << fEncodingShift)
|
||||
#endif
|
||||
};
|
||||
|
||||
// ctor and dtor
|
||||
PropertyConfigurator(const log4cplus::tstring& propertyFile,
|
||||
Hierarchy& h = Logger::getDefaultHierarchy(), unsigned flags = 0);
|
||||
PropertyConfigurator(const log4cplus::helpers::Properties& props,
|
||||
Hierarchy& h = Logger::getDefaultHierarchy(), unsigned flags = 0);
|
||||
PropertyConfigurator(log4cplus::tistream& propertyStream,
|
||||
Hierarchy& h = Logger::getDefaultHierarchy(), unsigned flags = 0);
|
||||
virtual ~PropertyConfigurator();
|
||||
|
||||
/**
|
||||
* This method eliminates the need to create a temporary
|
||||
* <code>PropertyConfigurator</code> to configure log4cplus.
|
||||
* It is equivalent to the following:<br>
|
||||
* <code>
|
||||
* PropertyConfigurator config("filename");
|
||||
* config.configure();
|
||||
* </code>
|
||||
*/
|
||||
static void doConfigure(const log4cplus::tstring& configFilename,
|
||||
Hierarchy& h = Logger::getDefaultHierarchy(), unsigned flags = 0);
|
||||
|
||||
/**
|
||||
* Read configuration from a file. <b>The existing configuration is
|
||||
* not cleared nor reset.</b> If you require a different behavior,
|
||||
* then call {@link Hierarchy::resetConfiguration
|
||||
* resetConfiguration} method before calling
|
||||
* <code>doConfigure</code>.
|
||||
*
|
||||
* The configuration file consists of statements in the format
|
||||
* <code>key=value</code>. The syntax of different configuration
|
||||
* elements are discussed below.
|
||||
*
|
||||
* <h3>Appender configuration</h3>
|
||||
*
|
||||
* Appender configuration syntax is:
|
||||
* <pre>
|
||||
* # For appender named <i>appenderName</i>, set its class.
|
||||
* # Note: The appender name can contain dots.
|
||||
* log4cplus.appender.appenderName=fully.qualified.name.of.appender.class
|
||||
*
|
||||
* # Set appender specific options.
|
||||
* log4cplus.appender.appenderName.option1=value1
|
||||
* ...
|
||||
* log4cplus.appender.appenderName.optionN=valueN
|
||||
* </pre>
|
||||
*
|
||||
* For each named appender you can configure its {@link Layout}. The
|
||||
* syntax for configuring an appender's layout is:
|
||||
* <pre>
|
||||
* log4cplus.appender.appenderName.layout=fully.qualified.name.of.layout.class
|
||||
* log4cplus.appender.appenderName.layout.option1=value1
|
||||
* ....
|
||||
* log4cplus.appender.appenderName.layout.optionN=valueN
|
||||
* </pre>
|
||||
*
|
||||
* <h3>Configuring loggers</h3>
|
||||
*
|
||||
* The syntax for configuring the root logger is:
|
||||
* <pre>
|
||||
* log4cplus.rootLogger=[LogLevel], appenderName, appenderName, ...
|
||||
* </pre>
|
||||
*
|
||||
* This syntax means that an optional <em>LogLevel value</em> can
|
||||
* be supplied followed by appender names separated by commas.
|
||||
*
|
||||
* The LogLevel value can consist of the string values FATAL,
|
||||
* ERROR, WARN, INFO, DEBUG or a <em>custom LogLevel</em> value.
|
||||
*
|
||||
* If a LogLevel value is specified, then the root LogLevel is set
|
||||
* to the corresponding LogLevel. If no LogLevel value is specified,
|
||||
* then the root LogLevel remains untouched.
|
||||
*
|
||||
* The root logger can be assigned multiple appenders.
|
||||
*
|
||||
* Each <i>appenderName</i> (separated by commas) will be added to
|
||||
* the root logger. The named appender is defined using the
|
||||
* appender syntax defined above.
|
||||
*
|
||||
* For non-root loggers the syntax is almost the same:
|
||||
* <pre>
|
||||
* log4cplus.logger.logger_name=[LogLevel|INHERITED], appenderName, appenderName, ...
|
||||
* </pre>
|
||||
*
|
||||
* The meaning of the optional LogLevel value is discussed above
|
||||
* in relation to the root logger. In addition however, the value
|
||||
* INHERITED can be specified meaning that the named logger should
|
||||
* inherit its LogLevel from the logger hierarchy.
|
||||
*
|
||||
* By default loggers inherit their LogLevel from the
|
||||
* hierarchy. However, if you set the LogLevel of a logger and
|
||||
* later decide that that logger should inherit its LogLevel, then
|
||||
* you should specify INHERITED as the value for the LogLevel value.
|
||||
*
|
||||
* Similar to the root logger syntax, each <i>appenderName</i>
|
||||
* (separated by commas) will be attached to the named logger.
|
||||
*
|
||||
* See the <a href="../../../../manual.html#additivity">appender
|
||||
* additivity rule</a> in the user manual for the meaning of the
|
||||
* <code>additivity</code> flag.
|
||||
*
|
||||
* The user can override any of the {@link
|
||||
* Hierarchy#disable} family of methods by setting the a key
|
||||
* "log4cplus.disableOverride" to <code>true</code> or any value other
|
||||
* than false. As in <pre>log4cplus.disableOverride=true </pre>
|
||||
*
|
||||
* <h3>Global configuration</h3>
|
||||
*
|
||||
* Property <pre>log4cplus.threadPoolSize</pre> can be used to adjust
|
||||
* size of log4cplus' internal thread pool.
|
||||
*
|
||||
* <h3>Example</h3>
|
||||
*
|
||||
* An example configuration is given below.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* # Set options for appender named "A1".
|
||||
* # Appender "A1" will be a SyslogAppender
|
||||
* log4cplus.appender.A1=log4cplus::SyslogAppender
|
||||
*
|
||||
* # The syslog daemon resides on www.abc.net
|
||||
* log4cplus.appender.A1.SyslogHost=www.abc.net
|
||||
*
|
||||
* # A1's layout is a PatternLayout, using the conversion pattern
|
||||
* # <b>%r %-5p %c{2} %M.%L %x - %m\n</b>. Thus, the log output will
|
||||
* # include # the relative time since the start of the application in
|
||||
* # milliseconds, followed by the LogLevel of the log request,
|
||||
* # followed by the two rightmost components of the logger name,
|
||||
* # followed by the callers method name, followed by the line number,
|
||||
* # the nested disgnostic context and finally the message itself.
|
||||
* # Refer to the documentation of {@link PatternLayout} for further information
|
||||
* # on the syntax of the ConversionPattern key.
|
||||
* log4cplus.appender.A1.layout=log4cplus::PatternLayout
|
||||
* log4cplus.appender.A1.layout.ConversionPattern=%-4r %-5p %c{2} %M.%L %x - %m\n
|
||||
*
|
||||
* # Set options for appender named "A2"
|
||||
* # A2 should be a RollingFileAppender, with maximum file size of 10 MB
|
||||
* # using at most one backup file. A2's layout is TTCC, using the
|
||||
* # ISO8061 date format with context printing enabled.
|
||||
* log4cplus.appender.A2=log4cplus::RollingFileAppender
|
||||
* log4cplus.appender.A2.MaxFileSize=10MB
|
||||
* log4cplus.appender.A2.MaxBackupIndex=1
|
||||
* log4cplus.appender.A2.layout=log4cplus::TTCCLayout
|
||||
* log4cplus.appender.A2.layout.ContextPrinting=true
|
||||
* log4cplus.appender.A2.layout.DateFormat=ISO8601
|
||||
*
|
||||
* # Root logger set to DEBUG using the A2 appender defined above.
|
||||
* log4cplus.rootLogger=DEBUG, A2
|
||||
*
|
||||
* # Logger definitions:
|
||||
* # The SECURITY logger inherits is LogLevel from root. However, it's output
|
||||
* # will go to A1 appender defined above. It's additivity is non-cumulative.
|
||||
* log4cplus.logger.SECURITY=INHERIT, A1
|
||||
* log4cplus.additivity.SECURITY=false
|
||||
*
|
||||
* # Only warnings or above will be logged for the logger "SECURITY.access".
|
||||
* # Output will go to A1.
|
||||
* log4cplus.logger.SECURITY.access=WARN
|
||||
*
|
||||
*
|
||||
* # The logger "class.of.the.day" inherits its LogLevel from the
|
||||
* # logger hierarchy. Output will go to the appender's of the root
|
||||
* # logger, A2 in this case.
|
||||
* log4cplus.logger.class.of.the.day=INHERIT
|
||||
* </pre>
|
||||
*
|
||||
* Refer to the <b>setOption</b> method in each Appender and
|
||||
* Layout for class specific options.
|
||||
*
|
||||
* Use the <code>#</code> character at the beginning of a line
|
||||
* for comments.
|
||||
*/
|
||||
virtual void configure();
|
||||
|
||||
/**
|
||||
* \return The return value is reference to Properties
|
||||
* container of properties with the <code>"log4cplus."</code>
|
||||
* prefix removed and references to other properties and/or
|
||||
* environment variables expanded.
|
||||
*/
|
||||
log4cplus::helpers::Properties const & getProperties () const;
|
||||
|
||||
/**
|
||||
* \return The return value is a reference to log4cplus::tstring
|
||||
* containing filename of properties source file. It will be
|
||||
* string "UNAVAILABLE" if the PropertyConfigurator instance has been
|
||||
* constructed using one of the other constructors that do not take
|
||||
* filename as parameter.
|
||||
*/
|
||||
log4cplus::tstring const & getPropertyFilename () const;
|
||||
|
||||
protected:
|
||||
// Methods
|
||||
void init(); // called by the ctor
|
||||
void reconfigure();
|
||||
void replaceEnvironVariables();
|
||||
void configureLoggers();
|
||||
void configureLogger(log4cplus::Logger logger, const log4cplus::tstring& config);
|
||||
void configureAppenders();
|
||||
void configureAdditivity();
|
||||
|
||||
virtual Logger getLogger(const log4cplus::tstring& name);
|
||||
virtual void addAppender(Logger &logger, log4cplus::SharedAppenderPtr& appender);
|
||||
|
||||
// Types
|
||||
typedef std::map<log4cplus::tstring, log4cplus::SharedAppenderPtr> AppenderMap;
|
||||
|
||||
// Data
|
||||
Hierarchy& h;
|
||||
log4cplus::tstring propertyFilename;
|
||||
log4cplus::helpers::Properties properties;
|
||||
AppenderMap appenders;
|
||||
unsigned flags;
|
||||
|
||||
private:
|
||||
// Disable copy
|
||||
PropertyConfigurator(const PropertyConfigurator&);
|
||||
PropertyConfigurator& operator=(PropertyConfigurator&);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Use this class to quickly configure the package. For file based
|
||||
* configuration see PropertyConfigurator. BasicConfigurator
|
||||
* automatically attaches ConsoleAppender to
|
||||
* <code>rootLogger</code>, with output going to standard output,
|
||||
* using DEBUG LogLevel value. The additional parameter
|
||||
* logToStdErr may redirect the output to standard error.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT BasicConfigurator : public PropertyConfigurator {
|
||||
public:
|
||||
// ctor and dtor
|
||||
BasicConfigurator(Hierarchy& h = Logger::getDefaultHierarchy(),
|
||||
bool logToStdErr = false);
|
||||
virtual ~BasicConfigurator();
|
||||
|
||||
/**
|
||||
* This method eliminates the need to create a temporary
|
||||
* <code>BasicConfigurator</code> object to configure log4cplus.
|
||||
* It is equivalent to the following:<br>
|
||||
* <code><pre>
|
||||
* BasicConfigurator config;
|
||||
* config.configure();
|
||||
* </pre></code>
|
||||
*/
|
||||
static void doConfigure(Hierarchy& h = Logger::getDefaultHierarchy(),
|
||||
bool logToStdErr = false);
|
||||
|
||||
//! Property name for disable override.
|
||||
static log4cplus::tstring const DISABLE_OVERRIDE_KEY;
|
||||
|
||||
private:
|
||||
// Disable copy
|
||||
BasicConfigurator(const BasicConfigurator&);
|
||||
BasicConfigurator& operator=(BasicConfigurator&);
|
||||
};
|
||||
|
||||
|
||||
#if !defined(LOG4CPLUS_SINGLE_THREADED)
|
||||
// Forward Declarations
|
||||
class ConfigurationWatchDogThread;
|
||||
|
||||
|
||||
class LOG4CPLUS_EXPORT ConfigureAndWatchThread {
|
||||
public:
|
||||
// ctor and dtor
|
||||
ConfigureAndWatchThread(const log4cplus::tstring& propertyFile,
|
||||
unsigned int millis = 60 * 1000);
|
||||
virtual ~ConfigureAndWatchThread();
|
||||
|
||||
private:
|
||||
// Disallow copying of instances of this class
|
||||
ConfigureAndWatchThread(const ConfigureAndWatchThread&);
|
||||
ConfigureAndWatchThread& operator=(const ConfigureAndWatchThread&);
|
||||
|
||||
// Data
|
||||
ConfigurationWatchDogThread * watchDogThread;
|
||||
};
|
||||
#endif
|
||||
|
||||
} // end namespace log4cplus
|
||||
|
||||
#endif // LOG4CPLUS_CONFIGURATOR_HEADER_
|
|
@ -0,0 +1,85 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: consoleappender.h
|
||||
// Created: 6/2001
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2001-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_CONSOLE_APPENDER_HEADER_
|
||||
#define LOG4CPLUS_CONSOLE_APPENDER_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/appender.h>
|
||||
|
||||
namespace log4cplus {
|
||||
/**
|
||||
* ConsoleAppender appends log events to <code>std::cout</code> or
|
||||
* <code>std::cerr</code> using a layout specified by the
|
||||
* user. The default target is <code>std::cout</code>.
|
||||
*
|
||||
* <h3>Properties</h3>
|
||||
* <dl>
|
||||
* <dt><tt>logToStdErr</tt></dt>
|
||||
* <dd>When it is set true, the output stream will be
|
||||
* <code>std::cerr</code> instead of <code>std::cout</code>.</dd>
|
||||
*
|
||||
* <dt><tt>ImmediateFlush</tt></dt>
|
||||
* <dd>When it is set true, output stream will be flushed after
|
||||
* each appended event.</dd>
|
||||
*
|
||||
* </dl>
|
||||
* \sa Appender
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT ConsoleAppender : public Appender {
|
||||
public:
|
||||
// Ctors
|
||||
ConsoleAppender(bool logToStdErr = false, bool immediateFlush = false);
|
||||
ConsoleAppender(const log4cplus::helpers::Properties & properties);
|
||||
|
||||
// Dtor
|
||||
~ConsoleAppender();
|
||||
|
||||
// Methods
|
||||
virtual void close();
|
||||
|
||||
//! This mutex is used by ConsoleAppender and helpers::LogLog
|
||||
//! classes to synchronize output to console.
|
||||
static log4cplus::thread::Mutex const & getOutputMutex();
|
||||
|
||||
protected:
|
||||
virtual void append(const spi::InternalLoggingEvent& event);
|
||||
|
||||
// Data
|
||||
bool logToStdErr;
|
||||
/**
|
||||
* Immediate flush means that the underlying output stream
|
||||
* will be flushed at the end of each append operation.
|
||||
*/
|
||||
bool immediateFlush;
|
||||
};
|
||||
|
||||
} // end namespace log4cplus
|
||||
|
||||
#endif // LOG4CPLUS_CONSOLE_APPENDER_HEADER_
|
||||
|
|
@ -0,0 +1,428 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: fileappender.h
|
||||
// Created: 6/2001
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2001-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_FILE_APPENDER_HEADER_
|
||||
#define LOG4CPLUS_FILE_APPENDER_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/appender.h>
|
||||
#include <log4cplus/fstreams.h>
|
||||
#include <log4cplus/helpers/timehelper.h>
|
||||
#include <log4cplus/helpers/lockfile.h>
|
||||
#include <fstream>
|
||||
#include <locale>
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace log4cplus
|
||||
{
|
||||
|
||||
/**
|
||||
* Base class for Appenders writing log events to a file.
|
||||
* It is constructed with uninitialized file object, so all
|
||||
* classes derived from FileAppenderBase _must_ call init() method.
|
||||
*
|
||||
* <h3>Properties</h3>
|
||||
* <dl>
|
||||
* <dt><tt>File</tt></dt>
|
||||
* <dd>This property specifies output file name.</dd>
|
||||
*
|
||||
* <dt><tt>ImmediateFlush</tt></dt>
|
||||
* <dd>When it is set true, output stream will be flushed after
|
||||
* each appended event.</dd>
|
||||
*
|
||||
* <dt><tt>Append</tt></dt>
|
||||
* <dd>When it is set true, output file will be appended to
|
||||
* instead of being truncated at opening.</dd>
|
||||
*
|
||||
* <dt><tt>ReopenDelay</tt></dt>
|
||||
* <dd>This property sets a delay after which the appender will try
|
||||
* to reopen log file again, after last logging failure.
|
||||
* </dd>
|
||||
*
|
||||
* <dt><tt>BufferSize</tt></dt>
|
||||
* <dd>Non-zero value of this property sets up buffering of output
|
||||
* stream using a buffer of given size.
|
||||
* </dd>
|
||||
*
|
||||
* <dt><tt>UseLockFile</tt></dt>
|
||||
* <dd>Set this property to <tt>true</tt> if you want your output
|
||||
* to go into a log file shared by multiple processes. When this
|
||||
* property is set to true then log4cplus uses OS specific
|
||||
* facilities (e.g., <code>lockf()</code>) to provide
|
||||
* inter-process file locking.
|
||||
* \sa Appender
|
||||
* </dd>
|
||||
*
|
||||
* <dt><tt>LockFile</tt></dt>
|
||||
* <dd>This property specifies lock file, file used for
|
||||
* inter-process synchronization of log file access. When this
|
||||
* property is not specified, the value is derived from
|
||||
* <tt>File</tt> property by addition of ".lock" suffix. The
|
||||
* property is only used when <tt>UseLockFile</tt> is set to true.
|
||||
* \sa Appender
|
||||
* </dd>
|
||||
*
|
||||
* <dt><tt>Locale</tt></dt>
|
||||
* <dd>This property specifies a locale name that will be imbued
|
||||
* into output stream. Locale can be specified either by system
|
||||
* specific locale name, e.g., <tt>en_US.UTF-8</tt>, or by one of
|
||||
* four recognized keywords: <tt>GLOBAL</tt>, <tt>DEFAULT</tt>
|
||||
* (which is an alias for <tt>GLOBAL</tt>), <tt>USER</tt> and
|
||||
* <tt>CLASSIC</tt>. When specified locale is not available,
|
||||
* <tt>GLOBAL</tt> is used instead. It is possible to register
|
||||
* additional locale keywords by registering an instance of
|
||||
* <code>spi::LocaleFactory</code> in
|
||||
* <code>spi::LocaleFactoryRegistry</code>.
|
||||
* \sa spi::getLocaleFactoryRegistry()
|
||||
* </dd>
|
||||
*
|
||||
* <dt><tt>CreateDirs</tt></dt>
|
||||
* <dd>Set this property to <tt>true</tt> if you want to create
|
||||
* missing directories in path leading to log file and lock file.
|
||||
* </dd>
|
||||
*
|
||||
* <dt><tt>TextMode</tt></dt>
|
||||
* <dd>Set this property to <tt>Binary</tt> if the underlying stream should
|
||||
* not translate EOLs to OS specific character sequence. The default value
|
||||
* is <tt>Text</tt> and the underlying stream will be opened in text
|
||||
* mode.</dd>
|
||||
* </dl>
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT FileAppenderBase : public Appender {
|
||||
public:
|
||||
// Methods
|
||||
virtual void close();
|
||||
|
||||
//! Redefine default locale for output stream. It may be a good idea to
|
||||
//! provide UTF-8 locale in case UNICODE macro is defined.
|
||||
virtual std::locale imbue(std::locale const& loc);
|
||||
|
||||
//! \returns Locale imbued in fstream.
|
||||
virtual std::locale getloc () const;
|
||||
|
||||
protected:
|
||||
// Ctors
|
||||
FileAppenderBase(const log4cplus::tstring& filename,
|
||||
std::ios_base::openmode mode = std::ios_base::trunc,
|
||||
bool immediateFlush = true,
|
||||
bool createDirs = false);
|
||||
FileAppenderBase(const log4cplus::helpers::Properties& properties,
|
||||
std::ios_base::openmode mode = std::ios_base::trunc);
|
||||
|
||||
void init();
|
||||
|
||||
virtual void append(const spi::InternalLoggingEvent& event);
|
||||
|
||||
virtual void open(std::ios_base::openmode mode);
|
||||
bool reopen();
|
||||
|
||||
// Data
|
||||
/**
|
||||
* Immediate flush means that the underlying writer or output stream
|
||||
* will be flushed at the end of each append operation. Immediate
|
||||
* flush is slower but ensures that each append request is actually
|
||||
* written. If <code>immediateFlush</code> is set to
|
||||
* <code>false</code>, then there is a good chance that the last few
|
||||
* logs events are not actually written to persistent media if and
|
||||
* when the application crashes.
|
||||
*
|
||||
* The <code>immediateFlush</code> variable is set to
|
||||
* <code>true</code> by default.
|
||||
*/
|
||||
bool immediateFlush;
|
||||
|
||||
/**
|
||||
* When this variable is true, FileAppender will try to create
|
||||
* missing directories in path leading to log file.
|
||||
*
|
||||
* The `createDirs` variable is set to `false` by default.
|
||||
*/
|
||||
bool createDirs;
|
||||
|
||||
/**
|
||||
* When any append operation fails, <code>reopenDelay</code> says
|
||||
* for how many seconds the next attempt to re-open the log file and
|
||||
* resume logging will be delayed. If <code>reopenDelay</code> is zero,
|
||||
* each failed append operation will cause log file to be re-opened.
|
||||
* By default, <code>reopenDelay</code> is 1 second.
|
||||
*/
|
||||
int reopenDelay;
|
||||
|
||||
unsigned long bufferSize;
|
||||
std::unique_ptr<log4cplus::tchar[]> buffer;
|
||||
|
||||
log4cplus::tofstream out;
|
||||
log4cplus::tstring filename;
|
||||
log4cplus::tstring localeName;
|
||||
log4cplus::tstring lockFileName;
|
||||
std::ios_base::openmode fileOpenMode;
|
||||
|
||||
log4cplus::helpers::Time reopen_time;
|
||||
|
||||
private:
|
||||
// Disallow copying of instances of this class
|
||||
FileAppenderBase(const FileAppenderBase&);
|
||||
FileAppenderBase& operator=(const FileAppenderBase&);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Appends log events to a file.
|
||||
*
|
||||
* <h3>Properties</h3>
|
||||
* <p>It has no properties additional to {@link FileAppenderBase}.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT FileAppender : public FileAppenderBase {
|
||||
public:
|
||||
// Ctors
|
||||
FileAppender(const log4cplus::tstring& filename,
|
||||
std::ios_base::openmode mode = std::ios_base::trunc,
|
||||
bool immediateFlush = true,
|
||||
bool createDirs = false);
|
||||
FileAppender(const log4cplus::helpers::Properties& properties,
|
||||
std::ios_base::openmode mode = std::ios_base::trunc);
|
||||
|
||||
// Dtor
|
||||
virtual ~FileAppender();
|
||||
|
||||
protected:
|
||||
void init();
|
||||
};
|
||||
|
||||
typedef helpers::SharedObjectPtr<FileAppender> SharedFileAppenderPtr;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* RollingFileAppender extends FileAppender to backup the log
|
||||
* files when they reach a certain size.
|
||||
*
|
||||
* <h3>Properties</h3>
|
||||
* <p>Properties additional to {@link FileAppender}'s properties:
|
||||
*
|
||||
* <dl>
|
||||
* <dt><tt>MaxFileSize</tt></dt>
|
||||
* <dd>This property specifies maximal size of output file. The
|
||||
* value is in bytes. It is possible to use <tt>MB</tt> and
|
||||
* <tt>KB</tt> suffixes to specify the value in megabytes or
|
||||
* kilobytes instead.</dd>
|
||||
*
|
||||
* <dt><tt>MaxBackupIndex</tt></dt>
|
||||
* <dd>This property limits the number of backup output
|
||||
* files; e.g. how many <tt>log.1</tt>, <tt>log.2</tt> etc. files
|
||||
* will be kept.</dd>
|
||||
* </dl>
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT RollingFileAppender : public FileAppender {
|
||||
public:
|
||||
// Ctors
|
||||
RollingFileAppender(const log4cplus::tstring& filename,
|
||||
long maxFileSize = 10*1024*1024, // 10 MB
|
||||
int maxBackupIndex = 1,
|
||||
bool immediateFlush = true,
|
||||
bool createDirs = false);
|
||||
RollingFileAppender(const log4cplus::helpers::Properties& properties);
|
||||
|
||||
// Dtor
|
||||
virtual ~RollingFileAppender();
|
||||
|
||||
protected:
|
||||
virtual void append(const spi::InternalLoggingEvent& event);
|
||||
void rollover(bool alreadyLocked = false);
|
||||
|
||||
// Data
|
||||
long maxFileSize;
|
||||
int maxBackupIndex;
|
||||
|
||||
private:
|
||||
LOG4CPLUS_PRIVATE void init(long maxFileSize, int maxBackupIndex);
|
||||
};
|
||||
|
||||
|
||||
typedef helpers::SharedObjectPtr<RollingFileAppender>
|
||||
SharedRollingFileAppenderPtr;
|
||||
|
||||
|
||||
enum DailyRollingFileSchedule { MONTHLY, WEEKLY, DAILY,
|
||||
TWICE_DAILY, HOURLY, MINUTELY};
|
||||
|
||||
/**
|
||||
* DailyRollingFileAppender extends {@link FileAppender} so that the
|
||||
* underlying file is rolled over at a user chosen frequency.
|
||||
*
|
||||
* <h3>Properties</h3>
|
||||
* <p>Properties additional to {@link FileAppender}'s properties:
|
||||
*
|
||||
* <dl>
|
||||
* <dt><tt>Schedule</tt></dt>
|
||||
* <dd>This property specifies rollover schedule. The possible
|
||||
* values are <tt>MONTHLY</tt>, <tt>WEEKLY</tt>, <tt>DAILY</tt>,
|
||||
* <tt>TWICE_DAILY</tt>, <tt>HOURLY</tt> and
|
||||
* <tt>MINUTELY</tt>.</dd>
|
||||
*
|
||||
* <dt><tt>MaxBackupIndex</tt></dt>
|
||||
* <dd>This property limits how many backup files are kept per
|
||||
* single logging period; e.g. how many <tt>log.2009-11-07.1</tt>,
|
||||
* <tt>log.2009-11-07.2</tt> etc. files are kept.</dd>
|
||||
*
|
||||
* <dt><tt>RollOnClose</tt></dt>
|
||||
* <dd>This property specifies whether to rollover log files upon
|
||||
* shutdown. By default it's set to <code>true</code> to retain compatibility
|
||||
* with legacy code, however it may lead to undesired behaviour
|
||||
* as described in the github issue #120.</dd>
|
||||
*
|
||||
* <dt><tt>DatePattern</tt></dt>
|
||||
* <dd>This property specifies filename suffix pattern to use for
|
||||
* periodical backups of the logfile. The patern should be in
|
||||
* format supported by {@link log4cplus::helpers::Time::getFormatterTime()}</code>.
|
||||
* Please notice that the format of the pattern is similar but not identical
|
||||
* to the one used for this option in the corresponding Log4J class.
|
||||
* If the property isn't specified a reasonable default for a given
|
||||
* schedule type is used.</dd>
|
||||
*
|
||||
* </dl>
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT DailyRollingFileAppender : public FileAppender {
|
||||
public:
|
||||
// Ctors
|
||||
DailyRollingFileAppender(const log4cplus::tstring& filename,
|
||||
DailyRollingFileSchedule schedule = DAILY,
|
||||
bool immediateFlush = true,
|
||||
int maxBackupIndex = 10,
|
||||
bool createDirs = false,
|
||||
bool rollOnClose = true,
|
||||
const log4cplus::tstring& datePattern = log4cplus::tstring());
|
||||
DailyRollingFileAppender(const log4cplus::helpers::Properties& properties);
|
||||
|
||||
// Dtor
|
||||
virtual ~DailyRollingFileAppender();
|
||||
|
||||
// Methods
|
||||
virtual void close();
|
||||
|
||||
protected:
|
||||
virtual void append(const spi::InternalLoggingEvent& event);
|
||||
void rollover(bool alreadyLocked = false);
|
||||
log4cplus::helpers::Time calculateNextRolloverTime(const log4cplus::helpers::Time& t) const;
|
||||
log4cplus::tstring getFilename(const log4cplus::helpers::Time& t) const;
|
||||
|
||||
// Data
|
||||
DailyRollingFileSchedule schedule;
|
||||
log4cplus::tstring scheduledFilename;
|
||||
log4cplus::helpers::Time nextRolloverTime;
|
||||
int maxBackupIndex;
|
||||
bool rollOnClose;
|
||||
log4cplus::tstring datePattern;
|
||||
|
||||
private:
|
||||
LOG4CPLUS_PRIVATE void init(DailyRollingFileSchedule schedule);
|
||||
};
|
||||
|
||||
typedef helpers::SharedObjectPtr<DailyRollingFileAppender>
|
||||
SharedDailyRollingFileAppenderPtr;
|
||||
|
||||
|
||||
/**
|
||||
* TimeBasedRollingFileAppender extends {@link FileAppenderBase} so that
|
||||
* the underlying file is rolled over at a user chosen frequency while also
|
||||
* keeping in check a total maximum number of produced files.
|
||||
*
|
||||
* <h3>Properties</h3>
|
||||
* <p>Properties additional to {@link FileAppenderBase}'s properties:
|
||||
*
|
||||
* <dl>
|
||||
*
|
||||
* <dt><tt>FilenamePattern</tt></dt>
|
||||
* <dd>The mandatory fileNamePattern property defines the name of the
|
||||
* rolled-over (archived) log files. Its value should consist of the name
|
||||
* of the file, plus a suitably placed %d conversion specifier. The %d
|
||||
* conversion specifier may contain a date-and-time pattern as specified by
|
||||
* the java's SimpleDateFormat. The rollover period is inferred from the
|
||||
* value of fileNamePattern.</dd>
|
||||
*
|
||||
* <dt><tt>MaxHistory</tt></dt>
|
||||
* <dd>The optional maxHistory property controls the maximum number of
|
||||
* archive files to keep, deleting older files.</dd>
|
||||
*
|
||||
* <dt><tt>CleanHistoryOnStart</tt></dt>
|
||||
* <dd>If set to true, archive removal will be executed on appender start
|
||||
* up. By default this property is set to false. </dd>
|
||||
*
|
||||
* <dt><tt>RollOnClose</tt></dt>
|
||||
* <dd>This property specifies whether to rollover log files upon
|
||||
* shutdown. By default it's set to <code>true</code> to retain compatibility
|
||||
* with legacy code, however it may lead to undesired behaviour
|
||||
* as described in the github issue #120.</dd>
|
||||
*
|
||||
* </dl>
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT TimeBasedRollingFileAppender : public FileAppenderBase {
|
||||
public:
|
||||
// Ctors
|
||||
TimeBasedRollingFileAppender(const tstring& filename = LOG4CPLUS_TEXT(""),
|
||||
const tstring& filenamePattern = LOG4CPLUS_TEXT("%d.log"),
|
||||
int maxHistory = 10,
|
||||
bool cleanHistoryOnStart = false,
|
||||
bool immediateFlush = true,
|
||||
bool createDirs = false,
|
||||
bool rollOnClose = true);
|
||||
TimeBasedRollingFileAppender(const helpers::Properties& properties);
|
||||
|
||||
// Dtor
|
||||
~TimeBasedRollingFileAppender();
|
||||
|
||||
protected:
|
||||
void append(const spi::InternalLoggingEvent& event);
|
||||
void open(std::ios_base::openmode mode);
|
||||
void close();
|
||||
void rollover(bool alreadyLocked = false);
|
||||
void clean(helpers::Time time);
|
||||
helpers::Time::duration getRolloverPeriodDuration() const;
|
||||
helpers::Time calculateNextRolloverTime(const helpers::Time& t) const;
|
||||
|
||||
// Data
|
||||
tstring filenamePattern;
|
||||
DailyRollingFileSchedule schedule;
|
||||
tstring scheduledFilename;
|
||||
int maxHistory;
|
||||
bool cleanHistoryOnStart;
|
||||
log4cplus::helpers::Time lastHeartBeat;
|
||||
log4cplus::helpers::Time nextRolloverTime;
|
||||
bool rollOnClose;
|
||||
|
||||
private:
|
||||
LOG4CPLUS_PRIVATE void init();
|
||||
};
|
||||
|
||||
typedef helpers::SharedObjectPtr<TimeBasedRollingFileAppender>
|
||||
SharedTimeBasedRollingFileAppenderPtr;
|
||||
|
||||
} // end namespace log4cplus
|
||||
|
||||
#endif // LOG4CPLUS_FILE_APPENDER_HEADER_
|
|
@ -0,0 +1,56 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: fstreams.h
|
||||
// Created: 4/2003
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2003-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_FSTREAMS_HEADER_
|
||||
#define LOG4CPLUS_FSTREAMS_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/tchar.h>
|
||||
#include <iosfwd>
|
||||
|
||||
|
||||
namespace log4cplus
|
||||
{
|
||||
|
||||
|
||||
typedef std::basic_ofstream<tchar> tofstream;
|
||||
typedef std::basic_ifstream<tchar> tifstream;
|
||||
|
||||
//! \def LOG4CPLUS_FSTREAM_PREFERED_FILE_NAME(X)
|
||||
//! \brief Expands into expression that picks the right type for
|
||||
//! std::fstream file name parameter.
|
||||
#if defined (LOG4CPLUS_FSTREAM_ACCEPTS_WCHAR_T) && defined (UNICODE)
|
||||
# define LOG4CPLUS_FSTREAM_PREFERED_FILE_NAME(X) (X)
|
||||
#else
|
||||
# define LOG4CPLUS_FSTREAM_PREFERED_FILE_NAME(X) (LOG4CPLUS_TSTRING_TO_STRING(X))
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // LOG4CPLUS_FSTREAMS_HEADER_
|
|
@ -0,0 +1,119 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: appenderattachableimpl.h
|
||||
// Created: 6/2001
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2001-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_HELPERS_APPENDER_ATTACHABLE_IMPL_HEADER_
|
||||
#define LOG4CPLUS_HELPERS_APPENDER_ATTACHABLE_IMPL_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/tstring.h>
|
||||
#include <log4cplus/helpers/pointer.h>
|
||||
#include <log4cplus/spi/appenderattachable.h>
|
||||
#include <log4cplus/thread/syncprims.h>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace log4cplus {
|
||||
namespace helpers {
|
||||
|
||||
/**
|
||||
* This Interface is for attaching Appenders to objects.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT AppenderAttachableImpl
|
||||
: public log4cplus::spi::AppenderAttachable
|
||||
{
|
||||
public:
|
||||
// Data
|
||||
thread::Mutex appender_list_mutex;
|
||||
|
||||
// Ctors
|
||||
AppenderAttachableImpl();
|
||||
|
||||
// Dtor
|
||||
virtual ~AppenderAttachableImpl();
|
||||
|
||||
// Methods
|
||||
/**
|
||||
* Add an appender. If the appender is already in the list in
|
||||
* won't be added again.
|
||||
*/
|
||||
virtual void addAppender(SharedAppenderPtr newAppender);
|
||||
|
||||
/**
|
||||
* Get all previously added appenders as an vectory.
|
||||
*/
|
||||
virtual SharedAppenderPtrList getAllAppenders();
|
||||
|
||||
/**
|
||||
* Look for an attached appender named as <code>name</code>.
|
||||
*
|
||||
* Return the appender with that name if in the list. Return null
|
||||
* otherwise.
|
||||
*/
|
||||
virtual SharedAppenderPtr getAppender(const log4cplus::tstring& name);
|
||||
|
||||
/**
|
||||
* Remove all previously added appenders.
|
||||
*/
|
||||
virtual void removeAllAppenders();
|
||||
|
||||
/**
|
||||
* Remove the appender passed as parameter from the list of appenders.
|
||||
*/
|
||||
virtual void removeAppender(SharedAppenderPtr appender);
|
||||
|
||||
/**
|
||||
* Remove the appender with the name passed as parameter from the
|
||||
* list of appenders.
|
||||
*/
|
||||
virtual void removeAppender(const log4cplus::tstring& name);
|
||||
|
||||
/**
|
||||
* Call the <code>doAppend</code> method on all attached appenders.
|
||||
*/
|
||||
int appendLoopOnAppenders(const spi::InternalLoggingEvent& event) const;
|
||||
|
||||
protected:
|
||||
// Types
|
||||
typedef std::vector<SharedAppenderPtr> ListType;
|
||||
|
||||
// Data
|
||||
/** Array of appenders. */
|
||||
ListType appenderList;
|
||||
|
||||
private:
|
||||
AppenderAttachableImpl(AppenderAttachableImpl const &);
|
||||
AppenderAttachableImpl & operator = (AppenderAttachableImpl const &);
|
||||
}; // end class AppenderAttachableImpl
|
||||
|
||||
} // end namespace helpers
|
||||
} // end namespace log4cplus
|
||||
|
||||
#endif // LOG4CPLUS_HELPERS_APPENDER_ATTACHABLE_IMPL_HEADER_
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
// -*- C++ -*-
|
||||
// Copyright (C) 2013-2017, Vaclav Zeman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef LOG4CPLUS_HELPERS_CONNECTORTHREAD_H
|
||||
#define LOG4CPLUS_HELPERS_CONNECTORTHREAD_H
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/thread/syncprims.h>
|
||||
#include <log4cplus/thread/threads.h>
|
||||
#include <log4cplus/helpers/socket.h>
|
||||
|
||||
|
||||
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
|
||||
namespace log4cplus { namespace helpers {
|
||||
|
||||
|
||||
class LOG4CPLUS_EXPORT ConnectorThread;
|
||||
|
||||
//! Interface implemented by users of ConnectorThread.
|
||||
class LOG4CPLUS_EXPORT IConnectorThreadClient
|
||||
{
|
||||
protected:
|
||||
virtual ~IConnectorThreadClient ();
|
||||
|
||||
//! \return Mutex for synchronization between ConnectorThread and
|
||||
//! its client object. This is usually SharedObject::access_mutex.
|
||||
virtual thread::Mutex const & ctcGetAccessMutex () const = 0;
|
||||
|
||||
//! \return Socket variable in ConnectorThread client to maintain.
|
||||
virtual helpers::Socket & ctcGetSocket () = 0;
|
||||
|
||||
//! \return ConnectorThread client's function returning connected
|
||||
//! socket.
|
||||
virtual helpers::Socket ctcConnect () = 0;
|
||||
|
||||
//! Sets connected flag to true in ConnectorThread's client.
|
||||
virtual void ctcSetConnected () = 0;
|
||||
|
||||
friend class LOG4CPLUS_EXPORT ConnectorThread;
|
||||
};
|
||||
|
||||
|
||||
//! This class is used by SocketAppender and (remote) SysLogAppender
|
||||
//! to provide asynchronous re-connection.
|
||||
class LOG4CPLUS_EXPORT ConnectorThread
|
||||
: public thread::AbstractThread
|
||||
{
|
||||
public:
|
||||
//! \param client reference to ConnectorThread's client object
|
||||
ConnectorThread (IConnectorThreadClient & client);
|
||||
virtual ~ConnectorThread ();
|
||||
|
||||
virtual void run();
|
||||
|
||||
//! Call this function to terminate ConnectorThread. The function
|
||||
//! sets `exit_flag` and then triggers `trigger_ev` to wake up the
|
||||
//! ConnectorThread.
|
||||
void terminate ();
|
||||
|
||||
//! This function triggers (`trigger_ev`) connection check and
|
||||
//! attempt to re-connect a broken connection, when necessary.
|
||||
void trigger ();
|
||||
|
||||
protected:
|
||||
//! reference to ConnectorThread's client
|
||||
IConnectorThreadClient & ctc;
|
||||
|
||||
//! This event is the re-connection trigger.
|
||||
thread::ManualResetEvent trigger_ev;
|
||||
|
||||
//! When this variable set to true when ConnectorThread is signaled to
|
||||
bool exit_flag;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace log4cplus { namespace helpers {
|
||||
|
||||
#endif // ! defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
|
||||
#endif // LOG4CPLUS_HELPERS_CONNECTORTHREAD_H
|
|
@ -0,0 +1,59 @@
|
|||
// -*- C++ -*-
|
||||
//
|
||||
// Copyright (C) 2012-2017, Vaclav Zeman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#if ! defined (LOG4CPLUS_HELPERS_FILEINFO_H)
|
||||
#define LOG4CPLUS_HELPERS_FILEINFO_H
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/helpers/timehelper.h>
|
||||
#ifdef LOG4CPLUS_HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace log4cplus { namespace helpers {
|
||||
|
||||
//! FileInfo structure is OS independent abstraction of the
|
||||
//! <code>stat()</code> function.
|
||||
struct LOG4CPLUS_EXPORT FileInfo
|
||||
{
|
||||
helpers::Time mtime;
|
||||
bool is_link;
|
||||
off_t size;
|
||||
};
|
||||
|
||||
|
||||
//! OS independent abstraction of <code>stat()</code> function.
|
||||
LOG4CPLUS_EXPORT int getFileInfo (FileInfo * fi, tstring const & name);
|
||||
|
||||
|
||||
} } // namespace log4cplus { namespace helpers {
|
||||
|
||||
#endif // LOG4CPLUS_HELPERS_FILEINFO_H
|
|
@ -0,0 +1,69 @@
|
|||
// -*- C++ -*-
|
||||
//
|
||||
// Copyright (C) 2012-2017, Vaclav Zeman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#if ! defined (LOG4CPLUS_HELPERS_LOCKFILE_H)
|
||||
#define LOG4CPLUS_HELPERS_LOCKFILE_H
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/tstring.h>
|
||||
#include <log4cplus/thread/syncprims.h>
|
||||
|
||||
|
||||
namespace log4cplus { namespace helpers {
|
||||
|
||||
|
||||
class LOG4CPLUS_EXPORT LockFile
|
||||
{
|
||||
public:
|
||||
LockFile (tstring const & lock_file, bool create_dirs = false);
|
||||
~LockFile ();
|
||||
|
||||
void lock () const;
|
||||
void unlock () const;
|
||||
|
||||
private:
|
||||
void open (int) const;
|
||||
void close () const;
|
||||
|
||||
struct Impl;
|
||||
|
||||
tstring lock_file_name;
|
||||
Impl * data;
|
||||
bool create_dirs;
|
||||
};
|
||||
|
||||
|
||||
typedef log4cplus::thread::SyncGuard<LockFile> LockFileGuard;
|
||||
|
||||
|
||||
} } // namespace log4cplus { namespace helpers {
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_HELPERS_LOCKFILE_H
|
|
@ -0,0 +1,145 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: loglog.h
|
||||
// Created: 6/2001
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2001-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_HELPERS_LOGLOG
|
||||
#define LOG4CPLUS_HELPERS_LOGLOG
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/tstring.h>
|
||||
#include <log4cplus/streams.h>
|
||||
#include <log4cplus/thread/syncprims.h>
|
||||
|
||||
|
||||
namespace log4cplus {
|
||||
namespace helpers {
|
||||
|
||||
/**
|
||||
* This class used to output log statements from within the log4cplus package.
|
||||
*
|
||||
* Log4cplus components cannot make log4cplus logging calls. However, it is
|
||||
* sometimes useful for the user to learn about what log4cplus is
|
||||
* doing. You can enable log4cplus internal logging by defining the
|
||||
* <b>log4cplus.configDebug</b> variable.
|
||||
*
|
||||
* All log4cplus internal debug calls go to <code>cout</code>
|
||||
* where as internal error messages are sent to
|
||||
* <code>cerr</code>. All internal messages are prepended with
|
||||
* the string "log4clus: ".
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT LogLog
|
||||
{
|
||||
public:
|
||||
//! Return type of getLogLog().
|
||||
typedef LogLog * Ptr;
|
||||
|
||||
/**
|
||||
* Returns a reference to the <code>LogLog</code> singleton.
|
||||
*/
|
||||
static Ptr getLogLog();
|
||||
|
||||
|
||||
/**
|
||||
* Allows to enable/disable log4cplus internal logging.
|
||||
*/
|
||||
void setInternalDebugging(bool enabled);
|
||||
|
||||
/**
|
||||
* In quite mode no LogLog generates strictly no output, not even
|
||||
* for errors.
|
||||
*
|
||||
* @param quietMode A true for not
|
||||
*/
|
||||
void setQuietMode(bool quietMode);
|
||||
|
||||
/**
|
||||
* This method is used to output log4cplus internal debug
|
||||
* statements. Output goes to <code>std::cout</code>.
|
||||
*/
|
||||
void debug(const log4cplus::tstring& msg) const;
|
||||
void debug(tchar const * msg) const;
|
||||
|
||||
/**
|
||||
* This method is used to output log4cplus internal error
|
||||
* statements. There is no way to disable error
|
||||
* statements. Output goes to
|
||||
* <code>std::cerr</code>. Optionally, this method can
|
||||
* throw std::runtime_error exception too.
|
||||
*/
|
||||
void error(const log4cplus::tstring& msg, bool throw_flag = false) const;
|
||||
void error(tchar const * msg, bool throw_flag = false) const;
|
||||
|
||||
/**
|
||||
* This method is used to output log4cplus internal warning
|
||||
* statements. There is no way to disable warning statements.
|
||||
* Output goes to <code>std::cerr</code>.
|
||||
*/
|
||||
void warn(const log4cplus::tstring& msg) const;
|
||||
void warn(tchar const * msg) const;
|
||||
|
||||
// Public ctor and dtor to be used only by internal::DefaultContext.
|
||||
LogLog();
|
||||
virtual ~LogLog();
|
||||
|
||||
private:
|
||||
enum TriState
|
||||
{
|
||||
TriUndef = -1,
|
||||
TriFalse,
|
||||
TriTrue
|
||||
};
|
||||
|
||||
template <typename StringType>
|
||||
LOG4CPLUS_PRIVATE
|
||||
void logging_worker (tostream & os,
|
||||
bool (LogLog:: * cond) () const, tchar const *,
|
||||
StringType const &, bool throw_flag = false) const;
|
||||
|
||||
LOG4CPLUS_PRIVATE static void set_tristate_from_env (TriState *,
|
||||
tchar const * envvar);
|
||||
|
||||
LOG4CPLUS_PRIVATE bool get_quiet_mode () const;
|
||||
LOG4CPLUS_PRIVATE bool get_not_quiet_mode () const;
|
||||
LOG4CPLUS_PRIVATE bool get_debug_mode () const;
|
||||
|
||||
// Data
|
||||
mutable TriState debugEnabled;
|
||||
mutable TriState quietMode;
|
||||
thread::Mutex mutex;
|
||||
|
||||
LOG4CPLUS_PRIVATE LogLog(const LogLog&);
|
||||
LOG4CPLUS_PRIVATE LogLog & operator = (LogLog const &);
|
||||
};
|
||||
|
||||
LOG4CPLUS_EXPORT LogLog & getLogLog ();
|
||||
|
||||
} // end namespace helpers
|
||||
} // end namespace log4cplus
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_HELPERS_LOGLOG
|
||||
|
|
@ -0,0 +1,210 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: pointer.h
|
||||
// Created: 6/2001
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2001-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//
|
||||
// Note: Some of this code uses ideas from "More Effective C++" by Scott
|
||||
// Myers, Addison Wesley Longmain, Inc., (c) 1996, Chapter 29, pp. 183-213
|
||||
//
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_HELPERS_POINTERS_HEADER_
|
||||
#define LOG4CPLUS_HELPERS_POINTERS_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/thread/syncprims.h>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
#include <atomic>
|
||||
#endif
|
||||
|
||||
|
||||
namespace log4cplus {
|
||||
namespace helpers {
|
||||
|
||||
/******************************************************************************
|
||||
* Class SharedObject (from pp. 204-205) *
|
||||
******************************************************************************/
|
||||
|
||||
class LOG4CPLUS_EXPORT SharedObject
|
||||
{
|
||||
public:
|
||||
void addReference() const LOG4CPLUS_NOEXCEPT;
|
||||
void removeReference() const;
|
||||
|
||||
protected:
|
||||
// Ctor
|
||||
SharedObject()
|
||||
: access_mutex()
|
||||
, count__(0)
|
||||
{ }
|
||||
|
||||
SharedObject(const SharedObject&)
|
||||
: access_mutex()
|
||||
, count__(0)
|
||||
{ }
|
||||
|
||||
SharedObject(SharedObject &&)
|
||||
: access_mutex()
|
||||
, count__(0)
|
||||
{ }
|
||||
|
||||
// Dtor
|
||||
virtual ~SharedObject();
|
||||
|
||||
// Operators
|
||||
SharedObject& operator=(const SharedObject&) LOG4CPLUS_NOEXCEPT { return *this; }
|
||||
SharedObject& operator=(SharedObject &&) LOG4CPLUS_NOEXCEPT { return *this; }
|
||||
|
||||
public:
|
||||
thread::Mutex access_mutex;
|
||||
|
||||
private:
|
||||
#if defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
typedef unsigned count_type;
|
||||
#else
|
||||
typedef std::atomic<unsigned> count_type;
|
||||
#endif
|
||||
mutable count_type count__;
|
||||
};
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Template Class SharedObjectPtr (from pp. 203, 206) *
|
||||
******************************************************************************/
|
||||
template<class T>
|
||||
class SharedObjectPtr
|
||||
{
|
||||
public:
|
||||
// Ctor
|
||||
explicit
|
||||
SharedObjectPtr(T* realPtr = 0) LOG4CPLUS_NOEXCEPT
|
||||
: pointee(realPtr)
|
||||
{
|
||||
addref ();
|
||||
}
|
||||
|
||||
SharedObjectPtr(const SharedObjectPtr& rhs) LOG4CPLUS_NOEXCEPT
|
||||
: pointee(rhs.pointee)
|
||||
{
|
||||
addref ();
|
||||
}
|
||||
|
||||
SharedObjectPtr(SharedObjectPtr && rhs) LOG4CPLUS_NOEXCEPT
|
||||
: pointee (std::move (rhs.pointee))
|
||||
{
|
||||
rhs.pointee = 0;
|
||||
}
|
||||
|
||||
SharedObjectPtr & operator = (SharedObjectPtr && rhs) LOG4CPLUS_NOEXCEPT
|
||||
{
|
||||
rhs.swap (*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Dtor
|
||||
~SharedObjectPtr()
|
||||
{
|
||||
if (pointee)
|
||||
pointee->removeReference();
|
||||
}
|
||||
|
||||
// Operators
|
||||
bool operator==(const SharedObjectPtr& rhs) const
|
||||
{ return (pointee == rhs.pointee); }
|
||||
bool operator!=(const SharedObjectPtr& rhs) const
|
||||
{ return (pointee != rhs.pointee); }
|
||||
bool operator==(const T* rhs) const { return (pointee == rhs); }
|
||||
bool operator!=(const T* rhs) const { return (pointee != rhs); }
|
||||
T* operator->() const {assert (pointee); return pointee; }
|
||||
T& operator*() const {assert (pointee); return *pointee; }
|
||||
|
||||
SharedObjectPtr& operator=(const SharedObjectPtr& rhs)
|
||||
{
|
||||
return this->operator = (rhs.pointee);
|
||||
}
|
||||
|
||||
SharedObjectPtr& operator=(T* rhs)
|
||||
{
|
||||
SharedObjectPtr<T> (rhs).swap (*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Methods
|
||||
T* get() const { return pointee; }
|
||||
|
||||
void swap (SharedObjectPtr & other) LOG4CPLUS_NOEXCEPT
|
||||
{
|
||||
std::swap (pointee, other.pointee);
|
||||
}
|
||||
|
||||
typedef T * (SharedObjectPtr:: * unspec_bool_type) () const;
|
||||
operator unspec_bool_type () const
|
||||
{
|
||||
return pointee ? &SharedObjectPtr::get : 0;
|
||||
}
|
||||
|
||||
bool operator ! () const
|
||||
{
|
||||
return ! pointee;
|
||||
}
|
||||
|
||||
private:
|
||||
// Methods
|
||||
void addref() const LOG4CPLUS_NOEXCEPT
|
||||
{
|
||||
if (pointee)
|
||||
pointee->addReference();
|
||||
}
|
||||
|
||||
// Data
|
||||
T* pointee;
|
||||
};
|
||||
|
||||
|
||||
//! Boost `intrusive_ptr` helpers.
|
||||
//! @{
|
||||
inline
|
||||
void
|
||||
intrusive_ptr_add_ref (SharedObject const * so)
|
||||
{
|
||||
so->addReference();
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
intrusive_ptr_release (SharedObject const * so)
|
||||
{
|
||||
so->removeReference();
|
||||
}
|
||||
//! @}
|
||||
|
||||
} // end namespace helpers
|
||||
} // end namespace log4cplus
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_HELPERS_POINTERS_HEADER_
|
|
@ -0,0 +1,162 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: property.h
|
||||
// Created: 2/2002
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2002-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_HELPERS_PROPERTY_HEADER_
|
||||
#define LOG4CPLUS_HELPERS_PROPERTY_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/streams.h>
|
||||
#include <log4cplus/tstring.h>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace log4cplus {
|
||||
namespace helpers {
|
||||
|
||||
//! \sa log4cplus::PropertyConfigurator
|
||||
class LOG4CPLUS_EXPORT Properties {
|
||||
public:
|
||||
enum PFlags
|
||||
{
|
||||
// These encoding related options occupy 2 bits of the flags
|
||||
// and are mutually exclusive. These flags are synchronized
|
||||
// with PCFlags in PropertyConfigurator.
|
||||
|
||||
fEncodingShift = 3
|
||||
, fEncodingMask = 0x3
|
||||
, fUnspecEncoding = (0 << fEncodingShift)
|
||||
#if defined (LOG4CPLUS_HAVE_CODECVT_UTF8_FACET) && defined (UNICODE)
|
||||
, fUTF8 = (1 << fEncodingShift)
|
||||
#endif
|
||||
#if (defined (LOG4CPLUS_HAVE_CODECVT_UTF16_FACET) || defined (_WIN32)) \
|
||||
&& defined (UNICODE)
|
||||
, fUTF16 = (2 << fEncodingShift)
|
||||
#endif
|
||||
#if defined (LOG4CPLUS_HAVE_CODECVT_UTF32_FACET) && defined (UNICODE)
|
||||
, fUTF32 = (3 << fEncodingShift)
|
||||
#endif
|
||||
};
|
||||
|
||||
Properties();
|
||||
explicit Properties(log4cplus::tistream& input);
|
||||
explicit Properties(const log4cplus::tstring& inputFile, unsigned flags = 0);
|
||||
virtual ~Properties();
|
||||
|
||||
// constants
|
||||
static const tchar PROPERTIES_COMMENT_CHAR;
|
||||
|
||||
// methods
|
||||
/**
|
||||
* Tests to see if <code>key</code> can be found in this map.
|
||||
*/
|
||||
bool exists(const log4cplus::tstring& key) const;
|
||||
bool exists(tchar const * key) const;
|
||||
|
||||
/**
|
||||
* Returns the number of entries in this map.
|
||||
*/
|
||||
std::size_t size() const
|
||||
{
|
||||
return data.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches for the property with the specified key in this property
|
||||
* list. If the key is not found in this property list, the default
|
||||
* property list, and its defaults, recursively, are then checked.
|
||||
* The method returns <code>null</code> if the property is not found.
|
||||
*/
|
||||
log4cplus::tstring const & getProperty(const log4cplus::tstring& key) const;
|
||||
log4cplus::tstring const & getProperty(tchar const * key) const;
|
||||
|
||||
/**
|
||||
* Searches for the property with the specified key in this property
|
||||
* list. If the key is not found in this property list, the default
|
||||
* property list, and its defaults, recursively, are then checked.
|
||||
* The method returns the default value argument if the property is
|
||||
* not found.
|
||||
*/
|
||||
log4cplus::tstring getProperty(const log4cplus::tstring& key,
|
||||
const log4cplus::tstring& defaultVal) const;
|
||||
|
||||
/**
|
||||
* Returns all the keys in this property list.
|
||||
*/
|
||||
std::vector<log4cplus::tstring> propertyNames() const;
|
||||
|
||||
/**
|
||||
* Inserts <code>value</code> into this map indexed by <code>key</code>.
|
||||
*/
|
||||
void setProperty(const log4cplus::tstring& key, const log4cplus::tstring& value);
|
||||
|
||||
/**
|
||||
* Removed the property index by <code>key</code> from this map.
|
||||
*/
|
||||
bool removeProperty(const log4cplus::tstring& key);
|
||||
|
||||
/**
|
||||
* Returns a subset of the "properties" whose keys start with
|
||||
* "prefix". The returned "properties" have "prefix" trimmed from
|
||||
* their keys.
|
||||
*/
|
||||
Properties getPropertySubset(const log4cplus::tstring& prefix) const;
|
||||
|
||||
bool getInt (int & val, log4cplus::tstring const & key) const;
|
||||
bool getUInt (unsigned & val, log4cplus::tstring const & key) const;
|
||||
bool getLong (long & val, log4cplus::tstring const & key) const;
|
||||
bool getULong (unsigned long & val, log4cplus::tstring const & key) const;
|
||||
bool getBool (bool & val, log4cplus::tstring const & key) const;
|
||||
bool getString (log4cplus::tstring & val, log4cplus::tstring const & key) const;
|
||||
|
||||
protected:
|
||||
// Types
|
||||
typedef std::map<log4cplus::tstring, log4cplus::tstring> StringMap;
|
||||
|
||||
// Methods
|
||||
void init(log4cplus::tistream& input);
|
||||
|
||||
// Data
|
||||
StringMap data;
|
||||
unsigned flags;
|
||||
|
||||
private:
|
||||
template <typename StringType>
|
||||
log4cplus::tstring const & get_property_worker (
|
||||
StringType const & key) const;
|
||||
|
||||
template <typename ValType>
|
||||
bool get_type_val_worker (ValType & val,
|
||||
log4cplus::tstring const & key) const;
|
||||
};
|
||||
} // end namespace helpers
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_HELPERS_PROPERTY_HEADER_
|
|
@ -0,0 +1,158 @@
|
|||
// -*- C++ -*-
|
||||
// Copyright (C) 2009-2017, Vaclav Haisman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef LOG4CPLUS_HELPERS_QUEUE_H
|
||||
#define LOG4CPLUS_HELPERS_QUEUE_H
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
|
||||
#include <deque>
|
||||
#include <log4cplus/spi/loggingevent.h>
|
||||
#include <log4cplus/thread/threads.h>
|
||||
#include <log4cplus/thread/syncprims.h>
|
||||
|
||||
|
||||
namespace log4cplus { namespace thread {
|
||||
|
||||
|
||||
//! Single consumer, multiple producers queue.
|
||||
class LOG4CPLUS_EXPORT Queue
|
||||
: public virtual helpers::SharedObject
|
||||
{
|
||||
public:
|
||||
//! Type of the state flags field.
|
||||
typedef unsigned flags_type;
|
||||
|
||||
//! Queue storage type.
|
||||
typedef std::deque<spi::InternalLoggingEvent> queue_storage_type;
|
||||
|
||||
explicit Queue (unsigned len = 100);
|
||||
virtual ~Queue ();
|
||||
|
||||
// Producers' methods.
|
||||
|
||||
//! Puts event <code>ev</code> into queue, sets QUEUE flag and
|
||||
//! sets internal event object into signaled state. If the EXIT
|
||||
//! flags is already set upon entering the function, nothing is
|
||||
//! inserted into the queue. The function can block on internal
|
||||
//! semaphore if the queue has reached maximal allowed
|
||||
//! length. Calling thread is unblocked either by consumer thread
|
||||
//! removing item from queue or by any other thread calling
|
||||
//! signal_exit().
|
||||
//!
|
||||
//! \param ev spi::InternalLoggingEvent to be put into the queue.
|
||||
//! \return Flags.
|
||||
flags_type put_event (spi::InternalLoggingEvent const & ev);
|
||||
|
||||
//! Sets EXIT flag and DRAIN flag and sets internal event object
|
||||
//! into signaled state.
|
||||
//! \param drain If true, DRAIN flag will be set, otherwise unset.
|
||||
//! \return Flags, ERROR_BIT can be set upon error.
|
||||
flags_type signal_exit (bool drain = true);
|
||||
|
||||
// Consumer's methods.
|
||||
|
||||
//! The get_events() function is used by queue's consumer. It
|
||||
//! fills <code>buf</code> argument and sets EVENT flag in return
|
||||
//! value. If EXIT flag is already set in flags member upon
|
||||
//! entering the function then depending on DRAIN flag it either
|
||||
//! fills <code>buf</code> argument or does not fill the argument,
|
||||
//! if the queue is non-empty. The function blocks by waiting for
|
||||
//! internal event object to be signaled if the queue is empty,
|
||||
//! unless EXIT flag is set. The calling thread is unblocked when
|
||||
//! items are added into the queue or when exit is signaled using
|
||||
//! the signal_exit() function.
|
||||
//!
|
||||
//!
|
||||
//! Upon error, return value has one of the error flags set.
|
||||
//!
|
||||
//! \param buf Pointer to storage of spi::InternalLoggingEvent
|
||||
//! instances to be filled from queue.
|
||||
//! \return Flags.
|
||||
flags_type get_events (queue_storage_type * buf);
|
||||
|
||||
//! Possible state flags.
|
||||
enum Flags
|
||||
{
|
||||
//! EVENT flag is set in return value of get_event() call if
|
||||
//! the <code>ev</code> argument is filled with event from the queue.
|
||||
EVENT = 0x0001,
|
||||
|
||||
//! QUEUE flag is set by producers when they put item into the
|
||||
//! queue.
|
||||
QUEUE = 0x0002,
|
||||
|
||||
//! EXIT flag is set by signal_exit() call, signaling that the
|
||||
//! queue worker thread should end itself.
|
||||
EXIT = 0x0004,
|
||||
|
||||
//! When DRAIN flag is set together with EXIT flag, the queue
|
||||
//! worker thread will first drain the queue before exiting.
|
||||
DRAIN = 0x0008,
|
||||
|
||||
//! ERROR_BIT signals error.
|
||||
ERROR_BIT = 0x0010,
|
||||
|
||||
//! ERROR_AFTER signals error that has occurred after queue has
|
||||
//! already been touched.
|
||||
ERROR_AFTER = 0x0020
|
||||
};
|
||||
|
||||
protected:
|
||||
//! Queue storage.
|
||||
queue_storage_type queue;
|
||||
|
||||
//! Mutex protecting queue and flags.
|
||||
Mutex mutex;
|
||||
|
||||
//! Event on which consumer can wait if it finds queue empty.
|
||||
ManualResetEvent ev_consumer;
|
||||
|
||||
//! Semaphore that limits the queue length.
|
||||
Semaphore sem;
|
||||
|
||||
//! State flags.
|
||||
flags_type flags;
|
||||
|
||||
private:
|
||||
Queue (Queue const &);
|
||||
Queue & operator = (Queue const &);
|
||||
};
|
||||
|
||||
|
||||
typedef helpers::SharedObjectPtr<Queue> QueuePtr;
|
||||
|
||||
|
||||
} } // namespace log4cplus { namespace thread {
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_SINGLE_THREADED
|
||||
|
||||
#endif // LOG4CPLUS_HELPERS_QUEUE_H
|
|
@ -0,0 +1,62 @@
|
|||
// -*- C++ -*-
|
||||
// Copyright (C) 2010-2017, Vaclav Zeman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef LOG4CPLUS_HELPERS_SNPRINTF_H
|
||||
#define LOG4CPLUS_HELPERS_SNPRINTF_H
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/tchar.h>
|
||||
#include <cstdarg>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace log4cplus { namespace helpers {
|
||||
|
||||
|
||||
class LOG4CPLUS_EXPORT snprintf_buf
|
||||
{
|
||||
public:
|
||||
snprintf_buf ();
|
||||
|
||||
tchar const * print (tchar const * fmt, ...)
|
||||
LOG4CPLUS_FORMAT_ATTRIBUTE (__printf__, 2, 3);
|
||||
|
||||
int print_va_list (tchar const * & str, tchar const * fmt, std::va_list)
|
||||
LOG4CPLUS_FORMAT_ATTRIBUTE (__printf__, 3, 0);
|
||||
|
||||
private:
|
||||
std::vector<tchar> buf;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace log4cplus { namespace helpers
|
||||
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_HELPERS_SNPRINTF_H
|
|
@ -0,0 +1,163 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: socket.h
|
||||
// Created: 4/2003
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2003-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_HELPERS_SOCKET_HEADER_
|
||||
#define LOG4CPLUS_HELPERS_SOCKET_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <array>
|
||||
|
||||
#include <log4cplus/tstring.h>
|
||||
#include <log4cplus/helpers/socketbuffer.h>
|
||||
|
||||
|
||||
namespace log4cplus {
|
||||
namespace helpers {
|
||||
|
||||
enum SocketState { ok,
|
||||
not_opened,
|
||||
bad_address,
|
||||
connection_failed,
|
||||
broken_pipe,
|
||||
invalid_access_mode,
|
||||
message_truncated,
|
||||
accept_interrupted
|
||||
};
|
||||
|
||||
typedef std::ptrdiff_t SOCKET_TYPE;
|
||||
|
||||
extern LOG4CPLUS_EXPORT SOCKET_TYPE const INVALID_SOCKET_VALUE;
|
||||
|
||||
class LOG4CPLUS_EXPORT AbstractSocket {
|
||||
public:
|
||||
AbstractSocket();
|
||||
AbstractSocket(SOCKET_TYPE sock, SocketState state, int err);
|
||||
AbstractSocket(AbstractSocket const &) = delete;
|
||||
AbstractSocket(AbstractSocket &&) LOG4CPLUS_NOEXCEPT;
|
||||
virtual ~AbstractSocket() = 0;
|
||||
|
||||
/// Close socket
|
||||
virtual void close();
|
||||
virtual bool isOpen() const;
|
||||
virtual void shutdown();
|
||||
AbstractSocket & operator = (AbstractSocket && rhs) LOG4CPLUS_NOEXCEPT;
|
||||
|
||||
void swap (AbstractSocket &);
|
||||
|
||||
protected:
|
||||
SOCKET_TYPE sock;
|
||||
SocketState state;
|
||||
int err;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This class implements client sockets (also called just "sockets").
|
||||
* A socket is an endpoint for communication between two machines.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT Socket : public AbstractSocket {
|
||||
public:
|
||||
// ctor and dtor
|
||||
Socket();
|
||||
Socket(SOCKET_TYPE sock, SocketState state, int err);
|
||||
Socket(const tstring& address, unsigned short port,
|
||||
bool udp = false, bool ipv6 = false);
|
||||
Socket(Socket &&) LOG4CPLUS_NOEXCEPT;
|
||||
virtual ~Socket();
|
||||
|
||||
Socket & operator = (Socket &&) LOG4CPLUS_NOEXCEPT;
|
||||
|
||||
// methods
|
||||
virtual bool read(SocketBuffer& buffer);
|
||||
virtual bool write(const SocketBuffer& buffer);
|
||||
virtual bool write(const std::string & buffer);
|
||||
virtual bool write(std::size_t bufferCount,
|
||||
SocketBuffer const * const * buffers);
|
||||
|
||||
template <typename... Args>
|
||||
static bool write(Socket & socket, Args &&... args)
|
||||
{
|
||||
SocketBuffer const * const buffers[sizeof... (args)] {
|
||||
(&args)... };
|
||||
return socket.write (sizeof... (args), buffers);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This class implements server sockets. A server socket waits for
|
||||
* requests to come in over the network. It performs some operation
|
||||
* based on that request, and then possibly returns a result to the
|
||||
* requester.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT ServerSocket : public AbstractSocket {
|
||||
public:
|
||||
ServerSocket(unsigned short port, bool udp = false,
|
||||
bool ipv6 = false, tstring const & host = tstring ());
|
||||
ServerSocket(ServerSocket &&) LOG4CPLUS_NOEXCEPT;
|
||||
virtual ~ServerSocket();
|
||||
|
||||
ServerSocket & operator = (ServerSocket &&) LOG4CPLUS_NOEXCEPT;
|
||||
|
||||
Socket accept();
|
||||
void interruptAccept ();
|
||||
void swap (ServerSocket &);
|
||||
|
||||
protected:
|
||||
std::array<std::ptrdiff_t, 2> interruptHandles;
|
||||
};
|
||||
|
||||
|
||||
LOG4CPLUS_EXPORT SOCKET_TYPE openSocket(unsigned short port, bool udp,
|
||||
bool ipv6, SocketState& state);
|
||||
LOG4CPLUS_EXPORT SOCKET_TYPE openSocket(tstring const & host,
|
||||
unsigned short port, bool udp, bool ipv6, SocketState& state);
|
||||
|
||||
LOG4CPLUS_EXPORT SOCKET_TYPE connectSocket(const log4cplus::tstring& hostn,
|
||||
unsigned short port, bool udp, bool ipv6, SocketState& state);
|
||||
LOG4CPLUS_EXPORT SOCKET_TYPE acceptSocket(SOCKET_TYPE sock, SocketState& state);
|
||||
LOG4CPLUS_EXPORT int closeSocket(SOCKET_TYPE sock);
|
||||
LOG4CPLUS_EXPORT int shutdownSocket(SOCKET_TYPE sock);
|
||||
|
||||
LOG4CPLUS_EXPORT long read(SOCKET_TYPE sock, SocketBuffer& buffer);
|
||||
LOG4CPLUS_EXPORT long write(SOCKET_TYPE sock,
|
||||
const SocketBuffer& buffer);
|
||||
LOG4CPLUS_EXPORT long write(SOCKET_TYPE sock, std::size_t bufferCount,
|
||||
SocketBuffer const * const * buffers);
|
||||
LOG4CPLUS_EXPORT long write(SOCKET_TYPE sock,
|
||||
const std::string & buffer);
|
||||
|
||||
LOG4CPLUS_EXPORT tstring getHostname (bool fqdn);
|
||||
LOG4CPLUS_EXPORT int setTCPNoDelay (SOCKET_TYPE, bool);
|
||||
|
||||
} // end namespace helpers
|
||||
} // end namespace log4cplus
|
||||
|
||||
#endif // LOG4CPLUS_HELPERS_SOCKET_HEADER_
|
|
@ -0,0 +1,79 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: socketbuffer.h
|
||||
// Created: 5/2003
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2003-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_HELPERS_SOCKET_BUFFER_HEADER_
|
||||
#define LOG4CPLUS_HELPERS_SOCKET_BUFFER_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/tstring.h>
|
||||
|
||||
|
||||
namespace log4cplus {
|
||||
namespace helpers {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT SocketBuffer
|
||||
{
|
||||
public:
|
||||
explicit SocketBuffer(std::size_t max);
|
||||
virtual ~SocketBuffer();
|
||||
|
||||
char *getBuffer() const { return buffer; }
|
||||
std::size_t getMaxSize() const { return maxsize; }
|
||||
std::size_t getSize() const { return size; }
|
||||
void setSize(std::size_t s) { size = s; }
|
||||
std::size_t getPos() const { return pos; }
|
||||
|
||||
unsigned char readByte();
|
||||
unsigned short readShort();
|
||||
unsigned int readInt();
|
||||
tstring readString(unsigned char sizeOfChar);
|
||||
|
||||
void appendByte(unsigned char val);
|
||||
void appendShort(unsigned short val);
|
||||
void appendInt(unsigned int val);
|
||||
void appendString(const tstring& str);
|
||||
void appendBuffer(const SocketBuffer& buffer);
|
||||
|
||||
private:
|
||||
// Data
|
||||
std::size_t maxsize;
|
||||
std::size_t size;
|
||||
std::size_t pos;
|
||||
char *buffer;
|
||||
|
||||
SocketBuffer(SocketBuffer const & rhs);
|
||||
SocketBuffer& operator= (SocketBuffer const& rhs);
|
||||
};
|
||||
|
||||
} // end namespace helpers
|
||||
} // end namespace log4cplus
|
||||
|
||||
#endif // LOG4CPLUS_HELPERS_SOCKET_HEADER_
|
|
@ -0,0 +1,271 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: stringhelper.h
|
||||
// Created: 3/2003
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2003-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_HELPERS_STRINGHELPER_HEADER_
|
||||
#define LOG4CPLUS_HELPERS_STRINGHELPER_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/tstring.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
|
||||
|
||||
namespace log4cplus {
|
||||
namespace helpers {
|
||||
|
||||
/**
|
||||
* Returns <code>s</code> in upper case.
|
||||
*/
|
||||
LOG4CPLUS_EXPORT log4cplus::tstring toUpper(const log4cplus::tstring_view& s);
|
||||
LOG4CPLUS_EXPORT tchar toUpper(tchar);
|
||||
|
||||
|
||||
/**
|
||||
* Returns <code>s</code> in lower case.
|
||||
*/
|
||||
LOG4CPLUS_EXPORT log4cplus::tstring toLower(const log4cplus::tstring_view& s);
|
||||
LOG4CPLUS_EXPORT tchar toLower(tchar);
|
||||
|
||||
|
||||
/**
|
||||
* Tokenize <code>s</code> using <code>c</code> as the delimiter and
|
||||
* put the resulting tokens in <code>_result</code>. If
|
||||
* <code>collapseTokens</code> is false, multiple adjacent delimiters
|
||||
* will result in zero length tokens.
|
||||
*
|
||||
* <b>Example:</b>
|
||||
* <pre>
|
||||
* string s = // Set string with '.' as delimiters
|
||||
* list<log4cplus::tstring> tokens;
|
||||
* tokenize(s, '.', back_insert_iterator<list<string> >(tokens));
|
||||
* </pre>
|
||||
*/
|
||||
template <class StringType, class OutputIter>
|
||||
inline
|
||||
void
|
||||
tokenize(const StringType& s, typename StringType::value_type c,
|
||||
OutputIter result, bool collapseTokens = true)
|
||||
{
|
||||
typedef typename StringType::size_type size_type;
|
||||
size_type const slen = s.length();
|
||||
size_type first = 0;
|
||||
size_type i = 0;
|
||||
for (i=0; i < slen; ++i)
|
||||
{
|
||||
if (s[i] == c)
|
||||
{
|
||||
*result = StringType (s, first, i - first);
|
||||
++result;
|
||||
if (collapseTokens)
|
||||
while (i+1 < slen && s[i+1] == c)
|
||||
++i;
|
||||
first = i + 1;
|
||||
}
|
||||
}
|
||||
if (first != i)
|
||||
*result = StringType (s, first, i - first);
|
||||
else if (! collapseTokens && first == i)
|
||||
*result = StringType ();
|
||||
}
|
||||
|
||||
|
||||
template <typename intType, typename stringType, bool isSigned>
|
||||
struct ConvertIntegerToStringHelper;
|
||||
|
||||
|
||||
template <typename intType, typename charType>
|
||||
struct ConvertIntegerToStringHelper<intType, charType, true>
|
||||
{
|
||||
static inline
|
||||
void
|
||||
step1 (charType * & it, intType & value)
|
||||
{
|
||||
// The sign of the result of the modulo operator is
|
||||
// implementation defined. That's why we work with
|
||||
// positive counterpart instead. Also, in twos
|
||||
// complement arithmetic the smallest negative number
|
||||
// does not have positive counterpart; the range is
|
||||
// asymetric. That's why we handle the case of value
|
||||
// == min() specially here.
|
||||
if (LOG4CPLUS_UNLIKELY (
|
||||
value == (std::numeric_limits<intType>::min) ()))
|
||||
{
|
||||
intType const r = value / 10;
|
||||
intType const a = (-r) * 10;
|
||||
intType const mod = -(a + value);
|
||||
value = -r;
|
||||
|
||||
*(it - 1)
|
||||
= static_cast<charType>(LOG4CPLUS_TEXT('0') + mod);
|
||||
--it;
|
||||
}
|
||||
else
|
||||
value = -value;
|
||||
}
|
||||
|
||||
static
|
||||
bool
|
||||
is_negative (intType val)
|
||||
{
|
||||
return val < 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename intType, typename charType>
|
||||
struct ConvertIntegerToStringHelper<intType, charType, false>
|
||||
{
|
||||
static inline
|
||||
void
|
||||
step1 (charType * &, intType &)
|
||||
{
|
||||
// This will never be called for unsigned types.
|
||||
}
|
||||
|
||||
static
|
||||
bool
|
||||
is_negative (intType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <class stringType, class intType>
|
||||
inline
|
||||
void
|
||||
convertIntegerToString (stringType & str, intType value)
|
||||
{
|
||||
typedef std::numeric_limits<intType> intTypeLimits;
|
||||
typedef typename stringType::value_type charType;
|
||||
typedef ConvertIntegerToStringHelper<intType, charType,
|
||||
intTypeLimits::is_signed> HelperType;
|
||||
|
||||
charType buffer[intTypeLimits::digits10 + 2];
|
||||
const std::size_t buffer_size
|
||||
= sizeof (buffer) / sizeof (charType);
|
||||
|
||||
charType * it = &buffer[buffer_size];
|
||||
charType const * const buf_end = &buffer[buffer_size];
|
||||
|
||||
if (LOG4CPLUS_UNLIKELY (value == 0))
|
||||
{
|
||||
--it;
|
||||
*it = LOG4CPLUS_TEXT('0');
|
||||
}
|
||||
else
|
||||
{
|
||||
bool const negative = HelperType::is_negative (value);
|
||||
if (negative)
|
||||
HelperType::step1 (it, value);
|
||||
|
||||
for (; value != 0; --it)
|
||||
{
|
||||
intType mod = value % 10;
|
||||
value = value / 10;
|
||||
*(it - 1) = static_cast<charType>(LOG4CPLUS_TEXT('0')
|
||||
+ mod);
|
||||
}
|
||||
|
||||
if (negative)
|
||||
{
|
||||
--it;
|
||||
*it = LOG4CPLUS_TEXT('-');
|
||||
}
|
||||
}
|
||||
|
||||
str.assign (static_cast<charType const *>(it), buf_end);
|
||||
}
|
||||
|
||||
|
||||
template<class intType>
|
||||
inline
|
||||
tstring
|
||||
convertIntegerToString (intType value)
|
||||
{
|
||||
tstring result;
|
||||
convertIntegerToString (result, value);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
template<class intType>
|
||||
inline
|
||||
std::string
|
||||
convertIntegerToNarrowString (intType value)
|
||||
{
|
||||
std::string result;
|
||||
convertIntegerToString (result, value);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//! Join a list of items into a string.
|
||||
template <typename Iterator, typename Separator>
|
||||
inline
|
||||
void
|
||||
join_worker (tstring & result, Iterator & start, Iterator & last,
|
||||
Separator const & sep)
|
||||
{
|
||||
if (start != last)
|
||||
result = *start++;
|
||||
|
||||
for (; start != last; ++start)
|
||||
{
|
||||
result += sep;
|
||||
result += *start;
|
||||
}
|
||||
}
|
||||
|
||||
//! Join a list of items into a string.
|
||||
template <typename Iterator>
|
||||
inline
|
||||
void
|
||||
join (tstring & result, Iterator start, Iterator last,
|
||||
tstring_view const & sep)
|
||||
{
|
||||
join_worker (result, start, last, sep);
|
||||
}
|
||||
|
||||
//! Join a list of items into a string.
|
||||
template <typename Iterator>
|
||||
inline
|
||||
void
|
||||
join (tstring & result, Iterator start, Iterator last,
|
||||
tstring::value_type sep)
|
||||
{
|
||||
join_worker (result, start, last, sep);
|
||||
}
|
||||
|
||||
|
||||
} // namespace helpers
|
||||
|
||||
} // namespace log4cplus
|
||||
|
||||
#endif // LOG4CPLUS_HELPERS_STRINGHELPER_HEADER_
|
|
@ -0,0 +1,58 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: thread-config.h
|
||||
// Created: 4/2003
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2003-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_HELPERS_THREAD_CONFIG_HEADER_
|
||||
#define LOG4CPLUS_HELPERS_THREAD_CONFIG_HEADER_
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if defined (LOG4CPLUS_USE_PTHREADS)
|
||||
# if defined (__APPLE__)
|
||||
# define LOG4CPLUS_USE_NAMED_POSIX_SEMAPHORE
|
||||
# endif
|
||||
|
||||
#elif defined(LOG4CPLUS_USE_WIN32_THREADS)
|
||||
# define LOG4CPLUS_USE_SRW_LOCK
|
||||
//# define LOG4CPLUS_POOR_MANS_SHAREDMUTEX
|
||||
# undef LOG4CPLUS_HAVE_TLS_SUPPORT
|
||||
# undef LOG4CPLUS_THREAD_LOCAL_VAR
|
||||
# if defined (_MSC_VER)
|
||||
// The __declspec(thread) functionality is not compatible with LoadLibrary().
|
||||
// For more information why see and "Windows and TLS" note in README.
|
||||
// <http://msdn.microsoft.com/en-us/library/2s9wt68x(v=vs.100).aspx>.
|
||||
# define LOG4CPLUS_HAVE_TLS_SUPPORT 1
|
||||
# define LOG4CPLUS_THREAD_LOCAL_VAR __declspec(thread)
|
||||
# endif
|
||||
|
||||
#elif defined(LOG4CPLUS_SINGLE_THREADED)
|
||||
# undef LOG4CPLUS_HAVE_TLS_SUPPORT
|
||||
# undef LOG4CPLUS_THREAD_LOCAL_VAR
|
||||
|
||||
#else
|
||||
# error "You Must define a Threading model"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_HELPERS_THREAD_CONFIG_HEADER_
|
|
@ -0,0 +1,169 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: timehelper.h
|
||||
// Created: 6/2003
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2003-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_HELPERS_TIME_HELPER_HEADER_
|
||||
#define LOG4CPLUS_HELPERS_TIME_HELPER_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/tstring.h>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_TIME_H)
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
#include <ctime>
|
||||
#include <chrono>
|
||||
|
||||
|
||||
namespace log4cplus {
|
||||
|
||||
namespace helpers {
|
||||
|
||||
|
||||
using std::time_t;
|
||||
using std::tm;
|
||||
namespace chrono = std::chrono;
|
||||
|
||||
typedef chrono::system_clock Clock;
|
||||
typedef chrono::duration<long long, std::micro> Duration;
|
||||
typedef chrono::time_point<Clock, Duration> Time;
|
||||
|
||||
|
||||
template <typename FromDuration>
|
||||
inline
|
||||
Time
|
||||
time_cast (chrono::time_point<Clock, FromDuration> const & tp)
|
||||
{
|
||||
return chrono::time_point_cast<Duration, Clock> (tp);
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
Time
|
||||
now ()
|
||||
{
|
||||
return time_cast (Clock::now ());
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
Time
|
||||
from_time_t (time_t t_time)
|
||||
{
|
||||
return time_cast (Clock::from_time_t (t_time));
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
time_t
|
||||
to_time_t (Time const & the_time)
|
||||
{
|
||||
// This is based on <http://stackoverflow.com/a/17395137/341065>. It is
|
||||
// possible that to_time_t() returns rounded time and we want truncation.
|
||||
|
||||
time_t time = Clock::to_time_t (the_time);
|
||||
auto const rounded_time = from_time_t (time);
|
||||
if (rounded_time > the_time)
|
||||
--time;
|
||||
|
||||
return time;
|
||||
}
|
||||
|
||||
|
||||
LOG4CPLUS_EXPORT Time from_struct_tm (tm * t);
|
||||
|
||||
|
||||
inline
|
||||
Time
|
||||
truncate_fractions (Time const & the_time)
|
||||
{
|
||||
return from_time_t (to_time_t (the_time));
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
long
|
||||
microseconds_part (Time const & the_time)
|
||||
{
|
||||
static_assert ((std::ratio_equal<Duration::period, std::micro>::value),
|
||||
"microseconds");
|
||||
|
||||
// This is based on <http://stackoverflow.com/a/17395137/341065>
|
||||
return static_cast<long>(
|
||||
(the_time - from_time_t (to_time_t (the_time))).count ());
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
Time
|
||||
time_from_parts (time_t tv_sec, long tv_usec)
|
||||
{
|
||||
return from_time_t (tv_sec) + chrono::microseconds (tv_usec);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Populates <code>tm</code> using the <code>gmtime()</code>
|
||||
* function.
|
||||
*/
|
||||
|
||||
LOG4CPLUS_EXPORT
|
||||
void gmTime (tm* t, Time const &);
|
||||
|
||||
/**
|
||||
* Populates <code>tm</code> using the <code>localtime()</code>
|
||||
* function.
|
||||
*/
|
||||
|
||||
LOG4CPLUS_EXPORT
|
||||
void localTime (tm* t, Time const &);
|
||||
|
||||
/**
|
||||
* Returns a string with a "formatted time" specified by
|
||||
* <code>fmt</code>. It used the <code>strftime()</code>
|
||||
* function to do this.
|
||||
*
|
||||
* Look at your platform's <code>strftime()</code> documentation
|
||||
* for the formatting options available.
|
||||
*
|
||||
* The following additional options are provided:<br>
|
||||
* <code>%q</code> - 3 character field that provides milliseconds
|
||||
* <code>%Q</code> - 7 character field that provides fractional
|
||||
* milliseconds.
|
||||
*/
|
||||
LOG4CPLUS_EXPORT
|
||||
log4cplus::tstring getFormattedTime (log4cplus::tstring const & fmt,
|
||||
Time const & the_time, bool use_gmtime = false);
|
||||
|
||||
|
||||
} // namespace helpers
|
||||
|
||||
} // namespace log4cplus
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_HELPERS_TIME_HELPER_HEADER_
|
|
@ -0,0 +1,325 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: hierarchy.h
|
||||
// Created: 6/2001
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2001-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_HIERARCHY_HEADER_
|
||||
#define LOG4CPLUS_HIERARCHY_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/logger.h>
|
||||
#include <log4cplus/thread/syncprims.h>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace log4cplus {
|
||||
// Forward Declarations
|
||||
class HierarchyLocker;
|
||||
|
||||
/**
|
||||
* This class is specialized in retrieving loggers by name and
|
||||
* also maintaining the logger hierarchy.
|
||||
*
|
||||
* <em>The casual user should not have to deal with this class
|
||||
* directly.</em> However, if you are in an environment where
|
||||
* multiple applications run in the same process, then read on.
|
||||
*
|
||||
* The structure of the logger hierarchy is maintained by the
|
||||
* {@link #getInstance} method. The hierarchy is such that children
|
||||
* link to their parent but parents do not have any pointers to their
|
||||
* children. Moreover, loggers can be instantiated in any order, in
|
||||
* particular descendant before ancestor.
|
||||
*
|
||||
* In case a descendant is created before a particular ancestor,
|
||||
* then it creates a provision node for the ancestor and adds itself
|
||||
* to the provision node. Other descendants of the same ancestor add
|
||||
* themselves to the previously created provision node.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT Hierarchy
|
||||
{
|
||||
public:
|
||||
// DISABLE_OFF should be set to a value lower than all possible
|
||||
// priorities.
|
||||
static const LogLevel DISABLE_OFF;
|
||||
static const LogLevel DISABLE_OVERRIDE;
|
||||
|
||||
// Ctors
|
||||
/**
|
||||
* Create a new Logger hierarchy.
|
||||
*/
|
||||
Hierarchy();
|
||||
|
||||
// Dtor
|
||||
virtual ~Hierarchy();
|
||||
|
||||
// Methods
|
||||
/**
|
||||
* This call will clear all logger definitions from the internal
|
||||
* hashtable. Invoking this method will irrevocably mess up the
|
||||
* logger hierarchy.
|
||||
*
|
||||
* You should <em>really</em> know what you are doing before
|
||||
* invoking this method.
|
||||
*/
|
||||
virtual void clear();
|
||||
|
||||
/**
|
||||
* Returns <code>true </code>if the named logger exists
|
||||
* (in the default hierarchy).
|
||||
*
|
||||
* @param name The name of the logger to search for.
|
||||
*/
|
||||
virtual bool exists(const log4cplus::tstring_view& name);
|
||||
|
||||
/**
|
||||
* Similar to {@link #disable(LogLevel)} except that the LogLevel
|
||||
* argument is given as a log4cplus::tstring.
|
||||
*/
|
||||
virtual void disable(const log4cplus::tstring_view& loglevelStr);
|
||||
|
||||
/**
|
||||
* Disable all logging requests of LogLevel <em>equal to or
|
||||
* below</em> the ll parameter <code>p</code>, for
|
||||
* <em>all</em> loggers in this hierarchy. Logging requests of
|
||||
* higher LogLevel then <code>p</code> remain unaffected.
|
||||
*
|
||||
* Nevertheless, if the
|
||||
* BasicConfigurator::DISABLE_OVERRIDE_KEY property is set to
|
||||
* true, then logging requests are evaluated as usual.
|
||||
*
|
||||
* The "disable" family of methods are there for speed. They
|
||||
* allow printing methods such as debug, info, etc. to return
|
||||
* immediately after an integer comparison without walking the
|
||||
* logger hierarchy. In most modern computers an integer
|
||||
* comparison is measured in nanoseconds where as a logger walk is
|
||||
* measured in units of microseconds.
|
||||
*/
|
||||
virtual void disable(LogLevel ll);
|
||||
|
||||
/**
|
||||
* Disable all logging requests regardless of logger and LogLevel.
|
||||
* This method is equivalent to calling {@link #disable} with the
|
||||
* argument FATAL_LOG_LEVEL, the highest possible LogLevel.
|
||||
*/
|
||||
virtual void disableAll();
|
||||
|
||||
/**
|
||||
* Disable all Debug logging requests regardless of logger.
|
||||
* This method is equivalent to calling {@link #disable} with the
|
||||
* argument DEBUG_LOG_LEVEL.
|
||||
*/
|
||||
virtual void disableDebug();
|
||||
|
||||
/**
|
||||
* Disable all Info logging requests regardless of logger.
|
||||
* This method is equivalent to calling {@link #disable} with the
|
||||
* argument INFO_LOG_LEVEL.
|
||||
*/
|
||||
virtual void disableInfo();
|
||||
|
||||
/**
|
||||
* Undoes the effect of calling any of {@link #disable}, {@link
|
||||
* #disableAll}, {@link #disableDebug} and {@link #disableInfo}
|
||||
* methods. More precisely, invoking this method sets the Logger
|
||||
* class internal variable called <code>disable</code> to its
|
||||
* default "off" value.
|
||||
*/
|
||||
virtual void enableAll();
|
||||
|
||||
/**
|
||||
* Return a new logger instance named as the first parameter using
|
||||
* the default factory.
|
||||
*
|
||||
* If a logger of that name already exists, then it will be
|
||||
* returned. Otherwise, a new logger will be instantiated and
|
||||
* then linked with its existing ancestors as well as children.
|
||||
*
|
||||
* @param name The name of the logger to retrieve.
|
||||
*/
|
||||
virtual Logger getInstance(const log4cplus::tstring_view& name);
|
||||
|
||||
/**
|
||||
* Return a new logger instance named as the first parameter using
|
||||
* <code>factory</code>.
|
||||
*
|
||||
* If a logger of that name already exists, then it will be
|
||||
* returned. Otherwise, a new logger will be instantiated by the
|
||||
* <code>factory</code> parameter and linked with its existing
|
||||
* ancestors as well as children.
|
||||
*
|
||||
* @param name The name of the logger to retrieve.
|
||||
* @param factory The factory that will make the new logger instance.
|
||||
*/
|
||||
virtual Logger getInstance(const log4cplus::tstring_view& name,
|
||||
spi::LoggerFactory& factory);
|
||||
|
||||
/**
|
||||
* Returns all the currently defined loggers in this hierarchy.
|
||||
*
|
||||
* The root logger is <em>not</em> included in the returned list.
|
||||
*/
|
||||
virtual LoggerList getCurrentLoggers();
|
||||
|
||||
/**
|
||||
* Is the LogLevel specified by <code>level</code> enabled?
|
||||
*/
|
||||
virtual bool isDisabled(LogLevel level);
|
||||
|
||||
/**
|
||||
* Get the root of this hierarchy.
|
||||
*/
|
||||
virtual Logger getRoot() const;
|
||||
|
||||
/**
|
||||
* Reset all values contained in this hierarchy instance to their
|
||||
* default. This removes all appenders from all loggers, sets
|
||||
* the LogLevel of all non-root loggers to <code>NOT_SET_LOG_LEVEL</code>,
|
||||
* sets their additivity flag to <code>true</code> and sets the LogLevel
|
||||
* of the root logger to DEBUG_LOG_LEVEL. Moreover, message disabling
|
||||
* is set its default "off" value.
|
||||
*
|
||||
* Existing loggers are not removed. They are just reset.
|
||||
*
|
||||
* This method should be used sparingly and with care as it will
|
||||
* block all logging until it is completed.</p>
|
||||
*/
|
||||
virtual void resetConfiguration();
|
||||
|
||||
/**
|
||||
* Set the default LoggerFactory instance.
|
||||
*/
|
||||
virtual void setLoggerFactory(std::unique_ptr<spi::LoggerFactory> factory);
|
||||
|
||||
/**
|
||||
* Returns the default LoggerFactory instance.
|
||||
*/
|
||||
virtual spi::LoggerFactory* getLoggerFactory();
|
||||
|
||||
/**
|
||||
* Shutting down a hierarchy will <em>safely</em> close and remove
|
||||
* all appenders in all loggers including the root logger.
|
||||
*
|
||||
* Some appenders such as SocketAppender need to be closed before the
|
||||
* application exits. Otherwise, pending logging events might be
|
||||
* lost.
|
||||
*
|
||||
* The <code>shutdown</code> method is careful to close nested
|
||||
* appenders before closing regular appenders. This is allows
|
||||
* configurations where a regular appender is attached to a logger
|
||||
* and again to a nested appender.
|
||||
*/
|
||||
virtual void shutdown();
|
||||
|
||||
private:
|
||||
// Types
|
||||
typedef std::vector<Logger> ProvisionNode;
|
||||
typedef std::map<log4cplus::tstring, ProvisionNode, std::less<>> ProvisionNodeMap;
|
||||
typedef std::map<log4cplus::tstring, Logger, std::less<>> LoggerMap;
|
||||
|
||||
// Methods
|
||||
/**
|
||||
* This is the implementation of the <code>getInstance()</code> method.
|
||||
* NOTE: This method does not lock the <code>hashtable_mutex</code>.
|
||||
*/
|
||||
LOG4CPLUS_PRIVATE
|
||||
Logger getInstanceImpl(const log4cplus::tstring_view& name,
|
||||
spi::LoggerFactory& factory);
|
||||
|
||||
/**
|
||||
* This is the implementation of the <code>getCurrentLoggers()</code>.
|
||||
* NOTE: This method does not lock the <code>hashtable_mutex</code>.
|
||||
*/
|
||||
LOG4CPLUS_PRIVATE
|
||||
void initializeLoggerList(LoggerList& list) const;
|
||||
|
||||
/**
|
||||
* This method loops through all the *potential* parents of
|
||||
* logger'. There 3 possible cases:
|
||||
*
|
||||
* 1) No entry for the potential parent of 'logger' exists
|
||||
*
|
||||
* We create a ProvisionNode for this potential parent and insert
|
||||
* 'logger' in that provision node.
|
||||
*
|
||||
* 2) There is an entry of type Logger for the potential parent.
|
||||
*
|
||||
* The entry is 'logger's nearest existing parent. We update logger's
|
||||
* parent field with this entry. We also break from the loop
|
||||
* because updating our parent's parent is our parent's
|
||||
* responsibility.
|
||||
*
|
||||
* 3) There entry is of type ProvisionNode for this potential parent.
|
||||
*
|
||||
* We add 'logger' to the list of children for this potential parent.
|
||||
*/
|
||||
LOG4CPLUS_PRIVATE void updateParents(Logger const & logger);
|
||||
|
||||
/**
|
||||
* We update the links for all the children that placed themselves
|
||||
* in the provision node 'pn'. The second argument 'logger' is a
|
||||
* reference for the newly created Logger, parent of all the
|
||||
* children in 'pn'
|
||||
*
|
||||
* We loop on all the children 'c' in 'pn':
|
||||
*
|
||||
* If the child 'c' has been already linked to a child of
|
||||
* 'logger' then there is no need to update 'c'.
|
||||
*
|
||||
* Otherwise, we set logger's parent field to c's parent and set
|
||||
* c's parent field to logger.
|
||||
*/
|
||||
LOG4CPLUS_PRIVATE void updateChildren(ProvisionNode& pn,
|
||||
Logger const & logger);
|
||||
|
||||
// Data
|
||||
thread::Mutex hashtable_mutex;
|
||||
std::unique_ptr<spi::LoggerFactory> defaultFactory;
|
||||
ProvisionNodeMap provisionNodes;
|
||||
LoggerMap loggerPtrs;
|
||||
Logger root;
|
||||
|
||||
int disableValue;
|
||||
|
||||
bool emittedNoAppenderWarning;
|
||||
|
||||
// Disallow copying of instances of this class
|
||||
Hierarchy(const Hierarchy&);
|
||||
Hierarchy& operator=(const Hierarchy&);
|
||||
|
||||
// Friends
|
||||
friend class log4cplus::spi::LoggerImpl;
|
||||
friend class log4cplus::HierarchyLocker;
|
||||
};
|
||||
|
||||
|
||||
LOG4CPLUS_EXPORT Hierarchy & getDefaultHierarchy ();
|
||||
|
||||
|
||||
} // end namespace log4cplus
|
||||
|
||||
#endif // LOG4CPLUS_HIERARCHY_HEADER_
|
|
@ -0,0 +1,79 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: hierarchylocker.h
|
||||
// Created: 8/2003
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2003-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_HIERARCHY_LOCKER_HEADER_
|
||||
#define LOG4CPLUS_HIERARCHY_LOCKER_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/tstring.h>
|
||||
#include <log4cplus/appender.h>
|
||||
#include <log4cplus/logger.h>
|
||||
|
||||
|
||||
namespace log4cplus
|
||||
{
|
||||
|
||||
class Hierarchy;
|
||||
|
||||
|
||||
/**
|
||||
* This is used to lock a Hierarchy. The dtor unlocks the Hierarchy.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT HierarchyLocker {
|
||||
public:
|
||||
// ctor & dtor
|
||||
HierarchyLocker(Hierarchy& h);
|
||||
~HierarchyLocker() LOG4CPLUS_NOEXCEPT_FALSE;
|
||||
|
||||
/**
|
||||
* Calls the <code>resetConfiguration()</code> method on the locked Hierarchy.
|
||||
*/
|
||||
void resetConfiguration();
|
||||
|
||||
/**
|
||||
* Calls the <code>getInstance()</code> method on the locked Hierarchy.
|
||||
*/
|
||||
Logger getInstance(const log4cplus::tstring& name);
|
||||
|
||||
/**
|
||||
* Calls the <code>getInstance()</code> method on the locked Hierarchy.
|
||||
*/
|
||||
Logger getInstance(const log4cplus::tstring& name, spi::LoggerFactory& factory);
|
||||
|
||||
void addAppender(Logger &logger, log4cplus::SharedAppenderPtr& appender);
|
||||
|
||||
private:
|
||||
// Data
|
||||
Hierarchy& h;
|
||||
log4cplus::thread::MutexGuard hierarchyLocker;
|
||||
LoggerList loggerList;
|
||||
};
|
||||
|
||||
} // end namespace log4cplus
|
||||
|
||||
#endif // LOG4CPLUS_HIERARCHY_LOCKER_HEADER_
|
|
@ -0,0 +1,62 @@
|
|||
// Copyright (C) 2015-2017, Vaclav Haisman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef LOG4CPLUS_INITIALIZER_HXX
|
||||
#define LOG4CPLUS_INITIALIZER_HXX
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace log4cplus
|
||||
{
|
||||
|
||||
/**
|
||||
This class helps with initialization and shutdown of log4cplus. Its
|
||||
constructor calls `log4cplus::initialize()` and its destructor calls
|
||||
`log4cplus::Logger::shutdown()`. Use this class as the first thing in your
|
||||
`main()`. It will ensure shutdown of log4cplus at the end of
|
||||
`main()`. This is particularly important on Windows, where shutdown of
|
||||
standard threads outside `main()` is impossible.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT Initializer
|
||||
{
|
||||
public:
|
||||
Initializer ();
|
||||
~Initializer ();
|
||||
|
||||
Initializer (Initializer const &) = delete;
|
||||
Initializer (Initializer &&) = delete;
|
||||
Initializer & operator = (Initializer const &) = delete;
|
||||
Initializer & operator = (Initializer &&) = delete;
|
||||
};
|
||||
|
||||
} // namespace log4cplus
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_INITIALIZER_HXX
|
|
@ -0,0 +1,98 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: customloglevelmanager.h
|
||||
// Created: 12/2018
|
||||
// Author: Jens Rehsack
|
||||
// Author: Václav Haisman
|
||||
//
|
||||
//
|
||||
// Copyright (C) 2018, Jens Rehsack. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
/** @file
|
||||
* This header contains declaration internal to log4cplus. They must never be
|
||||
* visible from user accesible headers or exported in DLL/shared library.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LOG4CPLUS_INTERNAL_CUSTOMLOGLEVELMANAGER_HEADER_
|
||||
#define LOG4CPLUS_INTERNAL_CUSTOMLOGLEVELMANAGER_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if ! defined (INSIDE_LOG4CPLUS)
|
||||
# error "This header must not be be used outside log4cplus' implementation files."
|
||||
#endif
|
||||
|
||||
#include <map>
|
||||
#include <log4cplus/thread/syncprims.h>
|
||||
#include <log4cplus/internal/internal.h>
|
||||
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
#include <shared_mutex>
|
||||
#endif
|
||||
|
||||
namespace log4cplus {
|
||||
|
||||
namespace internal {
|
||||
|
||||
|
||||
/**
|
||||
* Custom log level manager used by C API.
|
||||
*/
|
||||
class LOG4CPLUS_PRIVATE CustomLogLevelManager
|
||||
: virtual public LogLevelTranslator
|
||||
{
|
||||
protected:
|
||||
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
mutable std::shared_mutex mtx;
|
||||
#endif
|
||||
bool pushed_methods;
|
||||
std::map<LogLevel, tstring> ll2nm;
|
||||
std::map<tstring, LogLevel, std::less<>> nm2ll;
|
||||
|
||||
public:
|
||||
CustomLogLevelManager ();
|
||||
virtual ~CustomLogLevelManager ();
|
||||
|
||||
bool add(LogLevel ll, tstring const &nm);
|
||||
|
||||
bool remove(LogLevel ll, tstring const &nm);
|
||||
|
||||
protected:
|
||||
virtual log4cplus::tstring const & toString (LogLevel ll) const;
|
||||
|
||||
virtual LogLevel fromString (const log4cplus::tstring_view& s) const;
|
||||
};
|
||||
|
||||
LOG4CPLUS_PRIVATE CustomLogLevelManager & getCustomLogLevelManager ();
|
||||
|
||||
} // namespace internal
|
||||
|
||||
} // namespace log4cplus
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_INTERNAL_CUSTOMLOGLEVELMANAGER_HEADER
|
|
@ -0,0 +1,55 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: cygwin-win32.h
|
||||
// Created: 7/2011
|
||||
// Author: Vaclav Zeman
|
||||
//
|
||||
// Copyright (C) 2011-2017, Vaclav Zeman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#if ! defined (LOG4CPLUS_CONFIG_CYGWIN_WIN32_H)
|
||||
#define LOG4CPLUS_CONFIG_CYGWIN_WIN32_H
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if defined (__CYGWIN__)
|
||||
|
||||
#if ! defined (INSIDE_LOG4CPLUS)
|
||||
# error "This header must not be be used outside log4cplus' implementation files."
|
||||
#endif
|
||||
|
||||
|
||||
namespace log4cplus { namespace cygwin {
|
||||
|
||||
unsigned long get_current_win32_thread_id ();
|
||||
void output_debug_stringW (wchar_t const *);
|
||||
|
||||
} } // namespace log4cplus { namespace cygwin {
|
||||
|
||||
|
||||
#endif // defined (__CYGWIN__)
|
||||
#endif // LOG4CPLUS_CONFIG_CYGWIN_WIN32_H
|
|
@ -0,0 +1,98 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: env.h
|
||||
// Created: 7/2010
|
||||
// Author: Vaclav Haisman
|
||||
//
|
||||
//
|
||||
// Copyright (C) 2010-2017, Vaclav Haisman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef LOG4CPLUS_INTERNAL_ENV_H
|
||||
#define LOG4CPLUS_INTERNAL_ENV_H
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include <log4cplus/tstring.h>
|
||||
|
||||
#if defined (_WIN32)
|
||||
#include <log4cplus/config/windowsh-inc.h>
|
||||
#endif
|
||||
#ifdef LOG4CPLUS_HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef LOG4CPLUS_HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace log4cplus { namespace internal {
|
||||
|
||||
|
||||
//! Get environment variable value.
|
||||
bool get_env_var (tstring & value, tstring const & name);
|
||||
|
||||
//! Parse a string as a boolean value.
|
||||
bool parse_bool (bool & val, tstring const & str);
|
||||
|
||||
//! Parse a path into path components.
|
||||
bool split_path (std::vector<tstring> & components, std::size_t & special,
|
||||
tstring const & path);
|
||||
|
||||
//! Makes directories leading to file.
|
||||
void make_dirs (tstring const & file_path);
|
||||
|
||||
inline
|
||||
#if defined (_WIN32)
|
||||
DWORD
|
||||
get_process_id ()
|
||||
{
|
||||
return GetCurrentProcessId ();
|
||||
}
|
||||
|
||||
#elif defined (LOG4CPLUS_HAVE_GETPID)
|
||||
pid_t
|
||||
get_process_id ()
|
||||
{
|
||||
return getpid ();
|
||||
}
|
||||
|
||||
#else
|
||||
int
|
||||
get_process_id ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
} } // namespace log4cplus { namespace internal {
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_INTERNAL_ENV_H
|
|
@ -0,0 +1,244 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: internal.h
|
||||
// Created: 1/2009
|
||||
// Author: Vaclav Haisman
|
||||
//
|
||||
//
|
||||
// Copyright (C) 2009-2017, Vaclav Haisman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
/** @file
|
||||
* This header contains declaration internal to log4cplus. They must never be
|
||||
* visible from user accesible headers or exported in DLL/shared libray.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LOG4CPLUS_INTERNAL_INTERNAL_HEADER_
|
||||
#define LOG4CPLUS_INTERNAL_INTERNAL_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if ! defined (INSIDE_LOG4CPLUS)
|
||||
# error "This header must not be be used outside log4cplus' implementation files."
|
||||
#endif
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <cstdio>
|
||||
#include <log4cplus/tstring.h>
|
||||
#include <log4cplus/streams.h>
|
||||
#include <log4cplus/ndc.h>
|
||||
#include <log4cplus/mdc.h>
|
||||
#include <log4cplus/spi/loggingevent.h>
|
||||
#include <log4cplus/thread/impl/tls.h>
|
||||
#include <log4cplus/helpers/snprintf.h>
|
||||
|
||||
|
||||
namespace log4cplus {
|
||||
|
||||
namespace internal {
|
||||
|
||||
|
||||
//! Canonical empty string. It is used when the need to return empty string
|
||||
//! by reference arises.
|
||||
extern log4cplus::tstring const empty_str;
|
||||
|
||||
|
||||
struct gft_scratch_pad
|
||||
{
|
||||
gft_scratch_pad ();
|
||||
~gft_scratch_pad ();
|
||||
|
||||
void
|
||||
reset ()
|
||||
{
|
||||
uc_q_str_valid = false;
|
||||
q_str_valid = false;
|
||||
s_str_valid = false;
|
||||
ret.clear ();
|
||||
}
|
||||
|
||||
log4cplus::tstring q_str;
|
||||
log4cplus::tstring uc_q_str;
|
||||
log4cplus::tstring s_str;
|
||||
log4cplus::tstring ret;
|
||||
log4cplus::tstring fmt;
|
||||
log4cplus::tstring tmp;
|
||||
std::vector<tchar> buffer;
|
||||
bool uc_q_str_valid;
|
||||
bool q_str_valid;
|
||||
bool s_str_valid;
|
||||
};
|
||||
|
||||
|
||||
struct appender_sratch_pad
|
||||
{
|
||||
appender_sratch_pad ();
|
||||
~appender_sratch_pad ();
|
||||
|
||||
tostringstream oss;
|
||||
tstring str;
|
||||
std::string chstr;
|
||||
};
|
||||
|
||||
|
||||
//! Per thread data.
|
||||
struct per_thread_data
|
||||
{
|
||||
per_thread_data ();
|
||||
~per_thread_data ();
|
||||
|
||||
tstring macros_str;
|
||||
tostringstream macros_oss;
|
||||
tostringstream layout_oss;
|
||||
DiagnosticContextStack ndc_dcs;
|
||||
MappedDiagnosticContextMap mdc_map;
|
||||
log4cplus::tstring thread_name;
|
||||
log4cplus::tstring thread_name2;
|
||||
gft_scratch_pad gft_sp;
|
||||
appender_sratch_pad appender_sp;
|
||||
log4cplus::tstring faa_str;
|
||||
log4cplus::tstring ll_str;
|
||||
spi::InternalLoggingEvent forced_log_ev;
|
||||
std::FILE * fnull;
|
||||
log4cplus::helpers::snprintf_buf snprintf_buf;
|
||||
};
|
||||
|
||||
|
||||
per_thread_data * alloc_ptd ();
|
||||
|
||||
// TLS key whose value is pointer struct per_thread_data.
|
||||
extern log4cplus::thread::impl::tls_key_type tls_storage_key;
|
||||
|
||||
|
||||
#if ! defined (LOG4CPLUS_SINGLE_THREADED) \
|
||||
&& defined (LOG4CPLUS_THREAD_LOCAL_VAR)
|
||||
|
||||
extern LOG4CPLUS_THREAD_LOCAL_VAR per_thread_data * ptd;
|
||||
|
||||
|
||||
inline
|
||||
void
|
||||
set_ptd (per_thread_data * p)
|
||||
{
|
||||
ptd = p;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
per_thread_data *
|
||||
get_ptd (bool alloc = true)
|
||||
{
|
||||
if (LOG4CPLUS_UNLIKELY (! ptd && alloc))
|
||||
return alloc_ptd ();
|
||||
|
||||
// The assert() does not belong here. get_ptd() might be called by
|
||||
// cleanup code that can handle the returned NULL pointer.
|
||||
//assert (ptd);
|
||||
|
||||
return ptd;
|
||||
}
|
||||
|
||||
|
||||
#else // defined (LOG4CPLUS_THREAD_LOCAL_VAR)
|
||||
|
||||
|
||||
inline
|
||||
void
|
||||
set_ptd (per_thread_data * p)
|
||||
{
|
||||
thread::impl::tls_set_value (tls_storage_key, p);
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
per_thread_data *
|
||||
get_ptd (bool alloc = true)
|
||||
{
|
||||
per_thread_data * ptd
|
||||
= reinterpret_cast<per_thread_data *>(
|
||||
thread::impl::tls_get_value (tls_storage_key));
|
||||
|
||||
if (LOG4CPLUS_UNLIKELY (! ptd && alloc))
|
||||
return alloc_ptd ();
|
||||
|
||||
return ptd;
|
||||
}
|
||||
|
||||
|
||||
#endif // defined (LOG4CPLUS_THREAD_LOCAL_VAR)
|
||||
|
||||
|
||||
inline
|
||||
tstring &
|
||||
get_thread_name_str ()
|
||||
{
|
||||
return get_ptd ()->thread_name;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
tstring &
|
||||
get_thread_name2_str ()
|
||||
{
|
||||
return get_ptd ()->thread_name2;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
gft_scratch_pad &
|
||||
get_gft_scratch_pad ()
|
||||
{
|
||||
return get_ptd ()->gft_sp;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
appender_sratch_pad &
|
||||
get_appender_sp ()
|
||||
{
|
||||
return get_ptd ()->appender_sp;
|
||||
}
|
||||
|
||||
|
||||
} // namespace internal {
|
||||
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
LOG4CPLUS_EXPORT void clear_tostringstream (tostringstream &);
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
||||
} // namespace log4cplus {
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_INTERNAL_INTERNAL_HEADER_
|
|
@ -0,0 +1,219 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: socket.h
|
||||
// Created: 1/2010
|
||||
// Author: Vaclav Haisman
|
||||
//
|
||||
//
|
||||
// Copyright (C) 2010-2017, Vaclav Haisman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
/** @file
|
||||
* This header contains declaration internal to log4cplus. They must never be
|
||||
* visible from user accesible headers or exported in DLL/shared libray.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LOG4CPLUS_INTERNAL_SOCKET_H_
|
||||
#define LOG4CPLUS_INTERNAL_SOCKET_H_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if ! defined (INSIDE_LOG4CPLUS)
|
||||
# error "This header must not be be used outside log4cplus' implementation files."
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <log4cplus/config/windowsh-inc.h>
|
||||
#endif
|
||||
#include <log4cplus/helpers/socket.h>
|
||||
|
||||
#include <cerrno>
|
||||
#ifdef LOG4CPLUS_HAVE_ERRNO_H
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#ifdef LOG4CPLUS_HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_NETDB_H)
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace log4cplus {
|
||||
|
||||
namespace helpers {
|
||||
|
||||
#if defined(_WIN32)
|
||||
typedef SOCKET os_socket_type;
|
||||
os_socket_type const INVALID_OS_SOCKET_VALUE = INVALID_SOCKET;
|
||||
|
||||
struct ADDRINFOT_deleter
|
||||
{
|
||||
void
|
||||
operator () (ADDRINFOA * ptr) const
|
||||
{
|
||||
FreeAddrInfoA(ptr);
|
||||
}
|
||||
|
||||
void
|
||||
operator () (ADDRINFOW * ptr) const
|
||||
{
|
||||
FreeAddrInfoW(ptr);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct socket_closer
|
||||
{
|
||||
void
|
||||
operator () (SOCKET s)
|
||||
{
|
||||
if (s && s != INVALID_OS_SOCKET_VALUE)
|
||||
{
|
||||
DWORD const eno = WSAGetLastError();
|
||||
::closesocket(s);
|
||||
WSASetLastError(eno);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#else
|
||||
typedef int os_socket_type;
|
||||
os_socket_type const INVALID_OS_SOCKET_VALUE = -1;
|
||||
|
||||
|
||||
struct addrinfo_deleter
|
||||
{
|
||||
void
|
||||
operator () (struct addrinfo * ptr) const
|
||||
{
|
||||
freeaddrinfo(ptr);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct socket_closer
|
||||
{
|
||||
void
|
||||
operator () (os_socket_type s)
|
||||
{
|
||||
if (s >= 0)
|
||||
{
|
||||
int const eno = errno;
|
||||
close(s);
|
||||
errno = eno;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
struct socket_holder
|
||||
{
|
||||
os_socket_type sock;
|
||||
|
||||
socket_holder()
|
||||
: sock(INVALID_OS_SOCKET_VALUE)
|
||||
{ }
|
||||
|
||||
socket_holder(os_socket_type s)
|
||||
: sock(s)
|
||||
{ }
|
||||
|
||||
~socket_holder()
|
||||
{
|
||||
socket_closer()(sock);
|
||||
}
|
||||
|
||||
void
|
||||
reset(os_socket_type s = INVALID_OS_SOCKET_VALUE)
|
||||
{
|
||||
if (sock != INVALID_OS_SOCKET_VALUE)
|
||||
socket_closer()(sock);
|
||||
|
||||
sock = s;
|
||||
}
|
||||
|
||||
os_socket_type
|
||||
detach()
|
||||
{
|
||||
os_socket_type s = sock;
|
||||
sock = INVALID_OS_SOCKET_VALUE;
|
||||
return s;
|
||||
}
|
||||
|
||||
socket_holder(socket_holder &&) = delete;
|
||||
socket_holder(socket_holder const &) = delete;
|
||||
|
||||
socket_holder operator = (socket_holder &&) = delete;
|
||||
socket_holder operator = (socket_holder const &) = delete;
|
||||
};
|
||||
|
||||
|
||||
static inline
|
||||
os_socket_type
|
||||
to_os_socket (SOCKET_TYPE const & x)
|
||||
{
|
||||
return static_cast<os_socket_type>(x);
|
||||
}
|
||||
|
||||
|
||||
static inline
|
||||
SOCKET_TYPE
|
||||
to_log4cplus_socket (os_socket_type const & x)
|
||||
{
|
||||
return static_cast<SOCKET_TYPE>(x);
|
||||
}
|
||||
|
||||
|
||||
static inline
|
||||
void
|
||||
set_last_socket_error (int err)
|
||||
{
|
||||
errno = err;
|
||||
}
|
||||
|
||||
|
||||
static inline
|
||||
int
|
||||
get_last_socket_error ()
|
||||
{
|
||||
return errno;
|
||||
}
|
||||
|
||||
|
||||
} // namespace helpers {
|
||||
|
||||
} // namespace log4cplus {
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_INTERNAL_SOCKET_H_
|
|
@ -0,0 +1,645 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: Layout.h
|
||||
// Created: 6/2001
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2001-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_LAYOUT_HEADER_
|
||||
#define LOG4CPLUS_LAYOUT_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/loglevel.h>
|
||||
#include <log4cplus/streams.h>
|
||||
#include <log4cplus/tstring.h>
|
||||
#include <log4cplus/helpers/timehelper.h>
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace log4cplus {
|
||||
|
||||
// Forward Declarations
|
||||
namespace pattern
|
||||
{
|
||||
|
||||
class PatternConverter;
|
||||
|
||||
}
|
||||
|
||||
|
||||
namespace helpers
|
||||
{
|
||||
|
||||
class Properties;
|
||||
|
||||
}
|
||||
|
||||
|
||||
namespace spi
|
||||
{
|
||||
|
||||
class InternalLoggingEvent;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This class is used to layout strings sent to an {@link
|
||||
* log4cplus::Appender}.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT Layout
|
||||
{
|
||||
public:
|
||||
Layout();
|
||||
Layout(const helpers::Properties& properties);
|
||||
virtual ~Layout() = 0;
|
||||
|
||||
virtual void formatAndAppend(log4cplus::tostream& output,
|
||||
const log4cplus::spi::InternalLoggingEvent& event) = 0;
|
||||
|
||||
protected:
|
||||
LogLevelManager& llmCache;
|
||||
|
||||
private:
|
||||
// Disable copy
|
||||
Layout(const Layout&);
|
||||
Layout& operator=(Layout const &);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* SimpleLayout consists of the LogLevel of the log statement,
|
||||
* followed by " - " and then the log message itself. For example,
|
||||
*
|
||||
* <pre>
|
||||
* DEBUG - Hello world
|
||||
* </pre>
|
||||
*
|
||||
* {@link PatternLayout} offers a much more powerful alternative.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT SimpleLayout
|
||||
: public Layout
|
||||
{
|
||||
public:
|
||||
SimpleLayout();
|
||||
SimpleLayout(const log4cplus::helpers::Properties& properties);
|
||||
virtual ~SimpleLayout();
|
||||
|
||||
virtual void formatAndAppend(log4cplus::tostream& output,
|
||||
const log4cplus::spi::InternalLoggingEvent& event);
|
||||
|
||||
private:
|
||||
// Disallow copying of instances of this class
|
||||
SimpleLayout(const SimpleLayout&);
|
||||
SimpleLayout& operator=(const SimpleLayout&);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* TTCC layout format consists of time, thread, Logger and nested
|
||||
* diagnostic context information, hence the name.
|
||||
*
|
||||
* The time format depends on the <code>DateFormat</code> used. Use the
|
||||
* <code>Use_gmtime</code> to specify whether messages should be logged
|
||||
* using <code>localtime</code> or <code>gmtime</code>. There are also
|
||||
* <code>ThreadPrinting</code>, <code>CategoryPrefixing</code> and
|
||||
* <code>ContextPrinting</code> properties to turn on and off thread name,
|
||||
* logger name and NDC context printing respectively.
|
||||
*
|
||||
* Here is an example TTCCLayout output:
|
||||
*
|
||||
* ~~~~
|
||||
* 1 [0x60004dca0] WARN test.TestThread <> - Thread-3 TestThread.run()- Starting...
|
||||
* 1 [0x60004dca0] TRACE SlowObject <Thread-3 loop> - ENTER: SlowObject::doSomething()
|
||||
* 2 [0x60004b030] INFO SlowObject <Thread-0 loop> - Actually doing something...1, 2, 3, testing...DONE
|
||||
* 2 [0x60004b130] INFO SlowObject <Thread-1 loop> - Actually doing something...
|
||||
* 2 [0x60004b030] TRACE SlowObject <Thread-0 loop> - EXIT: SlowObject::doSomething()
|
||||
* 2 [0x60004b030] TRACE SlowObject <Thread-0 loop> - ENTER: SlowObject::doSomething()
|
||||
* 3 [0x60004b130] INFO SlowObject <Thread-1 loop> - Actually doing something...1, 2, 3, testing...DONE
|
||||
* 3 [0x60004cad0] INFO SlowObject <Thread-2 loop> - Actually doing something...
|
||||
* ~~~~
|
||||
*
|
||||
* The first field is the number of milliseconds elapsed since
|
||||
* the start of the program.
|
||||
*
|
||||
* The second field is the thread outputting the log
|
||||
* statement. (The value is the same as that of the `t` formatter
|
||||
* for PatternLayout.)
|
||||
*
|
||||
* The third field is the LogLevel.
|
||||
*
|
||||
* The fourth field is the logger to which the statement belongs.
|
||||
*
|
||||
* The fifth field (just before the '-') is the nested
|
||||
* diagnostic context. Note the nested diagnostic context may be
|
||||
* empty as in the first two statements. The text after the '-'
|
||||
* is the message of the statement.
|
||||
*
|
||||
* PatternLayout offers a much more flexible alternative.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT TTCCLayout
|
||||
: public Layout
|
||||
{
|
||||
public:
|
||||
TTCCLayout(bool use_gmtime = false, bool thread_printing = true,
|
||||
bool category_prefixes = true, bool context_printing = true);
|
||||
TTCCLayout(const log4cplus::helpers::Properties& properties);
|
||||
virtual ~TTCCLayout();
|
||||
|
||||
virtual void formatAndAppend(log4cplus::tostream& output,
|
||||
const log4cplus::spi::InternalLoggingEvent& event);
|
||||
|
||||
bool getThreadPrinting() const;
|
||||
void setThreadPrinting(bool);
|
||||
|
||||
bool getCategoryPrefixing() const;
|
||||
void setCategoryPrefixing(bool);
|
||||
|
||||
bool getContextPrinting() const;
|
||||
void setContextPrinting(bool);
|
||||
|
||||
protected:
|
||||
log4cplus::tstring dateFormat;
|
||||
bool use_gmtime = false;
|
||||
bool thread_printing = true;
|
||||
bool category_prefixing = true;
|
||||
bool context_printing = true;
|
||||
|
||||
private:
|
||||
// Disallow copying of instances of this class
|
||||
TTCCLayout(const TTCCLayout&);
|
||||
TTCCLayout& operator=(const TTCCLayout&);
|
||||
};
|
||||
|
||||
|
||||
LOG4CPLUS_EXPORT helpers::Time const & getTTCCLayoutTimeBase ();
|
||||
|
||||
|
||||
/**
|
||||
* A flexible layout configurable with pattern string.
|
||||
*
|
||||
* The goal of this class is to format a InternalLoggingEvent and return
|
||||
* the results as a string. The results depend on the <em>conversion
|
||||
* pattern</em>.
|
||||
*
|
||||
* The conversion pattern is closely related to the conversion
|
||||
* pattern of the printf function in C. A conversion pattern is
|
||||
* composed of literal text and format control expressions called
|
||||
* <em>conversion specifiers</em>.
|
||||
*
|
||||
* <i>You are free to insert any literal text within the conversion
|
||||
* pattern.</i>
|
||||
*
|
||||
* Each conversion specifier starts with a percent sign (%%) and is
|
||||
* followed by optional <em>format modifiers</em> and a <em>conversion
|
||||
* character</em>. The conversion character specifies the type of
|
||||
* data, e.g. Logger, LogLevel, date, thread name. The format
|
||||
* modifiers control such things as field width, padding, left and
|
||||
* right justification. The following is a simple example.
|
||||
*
|
||||
* Let the conversion pattern be `"%-5p [%t]: %m%n"` and assume
|
||||
* that the log4cplus environment was set to use a PatternLayout. Then the
|
||||
* statements
|
||||
*
|
||||
* ~~~~{.c}
|
||||
* Logger root = Logger.getRoot();
|
||||
* LOG4CPLUS_DEBUG(root, "Message 1");
|
||||
* LOG4CPLUS_WARN(root, "Message 2");
|
||||
* ~~~~
|
||||
*
|
||||
* would yield the output
|
||||
*
|
||||
* ~~~~
|
||||
* DEBUG [main]: Message 1
|
||||
* WARN [main]: Message 2
|
||||
* ~~~~
|
||||
*
|
||||
* Note that there is no explicit separator between text and
|
||||
* conversion specifiers. The pattern parser knows when it has reached
|
||||
* the end of a conversion specifier when it reads a conversion
|
||||
* character. In the example above the conversion specifier
|
||||
* <b>"%-5p"</b> means the LogLevel of the logging event should be left
|
||||
* justified to a width of five characters.
|
||||
*
|
||||
* The recognized conversion characters are
|
||||
*
|
||||
* <table border="1" CELLPADDING="8">
|
||||
* <tr>
|
||||
* <td>Conversion Character</td>
|
||||
* <td>Effect</td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td align=center><b>b</b></td>
|
||||
*
|
||||
* <td>Used to output file name component of path name.
|
||||
* E.g. <tt>main.cxx</tt> from path <tt>../../main.cxx</tt>.</td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td align=center><b>c</b></td>
|
||||
*
|
||||
* <td>Used to output the logger of the logging event. The
|
||||
* logger conversion specifier can be optionally followed by
|
||||
* <em>precision specifier</em>, that is a decimal constant in
|
||||
* brackets.
|
||||
*
|
||||
* If a precision specifier is given, then only the corresponding
|
||||
* number of right most components of the logger name will be
|
||||
* printed. By default the logger name is printed in full.
|
||||
*
|
||||
* For example, for the logger name "a.b.c" the pattern
|
||||
* <b>%c{2}</b> will output "b.c".
|
||||
*
|
||||
* </td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td align=center><b>d</b></td>
|
||||
*
|
||||
* <td>Used to output the date of the logging event in <b>UTC</b>.
|
||||
*
|
||||
* The date conversion specifier may be followed by a <em>date format
|
||||
* specifier</em> enclosed between braces. For example, <b>%%d{%%H:%%M:%%s}</b>
|
||||
* or <b>%%d{%%d %%b %%Y %%H:%%M:%%s}</b>. If no date format
|
||||
* specifier is given then <b>%%d{%%d %%m %%Y %%H:%%M:%%s}</b>
|
||||
* is assumed.
|
||||
*
|
||||
* The Following format options are possible:
|
||||
* <ul>
|
||||
* <li>%%a -- Abbreviated weekday name</li>
|
||||
* <li>%%A -- Full weekday name</li>
|
||||
* <li>%%b -- Abbreviated month name</li>
|
||||
* <li>%%B -- Full month name</li>
|
||||
* <li>%%c -- Standard date and time string</li>
|
||||
* <li>%%d -- Day of month as a decimal(1-31)</li>
|
||||
* <li>%%H -- Hour(0-23)</li>
|
||||
* <li>%%I -- Hour(1-12)</li>
|
||||
* <li>%%j -- Day of year as a decimal(1-366)</li>
|
||||
* <li>%%m -- Month as decimal(1-12)</li>
|
||||
* <li>%%M -- Minute as decimal(0-59)</li>
|
||||
* <li>%%p -- Locale's equivalent of AM or PM</li>
|
||||
* <li>%%q -- milliseconds as decimal(0-999) -- <b>Log4CPLUS specific</b>
|
||||
* <li>%%Q -- fractional milliseconds as decimal(0-999.999) -- <b>Log4CPLUS specific</b>
|
||||
* <li>%%S -- Second as decimal(0-59)</li>
|
||||
* <li>%%U -- Week of year, Sunday being first day(0-53)</li>
|
||||
* <li>%%w -- Weekday as a decimal(0-6, Sunday being 0)</li>
|
||||
* <li>%%W -- Week of year, Monday being first day(0-53)</li>
|
||||
* <li>%%x -- Standard date string</li>
|
||||
* <li>%%X -- Standard time string</li>
|
||||
* <li>%%y -- Year in decimal without century(0-99)</li>
|
||||
* <li>%%Y -- Year including century as decimal</li>
|
||||
* <li>%%Z -- Time zone name</li>
|
||||
* <li>%% -- The percent sign</li>
|
||||
* </ul>
|
||||
*
|
||||
* Lookup the documentation for the <code>strftime()</code> function
|
||||
* found in the <code><ctime></code> header for more information.
|
||||
* </td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td align=center><b>D</b></td>
|
||||
*
|
||||
* <td>Used to output the date of the logging event in <b>local</b> time.
|
||||
*
|
||||
* All of the above information applies.
|
||||
* </td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td align=center><b>E</b></td>
|
||||
*
|
||||
* <td>Used to output the value of a given environment variable. The
|
||||
* name of is supplied as an argument in brackets. If the variable does
|
||||
* exist then empty string will be used.
|
||||
*
|
||||
* For example, the pattern <b>%E{HOME}</b> will output the contents
|
||||
* of the HOME environment variable.
|
||||
* </td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td align=center><b>F</b></td>
|
||||
*
|
||||
* <td>Used to output the file name where the logging request was
|
||||
* issued.
|
||||
*
|
||||
* <b>NOTE</b> Unlike log4j, there is no performance penalty for
|
||||
* calling this method.</td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td align=center><b>h</b></td>
|
||||
*
|
||||
* <td>Used to output the hostname of this system (as returned
|
||||
* by gethostname(2)).
|
||||
*
|
||||
* <b>NOTE</b> The hostname is only retrieved once at
|
||||
* initialization.
|
||||
*
|
||||
* </td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td align=center><b>H</b></td>
|
||||
*
|
||||
* <td>Used to output the fully-qualified domain name of this
|
||||
* system (as returned by gethostbyname(2) for the hostname
|
||||
* returned by gethostname(2)).
|
||||
*
|
||||
* <b>NOTE</b> The hostname is only retrieved once at
|
||||
* initialization.
|
||||
*
|
||||
* </td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td align=center><b>l</b></td>
|
||||
*
|
||||
* <td>Equivalent to using "%F:%L"
|
||||
*
|
||||
* <b>NOTE:</b> Unlike log4j, there is no performance penalty for
|
||||
* calling this method.
|
||||
*
|
||||
* </td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td align=center><b>L</b></td>
|
||||
*
|
||||
* <td>Used to output the line number from where the logging request
|
||||
* was issued.
|
||||
*
|
||||
* <b>NOTE:</b> Unlike log4j, there is no performance penalty for
|
||||
* calling this method.
|
||||
*
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td align=center><b>m</b></td>
|
||||
* <td>Used to output the application supplied message associated with
|
||||
* the logging event.</td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td align=center><b>M</b></td>
|
||||
*
|
||||
* <td>Used to output function name using
|
||||
* <code>__FUNCTION__</code> or similar macro.
|
||||
*
|
||||
* <b>NOTE</b> The <code>__FUNCTION__</code> macro is not
|
||||
* standard but it is common extension provided by all compilers
|
||||
* (as of 2010). In case it is missing or in case this feature
|
||||
* is disabled using the
|
||||
* <code>LOG4CPLUS_DISABLE_FUNCTION_MACRO</code> macro, %M
|
||||
* expands to an empty string.</td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td align=center><b>n</b></td>
|
||||
*
|
||||
* <td>Outputs the platform dependent line separator character or
|
||||
* characters.
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td align=center><b>p</b></td>
|
||||
* <td>Used to output the LogLevel of the logging event.</td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td align=center><b>r</b></td>
|
||||
* <td>Used to output miliseconds since program start
|
||||
* of the logging event.</td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td align=center><b>t</b></td>
|
||||
*
|
||||
* <td>Used to output the thread ID of the thread that generated
|
||||
* the logging event. (This is either `pthread_t` value returned
|
||||
* by `pthread_self()` on POSIX platforms or thread ID returned
|
||||
* by `GetCurrentThreadId()` on Windows.)</td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td align=center><b>T</b></td>
|
||||
*
|
||||
* <td>Used to output alternative name of the thread that generated the
|
||||
* logging event.</td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td align=center><b>i</b></td>
|
||||
*
|
||||
* <td>Used to output the process ID of the process that generated the
|
||||
* logging event.</td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td align=center><b>x</b></td>
|
||||
*
|
||||
* <td>Used to output the NDC (nested diagnostic context) associated
|
||||
* with the thread that generated the logging event.
|
||||
* </td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td align=center><b>X</b></td>
|
||||
*
|
||||
* <td>Used to output the MDC (mapped diagnostic context)
|
||||
* associated with the thread that generated the logging
|
||||
* event. It takes optional key parameter. Without the key
|
||||
* paramter (%%X), it outputs the whole MDC map. With the key
|
||||
* (%%X{key}), it outputs just the key's value.
|
||||
* </td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td align=center><b>"%%"</b></td>
|
||||
* <td>The sequence "%%" outputs a single percent sign.
|
||||
* </td>
|
||||
* </tr>
|
||||
*
|
||||
* </table>
|
||||
*
|
||||
* By default the relevant information is output as is. However,
|
||||
* with the aid of format modifiers it is possible to change the
|
||||
* minimum field width, the maximum field width and justification.
|
||||
*
|
||||
* The optional format modifier is placed between the percent sign
|
||||
* and the conversion character.
|
||||
*
|
||||
* The first optional format modifier is the <em>left justification
|
||||
* flag</em> which is just the minus (-) character. Then comes the
|
||||
* optional <em>minimum field width</em> modifier. This is a decimal
|
||||
* constant that represents the minimum number of characters to
|
||||
* output. If the data item requires fewer characters, it is padded on
|
||||
* either the left or the right until the minimum width is
|
||||
* reached. The default is to pad on the left (right justify) but you
|
||||
* can specify right padding with the left justification flag. The
|
||||
* padding character is space. If the data item is larger than the
|
||||
* minimum field width, the field is expanded to accommodate the
|
||||
* data. The value is never truncated.
|
||||
*
|
||||
* This behavior can be changed using the <em>maximum field
|
||||
* width</em> modifier which is designated by a period followed by a
|
||||
* decimal constant. If the data item is longer than the maximum
|
||||
* field, then the extra characters are removed from the
|
||||
* <em>beginning</em> of the data item and not from the end. For
|
||||
* example, it the maximum field width is eight and the data item is
|
||||
* ten characters long, then the first two characters of the data item
|
||||
* are dropped. This behavior deviates from the printf function in C
|
||||
* where truncation is done from the end.
|
||||
*
|
||||
* Below are various format modifier examples for the logger
|
||||
* conversion specifier.
|
||||
*
|
||||
*
|
||||
* <TABLE BORDER=1 CELLPADDING=8>
|
||||
* <tr>
|
||||
* <td>Format modifier</td>
|
||||
* <td>left justify</td>
|
||||
* <td>minimum width</td>
|
||||
* <td>maximum width</td>
|
||||
* <td>comment</td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td align=center>%20c</td>
|
||||
* <td align=center>false</td>
|
||||
* <td align=center>20</td>
|
||||
* <td align=center>none</td>
|
||||
*
|
||||
* <td>Left pad with spaces if the logger name is less than 20
|
||||
* characters long.
|
||||
* </tr>
|
||||
*
|
||||
* <tr> <td align=center>%-20c</td> <td align=center>true</td> <td
|
||||
* align=center>20</td> <td align=center>none</td> <td>Right pad with
|
||||
* spaces if the logger name is less than 20 characters long.
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td align=center>%.30c</td>
|
||||
* <td align=center>NA</td>
|
||||
* <td align=center>none</td>
|
||||
* <td align=center>30</td>
|
||||
*
|
||||
* <td>Truncate from the beginning if the logger name is longer than 30
|
||||
* characters.
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td align=center>%20.30c</td>
|
||||
* <td align=center>false</td>
|
||||
* <td align=center>20</td>
|
||||
* <td align=center>30</td>
|
||||
*
|
||||
* <td>Left pad with spaces if the logger name is shorter than 20
|
||||
* characters. However, if logger name is longer than 30 characters,
|
||||
* then truncate from the beginning.
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td align=center>%-20.30c</td>
|
||||
* <td align=center>true</td>
|
||||
* <td align=center>20</td>
|
||||
* <td align=center>30</td>
|
||||
*
|
||||
* <td>Right pad with spaces if the logger name is shorter than 20
|
||||
* characters. However, if logger name is longer than 30 characters,
|
||||
* then truncate from the beginning.
|
||||
* </tr>
|
||||
*
|
||||
* </table>
|
||||
*
|
||||
* Below are some examples of conversion patterns.
|
||||
*
|
||||
* <dl>
|
||||
*
|
||||
* <dt><b>"%r [%t] %-5p %c %x - %m%n"</b>
|
||||
* <dd>This is essentially the TTCC layout.
|
||||
*
|
||||
* <dt><b>"%-6r [%15.15t] %-5p %30.30c %x - %m%n"</b>
|
||||
*
|
||||
* <dd>Similar to the TTCC layout except that the relative time is
|
||||
* right padded if less than 6 digits, thread name is right padded if
|
||||
* less than 15 characters and truncated if longer and the logger
|
||||
* name is left padded if shorter than 30 characters and truncated if
|
||||
* longer.
|
||||
*
|
||||
* </dl>
|
||||
*
|
||||
* The above text is largely inspired from Peter A. Darnell and
|
||||
* Philip E. Margolis' highly recommended book "C -- a Software
|
||||
* Engineering Approach", ISBN 0-387-97389-3.
|
||||
*
|
||||
* <h3>Properties</h3>
|
||||
*
|
||||
* <dl>
|
||||
* <dt><tt>NDCMaxDepth</tt></dt>
|
||||
* <dd>This property limits how many deepest NDC components will
|
||||
* be printed by <b>%%x</b> specifier.</dd>
|
||||
*
|
||||
* <dt><tt>ConversionPattern</tt></dt>
|
||||
* <dd>This property specifies conversion pattern.</dd>
|
||||
* </dl>
|
||||
*
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT PatternLayout
|
||||
: public Layout
|
||||
{
|
||||
public:
|
||||
// Ctors and dtor
|
||||
PatternLayout(const log4cplus::tstring& pattern);
|
||||
PatternLayout(const log4cplus::helpers::Properties& properties);
|
||||
virtual ~PatternLayout();
|
||||
|
||||
virtual void formatAndAppend(log4cplus::tostream& output,
|
||||
const log4cplus::spi::InternalLoggingEvent& event);
|
||||
|
||||
protected:
|
||||
void init(const log4cplus::tstring& pattern, unsigned ndcMaxDepth = 0);
|
||||
|
||||
// Data
|
||||
log4cplus::tstring pattern;
|
||||
std::vector<std::unique_ptr<pattern::PatternConverter> > parsedPattern;
|
||||
|
||||
private:
|
||||
// Disallow copying of instances of this class
|
||||
PatternLayout(const PatternLayout&);
|
||||
PatternLayout& operator=(const PatternLayout&);
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // end namespace log4cplus
|
||||
|
||||
#endif // LOG4CPLUS_LAYOUT_HEADER_
|
|
@ -0,0 +1,66 @@
|
|||
// Copyright (C) 2015-2017, Vaclav Haisman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef LOG4CPLUS_LOG4CPLUS_HXX
|
||||
#define LOG4CPLUS_LOG4CPLUS_HXX
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/version.h>
|
||||
#include <log4cplus/loglevel.h>
|
||||
#include <log4cplus/logger.h>
|
||||
#include <log4cplus/layout.h>
|
||||
#include <log4cplus/hierarchy.h>
|
||||
#include <log4cplus/loggingmacros.h>
|
||||
#include <log4cplus/tracelogger.h>
|
||||
#include <log4cplus/configurator.h>
|
||||
#include <log4cplus/appender.h>
|
||||
#include <log4cplus/mdc.h>
|
||||
#include <log4cplus/ndc.h>
|
||||
#include <log4cplus/initializer.h>
|
||||
#include <log4cplus/helpers/property.h>
|
||||
#include <log4cplus/spi/factory.h>
|
||||
#include <log4cplus/spi/filter.h>
|
||||
#include <log4cplus/spi/loggingevent.h>
|
||||
|
||||
#include <log4cplus/asyncappender.h>
|
||||
#include <log4cplus/consoleappender.h>
|
||||
#include <log4cplus/fileappender.h>
|
||||
#include <log4cplus/socketappender.h>
|
||||
#include <log4cplus/syslogappender.h>
|
||||
#include <log4cplus/nullappender.h>
|
||||
|
||||
#if defined (LOG4CPLUS_WITH_UNIT_TESTS)
|
||||
namespace log4cplus
|
||||
{
|
||||
|
||||
LOG4CPLUS_EXPORT int unit_tests_main (int argc, char* argv[]);
|
||||
|
||||
} // namespace log4cplus
|
||||
#endif
|
||||
|
||||
#endif // LOG4CPLUS_LOG4CPLUS_HXX
|
|
@ -0,0 +1,91 @@
|
|||
// -*- C++ -*-
|
||||
// Module: LOG4CPLUS
|
||||
// File: log4judpappender.h
|
||||
// Created: 7/2012
|
||||
// Author: Siva Chandran P
|
||||
//
|
||||
//
|
||||
// Copyright 2012-2017 Siva Chandran P
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_LOG4J_UDP_APPENDER_HEADER_
|
||||
#define LOG4CPLUS_LOG4J_UDP_APPENDER_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
#include <log4cplus/appender.h>
|
||||
#include <log4cplus/helpers/socket.h>
|
||||
|
||||
namespace log4cplus {
|
||||
|
||||
/**
|
||||
* Sends log events as Log4j XML to a remote a log server.
|
||||
*
|
||||
* The Log4jUdpAppender has the following properties:
|
||||
*
|
||||
* <ul>
|
||||
* <li>Remote logging is non-intrusive as far as the log event
|
||||
* is concerned. In other words, the event will be logged with
|
||||
* the same time stamp, NDC, location info as if it were logged
|
||||
* locally by the client.</li>
|
||||
*
|
||||
* <li>Remote logging uses the UDP protocol.</li>
|
||||
* </ul>
|
||||
*
|
||||
* <h3>Properties</h3>
|
||||
* <dl>
|
||||
* <dt><tt>host</tt></dt>
|
||||
* <dd>Remote host name to connect and send events to.</dd>
|
||||
*
|
||||
* <dt><tt>port</tt></dt>
|
||||
* <dd>Port on remote host to send events to. Default is 5000.</dd>
|
||||
*
|
||||
* <dt><tt>IPv6</tt></dt>
|
||||
* <dd>Boolean value specifying whether to use IPv6 (true) or IPv4
|
||||
* (false). Default value is false.</dd>
|
||||
*
|
||||
* </dl>
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT Log4jUdpAppender : public Appender {
|
||||
public:
|
||||
// Ctors
|
||||
Log4jUdpAppender(const log4cplus::tstring& host, int port,
|
||||
bool ipv6 = false);
|
||||
Log4jUdpAppender(const log4cplus::helpers::Properties & properties);
|
||||
|
||||
// Dtor
|
||||
~Log4jUdpAppender();
|
||||
|
||||
// Methods
|
||||
virtual void close();
|
||||
|
||||
protected:
|
||||
void openSocket();
|
||||
virtual void append(const spi::InternalLoggingEvent& event);
|
||||
|
||||
// Data
|
||||
log4cplus::helpers::Socket socket;
|
||||
log4cplus::tstring host;
|
||||
int port;
|
||||
bool ipv6 = false;
|
||||
|
||||
private:
|
||||
// Disallow copying of instances of this class
|
||||
Log4jUdpAppender(const Log4jUdpAppender&);
|
||||
Log4jUdpAppender& operator=(const Log4jUdpAppender&);
|
||||
};
|
||||
} // end namespace log4cplus
|
||||
|
||||
#endif // LOG4CPLUS_LOG4J_UDP_APPENDER_HEADER_
|
|
@ -0,0 +1,325 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: logger.h
|
||||
// Created: 6/2001
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2001-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file
|
||||
* This header defines the Logger class and the logging macros. */
|
||||
|
||||
#ifndef LOG4CPLUS_LOGGERHEADER_
|
||||
#define LOG4CPLUS_LOGGERHEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/loglevel.h>
|
||||
#include <log4cplus/tstring.h>
|
||||
#include <log4cplus/spi/appenderattachable.h>
|
||||
#include <log4cplus/spi/loggerfactory.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace log4cplus
|
||||
{
|
||||
// Forward declarations
|
||||
|
||||
class Appender;
|
||||
class Hierarchy;
|
||||
class HierarchyLocker;
|
||||
class DefaultLoggerFactory;
|
||||
|
||||
namespace spi
|
||||
{
|
||||
|
||||
class LoggerImpl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** \typedef std::vector<Logger> LoggerList
|
||||
* This is a list of {@link Logger Loggers}. */
|
||||
typedef std::vector<Logger> LoggerList;
|
||||
|
||||
|
||||
/**
|
||||
* This is the central class in the log4cplus package. One of the
|
||||
* distintive features of log4cplus are hierarchical loggers and their
|
||||
* evaluation.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT Logger
|
||||
: public log4cplus::spi::AppenderAttachable
|
||||
{
|
||||
public:
|
||||
// Static Methods
|
||||
/**
|
||||
* Returns <code>true </code>if the named logger exists
|
||||
* (in the default hierarchy).
|
||||
*
|
||||
* @param name The name of the logger to search for.
|
||||
*/
|
||||
static bool exists(const log4cplus::tstring_view& name);
|
||||
|
||||
/*
|
||||
* Returns all the currently defined loggers in the default
|
||||
* hierarchy.
|
||||
*
|
||||
* The root logger is <em>not</em> included in the returned
|
||||
* list.
|
||||
*/
|
||||
static LoggerList getCurrentLoggers();
|
||||
|
||||
/**
|
||||
* Return the default Hierarchy instance.
|
||||
*/
|
||||
static Hierarchy& getDefaultHierarchy();
|
||||
|
||||
/**
|
||||
* Retrieve a logger with name <code>name</code>. If the named
|
||||
* logger already exists, then the existing instance will be returned.
|
||||
* Otherwise, a new instance is created.
|
||||
*
|
||||
* By default, loggers do not have a set LogLevel but inherit
|
||||
* it from the hierarchy. This is one of the central features of
|
||||
* log4cplus.
|
||||
*
|
||||
* @param name The name of the logger to retrieve.
|
||||
*/
|
||||
static Logger getInstance(const log4cplus::tstring_view& name);
|
||||
|
||||
/**
|
||||
* Like getInstance() except that the type of logger
|
||||
* instantiated depends on the type returned by the {@link
|
||||
* spi::LoggerFactory#makeNewLoggerInstance} method of the
|
||||
* <code>factory</code> parameter.
|
||||
*
|
||||
* This method is intended to be used by sub-classes.
|
||||
*
|
||||
* @param name The name of the logger to retrieve.
|
||||
* @param factory A {@link spi::LoggerFactory} implementation that will
|
||||
* actually create a new Instance.
|
||||
*/
|
||||
static Logger getInstance(const log4cplus::tstring_view& name,
|
||||
spi::LoggerFactory& factory);
|
||||
|
||||
/**
|
||||
* Return the root of the default logger hierrachy.
|
||||
*
|
||||
* The root logger is always instantiated and available. It's
|
||||
* name is "root".
|
||||
*
|
||||
* Nevertheless, calling {@link #getInstance
|
||||
* Logger.getInstance("root")} does not retrieve the root logger
|
||||
* but a logger just under root named "root".
|
||||
*/
|
||||
static Logger getRoot();
|
||||
|
||||
/**
|
||||
* Calling this method will <em>safely</em> close and remove all
|
||||
* appenders in all the loggers including root contained in the
|
||||
* default hierachy.
|
||||
*
|
||||
* Some appenders such as SocketAppender need to be closed before the
|
||||
* application exits. Otherwise, pending logging events might be
|
||||
* lost.
|
||||
*
|
||||
* The <code>shutdown</code> method is careful to close nested
|
||||
* appenders before closing regular appenders. This is allows
|
||||
* configurations where a regular appender is attached to a logger
|
||||
* and again to a nested appender.
|
||||
*/
|
||||
static void shutdown();
|
||||
|
||||
// Non-Static Methods
|
||||
/**
|
||||
* If <code>assertionVal</code> parameter is <code>false</code>, then
|
||||
* logs <code>msg</code> with FATAL_LOG_LEVEL log level.
|
||||
*
|
||||
* @param assertionVal Truth value of assertion condition.
|
||||
* @param msg The message to print if <code>assertion</code> is
|
||||
* false.
|
||||
*/
|
||||
void assertion(bool assertionVal, const log4cplus::tstring_view& msg) const;
|
||||
|
||||
/**
|
||||
* Close all attached appenders implementing the AppenderAttachable
|
||||
* interface.
|
||||
*/
|
||||
void closeNestedAppenders() const;
|
||||
|
||||
/**
|
||||
* Check whether this logger is enabled for a given
|
||||
* LogLevel passed as parameter.
|
||||
*
|
||||
* @return boolean True if this logger is enabled for <code>ll</code>.
|
||||
*/
|
||||
bool isEnabledFor(LogLevel ll) const;
|
||||
|
||||
/**
|
||||
* This generic form is intended to be used by wrappers.
|
||||
*/
|
||||
void log(LogLevel ll, const log4cplus::tstring_view& message,
|
||||
const char* file = LOG4CPLUS_CALLER_FILE (),
|
||||
int line = LOG4CPLUS_CALLER_LINE (),
|
||||
const char* function = LOG4CPLUS_CALLER_FUNCTION ()) const;
|
||||
|
||||
void log(spi::InternalLoggingEvent const &) const;
|
||||
|
||||
/**
|
||||
* This method creates a new logging event and logs the event
|
||||
* without further checks.
|
||||
*/
|
||||
void forcedLog(LogLevel ll, const log4cplus::tstring_view& message,
|
||||
const char* file = LOG4CPLUS_CALLER_FILE (),
|
||||
int line = LOG4CPLUS_CALLER_LINE (),
|
||||
const char* function = LOG4CPLUS_CALLER_FUNCTION ()) const;
|
||||
|
||||
void forcedLog(spi::InternalLoggingEvent const &) const;
|
||||
|
||||
/**
|
||||
* Call the appenders in the hierrachy starting at
|
||||
* <code>this</code>. If no appenders could be found, emit a
|
||||
* warning.
|
||||
*
|
||||
* This method calls all the appenders inherited from the
|
||||
* hierarchy circumventing any evaluation of whether to log or not
|
||||
* to log the particular log request.
|
||||
*
|
||||
* @param event the event to log.
|
||||
*/
|
||||
void callAppenders(const spi::InternalLoggingEvent& event) const;
|
||||
|
||||
/**
|
||||
* Starting from this logger, search the logger hierarchy for a
|
||||
* "set" LogLevel and return it. Otherwise, return the LogLevel of the
|
||||
* root logger.
|
||||
*
|
||||
* The Logger class is designed so that this method executes as
|
||||
* quickly as possible.
|
||||
*/
|
||||
LogLevel getChainedLogLevel() const;
|
||||
|
||||
/**
|
||||
* Returns the assigned LogLevel, if any, for this Logger.
|
||||
*
|
||||
* @return LogLevel - the assigned LogLevel, can be <code>NOT_SET_LOG_LEVEL</code>.
|
||||
*/
|
||||
LogLevel getLogLevel() const;
|
||||
|
||||
/**
|
||||
* Set the LogLevel of this Logger.
|
||||
*/
|
||||
void setLogLevel(LogLevel ll);
|
||||
|
||||
/**
|
||||
* Return the the {@link Hierarchy} where this <code>Logger</code> instance is
|
||||
* attached.
|
||||
*/
|
||||
Hierarchy& getHierarchy() const;
|
||||
|
||||
/**
|
||||
* Return the logger name.
|
||||
*/
|
||||
log4cplus::tstring const & getName() const;
|
||||
|
||||
/**
|
||||
* Get the additivity flag for this Logger instance.
|
||||
*/
|
||||
bool getAdditivity() const;
|
||||
|
||||
/**
|
||||
* Set the additivity flag for this Logger instance.
|
||||
*/
|
||||
void setAdditivity(bool additive);
|
||||
|
||||
// AppenderAttachable Methods
|
||||
virtual void addAppender(SharedAppenderPtr newAppender);
|
||||
|
||||
virtual SharedAppenderPtrList getAllAppenders();
|
||||
|
||||
virtual SharedAppenderPtr getAppender(const log4cplus::tstring& name);
|
||||
|
||||
virtual void removeAllAppenders();
|
||||
|
||||
virtual void removeAppender(SharedAppenderPtr appender);
|
||||
|
||||
virtual void removeAppender(const log4cplus::tstring& name);
|
||||
|
||||
Logger () LOG4CPLUS_NOEXCEPT;
|
||||
Logger(const Logger& rhs) LOG4CPLUS_NOEXCEPT;
|
||||
Logger& operator=(const Logger& rhs) LOG4CPLUS_NOEXCEPT;
|
||||
Logger (Logger && rhs) LOG4CPLUS_NOEXCEPT;
|
||||
Logger & operator = (Logger && rhs) LOG4CPLUS_NOEXCEPT;
|
||||
virtual ~Logger();
|
||||
|
||||
void swap (Logger &) LOG4CPLUS_NOEXCEPT;
|
||||
|
||||
/**
|
||||
* Used to retrieve the parent of this Logger in the
|
||||
* Logger tree.
|
||||
*/
|
||||
Logger getParent() const;
|
||||
|
||||
protected:
|
||||
// Data
|
||||
/** This is a pointer to the implementation class. */
|
||||
spi::LoggerImpl * value = nullptr;
|
||||
|
||||
private:
|
||||
// Ctors
|
||||
/**
|
||||
* This constructor created a new <code>Logger</code> instance
|
||||
* with a pointer to a Logger implementation.
|
||||
*
|
||||
* You should not create loggers directly.
|
||||
*
|
||||
* @param ptr A pointer to the Logger implementation. This value
|
||||
* cannot be NULL.
|
||||
*/
|
||||
Logger(spi::LoggerImpl * ptr) LOG4CPLUS_NOEXCEPT;
|
||||
|
||||
// Friends
|
||||
friend class log4cplus::spi::LoggerImpl;
|
||||
friend class log4cplus::Hierarchy;
|
||||
friend class log4cplus::HierarchyLocker;
|
||||
friend class log4cplus::DefaultLoggerFactory;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This class is used to create the default implementation of
|
||||
* the Logger class.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT DefaultLoggerFactory : public spi::LoggerFactory {
|
||||
public:
|
||||
Logger makeNewLoggerInstance(const log4cplus::tstring_view& name, Hierarchy& h);
|
||||
|
||||
protected:
|
||||
virtual spi::LoggerImpl * makeNewLoggerImplInstance(
|
||||
const log4cplus::tstring_view& name, Hierarchy& h);
|
||||
};
|
||||
|
||||
|
||||
} // end namespace log4cplus
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_LOGGERHEADER_
|
|
@ -0,0 +1,405 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: loggingmacros.h
|
||||
// Created: 8/2003
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2003-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file
|
||||
* This header defines the logging macros. */
|
||||
|
||||
#ifndef LOG4CPLUS_LOGGING_MACROS_HEADER_
|
||||
#define LOG4CPLUS_LOGGING_MACROS_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/streams.h>
|
||||
#include <log4cplus/logger.h>
|
||||
#include <log4cplus/helpers/snprintf.h>
|
||||
#include <log4cplus/tracelogger.h>
|
||||
#include <sstream>
|
||||
#include <utility>
|
||||
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \
|
||||
__pragma (warning (push)) \
|
||||
__pragma (warning (disable:4127))
|
||||
|
||||
#define LOG4CPLUS_RESTORE_DOWHILE_WARNING() \
|
||||
__pragma (warning (pop))
|
||||
|
||||
#else
|
||||
#define LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() /* empty */
|
||||
#define LOG4CPLUS_RESTORE_DOWHILE_WARNING() /* empty */
|
||||
|
||||
#endif
|
||||
|
||||
#define LOG4CPLUS_DOWHILE_NOTHING() \
|
||||
LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \
|
||||
do { } while (0) \
|
||||
LOG4CPLUS_RESTORE_DOWHILE_WARNING()
|
||||
|
||||
#if defined(LOG4CPLUS_DISABLE_FATAL) && !defined(LOG4CPLUS_DISABLE_ERROR)
|
||||
#define LOG4CPLUS_DISABLE_ERROR
|
||||
#endif
|
||||
#if defined(LOG4CPLUS_DISABLE_ERROR) && !defined(LOG4CPLUS_DISABLE_WARN)
|
||||
#define LOG4CPLUS_DISABLE_WARN
|
||||
#endif
|
||||
#if defined(LOG4CPLUS_DISABLE_WARN) && !defined(LOG4CPLUS_DISABLE_INFO)
|
||||
#define LOG4CPLUS_DISABLE_INFO
|
||||
#endif
|
||||
#if defined(LOG4CPLUS_DISABLE_INFO) && !defined(LOG4CPLUS_DISABLE_DEBUG)
|
||||
#define LOG4CPLUS_DISABLE_DEBUG
|
||||
#endif
|
||||
#if defined(LOG4CPLUS_DISABLE_DEBUG) && !defined(LOG4CPLUS_DISABLE_TRACE)
|
||||
#define LOG4CPLUS_DISABLE_TRACE
|
||||
#endif
|
||||
|
||||
|
||||
namespace log4cplus
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
|
||||
inline
|
||||
Logger
|
||||
macros_get_logger (Logger const & logger)
|
||||
{
|
||||
return logger;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
Logger const &
|
||||
macros_get_logger (Logger & logger)
|
||||
{
|
||||
return logger;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
Logger
|
||||
macros_get_logger (Logger && logger)
|
||||
{
|
||||
return std::move (logger);
|
||||
}
|
||||
|
||||
inline
|
||||
Logger
|
||||
macros_get_logger (tstring_view const & logger)
|
||||
{
|
||||
return Logger::getInstance (logger);
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
Logger
|
||||
macros_get_logger (tchar const * logger)
|
||||
{
|
||||
return Logger::getInstance (logger);
|
||||
}
|
||||
|
||||
|
||||
LOG4CPLUS_EXPORT void clear_tostringstream (tostringstream &);
|
||||
|
||||
|
||||
LOG4CPLUS_EXPORT log4cplus::tostringstream & get_macro_body_oss ();
|
||||
LOG4CPLUS_EXPORT log4cplus::helpers::snprintf_buf & get_macro_body_snprintf_buf ();
|
||||
LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &,
|
||||
log4cplus::LogLevel, log4cplus::tstring_view const &, char const *, int,
|
||||
char const *);
|
||||
LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &,
|
||||
log4cplus::LogLevel, log4cplus::tchar const *, char const *, int,
|
||||
char const *);
|
||||
|
||||
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace log4cplus
|
||||
|
||||
|
||||
#undef LOG4CPLUS_MACRO_FUNCTION
|
||||
#define LOG4CPLUS_MACRO_FUNCTION() nullptr
|
||||
#if ! defined (LOG4CPLUS_DISABLE_FUNCTION_MACRO)
|
||||
# if defined (LOG4CPLUS_HAVE_FUNCSIG_MACRO)
|
||||
# undef LOG4CPLUS_MACRO_FUNCTION
|
||||
# define LOG4CPLUS_MACRO_FUNCTION() __FUNCSIG__
|
||||
# elif defined (LOG4CPLUS_HAVE_PRETTY_FUNCTION_MACRO)
|
||||
# undef LOG4CPLUS_MACRO_FUNCTION
|
||||
# define LOG4CPLUS_MACRO_FUNCTION() __PRETTY_FUNCTION__
|
||||
# elif defined (LOG4CPLUS_HAVE_FUNCTION_MACRO)
|
||||
# undef LOG4CPLUS_MACRO_FUNCTION
|
||||
# define LOG4CPLUS_MACRO_FUNCTION() __FUNCTION__
|
||||
# elif defined (LOG4CPLUS_HAVE_FUNC_SYMBOL)
|
||||
# undef LOG4CPLUS_MACRO_FUNCTION
|
||||
# define LOG4CPLUS_MACRO_FUNCTION() __func__
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#undef LOG4CPLUS_MACRO_FILE
|
||||
#define LOG4CPLUS_MACRO_FILE() nullptr
|
||||
#if ! defined (LOG4CPLUS_DISABLE_FILE_MACRO)
|
||||
# undef LOG4CPLUS_MACRO_FILE
|
||||
# define LOG4CPLUS_MACRO_FILE() __FILE__
|
||||
#endif
|
||||
|
||||
|
||||
// Make TRACE and DEBUG log level unlikely and INFO, WARN, ERROR and
|
||||
// FATAL log level likely.
|
||||
#define LOG4CPLUS_MACRO_TRACE_LOG_LEVEL(pred) \
|
||||
LOG4CPLUS_UNLIKELY (pred)
|
||||
#define LOG4CPLUS_MACRO_DEBUG_LOG_LEVEL(pred) \
|
||||
LOG4CPLUS_UNLIKELY (pred)
|
||||
#define LOG4CPLUS_MACRO_INFO_LOG_LEVEL(pred) \
|
||||
LOG4CPLUS_LIKELY (pred)
|
||||
#define LOG4CPLUS_MACRO_WARN_LOG_LEVEL(pred) \
|
||||
LOG4CPLUS_LIKELY (pred)
|
||||
#define LOG4CPLUS_MACRO_ERROR_LOG_LEVEL(pred) \
|
||||
LOG4CPLUS_LIKELY (pred)
|
||||
#define LOG4CPLUS_MACRO_FATAL_LOG_LEVEL(pred) \
|
||||
LOG4CPLUS_LIKELY (pred)
|
||||
|
||||
|
||||
//! Dispatch to LOG4CPLUS_MACRO_LOGLEVEL_* depending on log level.
|
||||
#define LOG4CPLUS_MACRO_LOGLEVEL_PRED(pred, logLevel) \
|
||||
LOG4CPLUS_MACRO_ ## logLevel (pred)
|
||||
|
||||
|
||||
// Either use temporary instances of ostringstream
|
||||
// and snprintf_buf, or use thread-local instances.
|
||||
#if defined (LOG4CPLUS_MACRO_DISABLE_TLS)
|
||||
# define LOG4CPLUS_MACRO_INSTANTIATE_OSTRINGSTREAM(var) \
|
||||
log4cplus::tostringstream var
|
||||
|
||||
# define LOG4CPLUS_MACRO_INSTANTIATE_SNPRINTF_BUF(var) \
|
||||
log4cplus::helpers::snprintf_buf var
|
||||
|
||||
#else
|
||||
# define LOG4CPLUS_MACRO_INSTANTIATE_OSTRINGSTREAM(var) \
|
||||
log4cplus::tostringstream & var \
|
||||
= log4cplus::detail::get_macro_body_oss ()
|
||||
|
||||
# define LOG4CPLUS_MACRO_INSTANTIATE_SNPRINTF_BUF(var) \
|
||||
log4cplus::helpers::snprintf_buf & var \
|
||||
= log4cplus::detail::get_macro_body_snprintf_buf ()
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define LOG4CPLUS_MACRO_BODY(logger, logEvent, logLevel) \
|
||||
LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \
|
||||
do { \
|
||||
log4cplus::Logger const & _l \
|
||||
= log4cplus::detail::macros_get_logger (logger); \
|
||||
if (LOG4CPLUS_MACRO_LOGLEVEL_PRED ( \
|
||||
_l.isEnabledFor (log4cplus::logLevel), logLevel)) { \
|
||||
LOG4CPLUS_MACRO_INSTANTIATE_OSTRINGSTREAM (_log4cplus_buf); \
|
||||
_log4cplus_buf << logEvent; \
|
||||
log4cplus::detail::macro_forced_log (_l, \
|
||||
log4cplus::logLevel, _log4cplus_buf.str(), \
|
||||
LOG4CPLUS_MACRO_FILE (), __LINE__, \
|
||||
LOG4CPLUS_MACRO_FUNCTION ()); \
|
||||
} \
|
||||
} while (0) \
|
||||
LOG4CPLUS_RESTORE_DOWHILE_WARNING()
|
||||
|
||||
|
||||
#define LOG4CPLUS_MACRO_STR_BODY(logger, logEvent, logLevel) \
|
||||
LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \
|
||||
do { \
|
||||
log4cplus::Logger const & _l \
|
||||
= log4cplus::detail::macros_get_logger (logger); \
|
||||
if (LOG4CPLUS_MACRO_LOGLEVEL_PRED ( \
|
||||
_l.isEnabledFor (log4cplus::logLevel), logLevel)) { \
|
||||
log4cplus::detail::macro_forced_log (_l, \
|
||||
log4cplus::logLevel, logEvent, \
|
||||
LOG4CPLUS_MACRO_FILE (), __LINE__, \
|
||||
LOG4CPLUS_MACRO_FUNCTION ()); \
|
||||
} \
|
||||
} while(0) \
|
||||
LOG4CPLUS_RESTORE_DOWHILE_WARNING()
|
||||
|
||||
#define LOG4CPLUS_MACRO_FMT_BODY(logger, logLevel, ...) \
|
||||
LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \
|
||||
do { \
|
||||
log4cplus::Logger const & _l \
|
||||
= log4cplus::detail::macros_get_logger (logger); \
|
||||
if (LOG4CPLUS_MACRO_LOGLEVEL_PRED ( \
|
||||
_l.isEnabledFor (log4cplus::logLevel), logLevel)) { \
|
||||
LOG4CPLUS_MACRO_INSTANTIATE_SNPRINTF_BUF (_snpbuf); \
|
||||
log4cplus::tchar const * _logEvent \
|
||||
= _snpbuf.print (__VA_ARGS__); \
|
||||
log4cplus::detail::macro_forced_log (_l, \
|
||||
log4cplus::logLevel, _logEvent, \
|
||||
LOG4CPLUS_MACRO_FILE (), __LINE__, \
|
||||
LOG4CPLUS_MACRO_FUNCTION ()); \
|
||||
} \
|
||||
} while(0) \
|
||||
LOG4CPLUS_RESTORE_DOWHILE_WARNING()
|
||||
|
||||
/**
|
||||
* @def LOG4CPLUS_TRACE(logger, logEvent) This macro creates a
|
||||
* TraceLogger to log a TRACE_LOG_LEVEL message to <code>logger</code>
|
||||
* upon entry and exiting of a method.
|
||||
* <code>logEvent</code> will be streamed into an <code>ostream</code>.
|
||||
*/
|
||||
#if !defined(LOG4CPLUS_DISABLE_TRACE)
|
||||
#define LOG4CPLUS_TRACE_METHOD(logger, logEvent) \
|
||||
log4cplus::TraceLogger _log4cplus_trace_logger(logger, logEvent, \
|
||||
LOG4CPLUS_MACRO_FILE (), __LINE__, \
|
||||
LOG4CPLUS_MACRO_FUNCTION ());
|
||||
#define LOG4CPLUS_TRACE(logger, logEvent) \
|
||||
LOG4CPLUS_MACRO_BODY (logger, logEvent, TRACE_LOG_LEVEL)
|
||||
#define LOG4CPLUS_TRACE_STR(logger, logEvent) \
|
||||
LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, TRACE_LOG_LEVEL)
|
||||
#define LOG4CPLUS_TRACE_FMT(logger, ...) \
|
||||
LOG4CPLUS_MACRO_FMT_BODY (logger, TRACE_LOG_LEVEL, __VA_ARGS__)
|
||||
|
||||
#else
|
||||
#define LOG4CPLUS_TRACE_METHOD(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING()
|
||||
#define LOG4CPLUS_TRACE(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING()
|
||||
#define LOG4CPLUS_TRACE_STR(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING()
|
||||
#define LOG4CPLUS_TRACE_FMT(logger, logFmt, ...) LOG4CPLUS_DOWHILE_NOTHING()
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def LOG4CPLUS_DEBUG(logger, logEvent) This macro is used to log a
|
||||
* DEBUG_LOG_LEVEL message to <code>logger</code>.
|
||||
* <code>logEvent</code> will be streamed into an <code>ostream</code>.
|
||||
*/
|
||||
#if !defined(LOG4CPLUS_DISABLE_DEBUG)
|
||||
#define LOG4CPLUS_DEBUG(logger, logEvent) \
|
||||
LOG4CPLUS_MACRO_BODY (logger, logEvent, DEBUG_LOG_LEVEL)
|
||||
#define LOG4CPLUS_DEBUG_STR(logger, logEvent) \
|
||||
LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, DEBUG_LOG_LEVEL)
|
||||
#define LOG4CPLUS_DEBUG_FMT(logger, ...) \
|
||||
LOG4CPLUS_MACRO_FMT_BODY (logger, DEBUG_LOG_LEVEL, __VA_ARGS__)
|
||||
|
||||
#else
|
||||
#define LOG4CPLUS_DEBUG(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING()
|
||||
#define LOG4CPLUS_DEBUG_STR(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING()
|
||||
#define LOG4CPLUS_DEBUG_FMT(logger, ...) LOG4CPLUS_DOWHILE_NOTHING()
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def LOG4CPLUS_INFO(logger, logEvent) This macro is used to log a
|
||||
* INFO_LOG_LEVEL message to <code>logger</code>.
|
||||
* <code>logEvent</code> will be streamed into an <code>ostream</code>.
|
||||
*/
|
||||
#if !defined(LOG4CPLUS_DISABLE_INFO)
|
||||
#define LOG4CPLUS_INFO(logger, logEvent) \
|
||||
LOG4CPLUS_MACRO_BODY (logger, logEvent, INFO_LOG_LEVEL)
|
||||
#define LOG4CPLUS_INFO_STR(logger, logEvent) \
|
||||
LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, INFO_LOG_LEVEL)
|
||||
#define LOG4CPLUS_INFO_FMT(logger, ...) \
|
||||
LOG4CPLUS_MACRO_FMT_BODY (logger, INFO_LOG_LEVEL, __VA_ARGS__)
|
||||
|
||||
#else
|
||||
#define LOG4CPLUS_INFO(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING()
|
||||
#define LOG4CPLUS_INFO_STR(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING()
|
||||
#define LOG4CPLUS_INFO_FMT(logger, ...) LOG4CPLUS_DOWHILE_NOTHING()
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def LOG4CPLUS_WARN(logger, logEvent) This macro is used to log a
|
||||
* WARN_LOG_LEVEL message to <code>logger</code>.
|
||||
* <code>logEvent</code> will be streamed into an <code>ostream</code>.
|
||||
*/
|
||||
#if !defined(LOG4CPLUS_DISABLE_WARN)
|
||||
#define LOG4CPLUS_WARN(logger, logEvent) \
|
||||
LOG4CPLUS_MACRO_BODY (logger, logEvent, WARN_LOG_LEVEL)
|
||||
#define LOG4CPLUS_WARN_STR(logger, logEvent) \
|
||||
LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, WARN_LOG_LEVEL)
|
||||
#define LOG4CPLUS_WARN_FMT(logger, ...) \
|
||||
LOG4CPLUS_MACRO_FMT_BODY (logger, WARN_LOG_LEVEL, __VA_ARGS__)
|
||||
|
||||
#else
|
||||
#define LOG4CPLUS_WARN(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING()
|
||||
#define LOG4CPLUS_WARN_STR(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING()
|
||||
#define LOG4CPLUS_WARN_FMT(logger, ...) LOG4CPLUS_DOWHILE_NOTHING()
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def LOG4CPLUS_ERROR(logger, logEvent) This macro is used to log a
|
||||
* ERROR_LOG_LEVEL message to <code>logger</code>.
|
||||
* <code>logEvent</code> will be streamed into an <code>ostream</code>.
|
||||
*/
|
||||
#if !defined(LOG4CPLUS_DISABLE_ERROR)
|
||||
#define LOG4CPLUS_ERROR(logger, logEvent) \
|
||||
LOG4CPLUS_MACRO_BODY (logger, logEvent, ERROR_LOG_LEVEL)
|
||||
#define LOG4CPLUS_ERROR_STR(logger, logEvent) \
|
||||
LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, ERROR_LOG_LEVEL)
|
||||
#define LOG4CPLUS_ERROR_FMT(logger, ...) \
|
||||
LOG4CPLUS_MACRO_FMT_BODY (logger, ERROR_LOG_LEVEL, __VA_ARGS__)
|
||||
|
||||
#else
|
||||
#define LOG4CPLUS_ERROR(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING()
|
||||
#define LOG4CPLUS_ERROR_STR(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING()
|
||||
#define LOG4CPLUS_ERROR_FMT(logger, ...) LOG4CPLUS_DOWHILE_NOTHING()
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def LOG4CPLUS_FATAL(logger, logEvent) This macro is used to log a
|
||||
* FATAL_LOG_LEVEL message to <code>logger</code>.
|
||||
* <code>logEvent</code> will be streamed into an <code>ostream</code>.
|
||||
*/
|
||||
#if !defined(LOG4CPLUS_DISABLE_FATAL)
|
||||
#define LOG4CPLUS_FATAL(logger, logEvent) \
|
||||
LOG4CPLUS_MACRO_BODY (logger, logEvent, FATAL_LOG_LEVEL)
|
||||
#define LOG4CPLUS_FATAL_STR(logger, logEvent) \
|
||||
LOG4CPLUS_MACRO_STR_BODY (logger, logEvent, FATAL_LOG_LEVEL)
|
||||
#define LOG4CPLUS_FATAL_FMT(logger, ...) \
|
||||
LOG4CPLUS_MACRO_FMT_BODY (logger, FATAL_LOG_LEVEL, __VA_ARGS__)
|
||||
|
||||
#else
|
||||
#define LOG4CPLUS_FATAL(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING()
|
||||
#define LOG4CPLUS_FATAL_STR(logger, logEvent) LOG4CPLUS_DOWHILE_NOTHING()
|
||||
#define LOG4CPLUS_FATAL_FMT(logger, ...) LOG4CPLUS_DOWHILE_NOTHING()
|
||||
|
||||
#endif
|
||||
|
||||
//! Helper macro for LOG4CPLUS_ASSERT() macro.
|
||||
#define LOG4CPLUS_ASSERT_STRINGIFY(X) #X
|
||||
|
||||
//! If the condition given in second parameter evaluates false, this
|
||||
//! macro logs it using FATAL log level, including the condition's
|
||||
//! source text.
|
||||
#define LOG4CPLUS_ASSERT(logger, condition) \
|
||||
LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \
|
||||
do { \
|
||||
if (LOG4CPLUS_UNLIKELY(! (condition))) \
|
||||
LOG4CPLUS_FATAL_STR ((logger), \
|
||||
LOG4CPLUS_TEXT ("failed condition: ") \
|
||||
LOG4CPLUS_TEXT (LOG4CPLUS_ASSERT_STRINGIFY (condition))); \
|
||||
} while (0) \
|
||||
LOG4CPLUS_RESTORE_DOWHILE_WARNING()
|
||||
|
||||
|
||||
#endif /* LOG4CPLUS_LOGGING_MACROS_HEADER_ */
|
|
@ -0,0 +1,191 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: loglevel.h
|
||||
// Created: 6/2001
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2001-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file
|
||||
* This header defines the LogLevel type.
|
||||
*/
|
||||
|
||||
#ifndef LOG4CPLUS_LOGLEVEL_HEADER_
|
||||
#define LOG4CPLUS_LOGLEVEL_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
#include <shared_mutex>
|
||||
#endif
|
||||
#include <log4cplus/tstring.h>
|
||||
#include <log4cplus/helpers/pointer.h>
|
||||
|
||||
|
||||
namespace log4cplus {
|
||||
|
||||
/**
|
||||
* \typedef int LogLevel
|
||||
* Defines the minimum set of priorities recognized by the system,
|
||||
* that is {@link #FATAL_LOG_LEVEL}, {@link #ERROR_LOG_LEVEL}, {@link
|
||||
* #WARN_LOG_LEVEL}, {@link #INFO_LOG_LEVEL}, {@link #DEBUG_LOG_LEVEL},
|
||||
* and {@link #TRACE_LOG_LEVEL}.
|
||||
*/
|
||||
typedef int LogLevel;
|
||||
|
||||
/** \var const LogLevel OFF_LOG_LEVEL
|
||||
* The <code>OFF_LOG_LEVEL</code> LogLevel is used during configuration to
|
||||
* turn off logging. */
|
||||
const LogLevel OFF_LOG_LEVEL = 60000;
|
||||
|
||||
/** \var const LogLevel FATAL_LOG_LEVEL
|
||||
* The <code>FATAL_LOG_LEVEL</code> LogLevel designates very severe error
|
||||
* events that will presumably lead the application to abort. */
|
||||
const LogLevel FATAL_LOG_LEVEL = 50000;
|
||||
|
||||
/** \var const LogLevel ERROR_LOG_LEVEL
|
||||
* The <code>ERROR_LOG_LEVEL</code> LogLevel designates error events that
|
||||
* might still allow the application to continue running. */
|
||||
const LogLevel ERROR_LOG_LEVEL = 40000;
|
||||
|
||||
/** \var const LogLevel WARN_LOG_LEVEL
|
||||
* The <code>WARN_LOG_LEVEL</code> LogLevel designates potentially harmful
|
||||
* situations. */
|
||||
const LogLevel WARN_LOG_LEVEL = 30000;
|
||||
|
||||
/** \var const LogLevel INFO_LOG_LEVEL
|
||||
* The <code>INFO_LOG_LEVEL</code> LogLevel designates informational
|
||||
* messages that highlight the progress of the application at
|
||||
* coarse-grained level. */
|
||||
const LogLevel INFO_LOG_LEVEL = 20000;
|
||||
|
||||
/** \var const LogLevel DEBUG_LOG_LEVEL
|
||||
* The <code>DEBUG_LOG_LEVEL</code> LogLevel designates fine-grained
|
||||
* informational events that are most useful to debug an application. */
|
||||
const LogLevel DEBUG_LOG_LEVEL = 10000;
|
||||
|
||||
/** \var const LogLevel TRACE_LOG_LEVEL
|
||||
* The <code>TRACE_LOG_LEVEL</code> LogLevel is used to "trace" entry
|
||||
* and exiting of methods. */
|
||||
const LogLevel TRACE_LOG_LEVEL = 0;
|
||||
|
||||
/** \var const LogLevel ALL_LOG_LEVEL
|
||||
* The <code>ALL_LOG_LEVEL</code> LogLevel is used during configuration to
|
||||
* turn on all logging. */
|
||||
const LogLevel ALL_LOG_LEVEL = TRACE_LOG_LEVEL;
|
||||
|
||||
/** \var const LogLevel NOT_SET_LOG_LEVEL
|
||||
* The <code>NOT_SET_LOG_LEVEL</code> LogLevel is used to indicated that
|
||||
* no particular LogLevel is desired and that the default should be used.
|
||||
*/
|
||||
const LogLevel NOT_SET_LOG_LEVEL = -1;
|
||||
|
||||
|
||||
/**
|
||||
* This is a base class used by `LogLevelManager` to translate between
|
||||
* numeric `LogLevel` and log level name.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT LogLevelTranslator
|
||||
: public virtual helpers::SharedObject {
|
||||
public:
|
||||
LogLevelTranslator ();
|
||||
virtual ~LogLevelTranslator () = 0;
|
||||
|
||||
/**
|
||||
* This method is called by all `LogLevelManager` classes to convert a
|
||||
* `LogLevel` into a string.
|
||||
*/
|
||||
virtual log4cplus::tstring const & toString (LogLevel ll) const = 0;
|
||||
|
||||
/**
|
||||
* This method is called by `LogLevelManager` to convert a string into
|
||||
* a `LogLevel`.
|
||||
*/
|
||||
virtual LogLevel fromString (const log4cplus::tstring_view& arg) const = 0;
|
||||
};
|
||||
|
||||
using SharedLogLevelTranslatorPtr = helpers::SharedObjectPtr<LogLevelTranslator>;
|
||||
|
||||
|
||||
/**
|
||||
* This class is used to "manage" LogLevel definitions. This class is also
|
||||
* how "derived" LogLevels are created. Here are the steps to creating a
|
||||
* "derived" LogLevel:
|
||||
* <ol>
|
||||
* <li>Create a LogLevel constant (greater than 0)</li>
|
||||
* <li>Define a string to represent that constant</li>
|
||||
* <li>Implement a LogLevelToStringMethod method.</li>
|
||||
* <li>Implement a StringToLogLevelMethod method.</li>
|
||||
* <li>create a "static initializer" that registers those 2 methods
|
||||
* with the LogLevelManager singleton.</li>
|
||||
* </ol>
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT LogLevelManager {
|
||||
public:
|
||||
LogLevelManager();
|
||||
~LogLevelManager();
|
||||
|
||||
/**
|
||||
* This method is called by all Layout classes to convert a LogLevel
|
||||
* into a string.
|
||||
*
|
||||
* Note: It traverses the list of <code>LogLevelToStringMethod</code>
|
||||
* to do this, so all "derived" LogLevels are recognized as well.
|
||||
*/
|
||||
log4cplus::tstring const & toString(LogLevel ll) const;
|
||||
|
||||
/**
|
||||
* This method is called by all classes internally to log4cplus to
|
||||
* convert a string into a LogLevel.
|
||||
*
|
||||
* Note: It traverses the list of <code>StringToLogLevelMethod</code>
|
||||
* to do this, so all "derived" LogLevels are recognized as well.
|
||||
*/
|
||||
LogLevel fromString(const log4cplus::tstring_view& arg) const;
|
||||
|
||||
|
||||
void pushLogLevel(LogLevel ll, const log4cplus::tstring_view & name);
|
||||
|
||||
void pushLogLevelTranslator(SharedLogLevelTranslatorPtr);
|
||||
|
||||
private:
|
||||
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
mutable std::shared_mutex mtx;
|
||||
#endif
|
||||
|
||||
typedef std::vector<SharedLogLevelTranslatorPtr> LogLevelTranslatorList;
|
||||
LogLevelTranslatorList translator_list;
|
||||
|
||||
// Disable Copy
|
||||
LogLevelManager(const LogLevelManager&);
|
||||
LogLevelManager& operator=(const LogLevelManager&);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the singleton LogLevelManager.
|
||||
*/
|
||||
LOG4CPLUS_EXPORT LogLevelManager& getLogLevelManager();
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_LOGLEVEL_HEADER_
|
|
@ -0,0 +1,77 @@
|
|||
// -*- C++ -*-
|
||||
// Copyright (C) 2010-2017, Vaclav Haisman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef LOG4CPLUS_MDC_H_HEADER
|
||||
#define LOG4CPLUS_MDC_H_HEADER
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/tstring.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
|
||||
namespace log4cplus
|
||||
{
|
||||
|
||||
|
||||
typedef std::map<tstring, tstring> MappedDiagnosticContextMap;
|
||||
|
||||
|
||||
class LOG4CPLUS_EXPORT MDC
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Clear any nested diagnostic information if any. This method is
|
||||
* useful in cases where the same thread can be potentially used
|
||||
* over and over in different unrelated contexts.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
void put (tstring const & key, tstring const & value);
|
||||
bool get (tstring * value, tstring const & key) const;
|
||||
void remove (tstring const & key);
|
||||
|
||||
MappedDiagnosticContextMap const & getContext () const;
|
||||
|
||||
// Public ctor and dtor but only to be used by internal::DefaultContext.
|
||||
MDC ();
|
||||
virtual ~MDC ();
|
||||
|
||||
private:
|
||||
LOG4CPLUS_PRIVATE static MappedDiagnosticContextMap * getPtr ();
|
||||
};
|
||||
|
||||
|
||||
LOG4CPLUS_EXPORT MDC & getMDC ();
|
||||
|
||||
|
||||
} // namespace log4cplus
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_MDC_H_HEADER
|
|
@ -0,0 +1,112 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4cplus
|
||||
// File: msttsappender.h
|
||||
// Created: 10/2012
|
||||
// Author: Vaclav Zeman
|
||||
//
|
||||
//
|
||||
// Copyright (C) 2012-2017, Vaclav Zeman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
//
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_MSTTSAPPENDER_H
|
||||
#define LOG4CPLUS_MSTTSAPPENDER_H
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/appender.h>
|
||||
|
||||
|
||||
#if defined (_WIN32)
|
||||
#if defined (log4cplusqt4debugappender_EXPORTS) \
|
||||
|| defined (log4cplusqt4debugappenderU_EXPORTS) \
|
||||
|| (defined (DLL_EXPORT) && defined (INSIDE_LOG4CPLUS_MSTTSAPPENDER))
|
||||
#undef LOG4CPLUS_MSTTSAPPENDER_BUILD_DLL
|
||||
#define LOG4CPLUS_MSTTSAPPENDER_BUILD_DLL
|
||||
#endif
|
||||
#if defined (LOG4CPLUS_MSTTSAPPENDER_BUILD_DLL)
|
||||
#if defined (INSIDE_LOG4CPLUS_MSTTSAPPENDER)
|
||||
#define LOG4CPLUS_MSTTSAPPENDER_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define LOG4CPLUS_MSTTSAPPENDER_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define LOG4CPLUS_MSTTSAPPENDER_EXPORT
|
||||
#endif
|
||||
#else
|
||||
#if defined (INSIDE_LOG4CPLUS_MSTTSAPPENDER)
|
||||
#define LOG4CPLUS_MSTTSAPPENDER_EXPORT LOG4CPLUS_DECLSPEC_EXPORT
|
||||
#else
|
||||
#define LOG4CPLUS_MSTTSAPPENDER_EXPORT LOG4CPLUS_DECLSPEC_IMPORT
|
||||
#endif // defined (INSIDE_LOG4CPLUS_MSTTSAPPENDER)
|
||||
#endif // !_WIN32
|
||||
|
||||
|
||||
namespace log4cplus
|
||||
{
|
||||
|
||||
|
||||
class LOG4CPLUS_MSTTSAPPENDER_EXPORT MSTTSAppender
|
||||
: public Appender
|
||||
{
|
||||
public:
|
||||
MSTTSAppender ();
|
||||
explicit MSTTSAppender (helpers::Properties const &);
|
||||
virtual ~MSTTSAppender ();
|
||||
|
||||
virtual void close ();
|
||||
|
||||
static void registerAppender ();
|
||||
|
||||
protected:
|
||||
virtual void append (spi::InternalLoggingEvent const &);
|
||||
|
||||
struct Data;
|
||||
|
||||
Data * data;
|
||||
|
||||
private:
|
||||
LOG4CPLUS_PRIVATE void init (long const * rate = 0,
|
||||
unsigned long const * volume = 0, bool speak_punc = false,
|
||||
bool async = false);
|
||||
|
||||
MSTTSAppender (MSTTSAppender const &);
|
||||
MSTTSAppender & operator = (MSTTSAppender const &);
|
||||
};
|
||||
|
||||
|
||||
typedef helpers::SharedObjectPtr<MSTTSAppender> MSTTSAppenderPtr;
|
||||
|
||||
|
||||
} // namespace log4cplus
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_MSTTSAPPENDER_H
|
|
@ -0,0 +1,329 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: ndc.h
|
||||
// Created: 6/2001
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2001-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file
|
||||
* This header defined the NDC class.
|
||||
*/
|
||||
|
||||
#ifndef _LO4CPLUS_NDC_HEADER_
|
||||
#define _LO4CPLUS_NDC_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/tstring.h>
|
||||
|
||||
#include <map>
|
||||
#include <deque>
|
||||
|
||||
|
||||
namespace log4cplus {
|
||||
// Forward declarations
|
||||
struct DiagnosticContext;
|
||||
typedef std::deque<DiagnosticContext> DiagnosticContextStack;
|
||||
|
||||
/**
|
||||
* The NDC class implements <i>nested diagnostic contexts</i> as
|
||||
* defined by Neil Harrison in the article "Patterns for Logging
|
||||
* Diagnostic Messages" part of the book <i>"Pattern Languages of
|
||||
* Program Design 3"</i> edited by Martin et al.
|
||||
*
|
||||
* A Nested Diagnostic Context, or NDC in short, is an instrument
|
||||
* to distinguish interleaved log output from different sources. Log
|
||||
* output is typically interleaved when a server handles multiple
|
||||
* clients near-simultaneously.
|
||||
*
|
||||
* Interleaved log output can still be meaningful if each log entry
|
||||
* from different contexts had a distinctive stamp. This is where NDCs
|
||||
* come into play.
|
||||
*
|
||||
* <em><b>Note that NDCs are managed on a per thread
|
||||
* basis</b></em>. NDC operations such as {@link #push}, {@link
|
||||
* #pop}, {@link #clear}, {@link #getDepth} and {@link #setMaxDepth}
|
||||
* affect the NDC of the <em>current</em> thread only. NDCs of other
|
||||
* threads remain unaffected.
|
||||
*
|
||||
* For example, a server can build a per client request NDC
|
||||
* consisting the clients host name and other information contained in
|
||||
* the the request. <em>Cookies</em> are another source of distinctive
|
||||
* information. To build an NDC one uses the {@link #push}
|
||||
* operation. Simply put,
|
||||
*
|
||||
* - Contexts can be nested.
|
||||
* - When entering a context, call `push()`. As a side effect, if
|
||||
* there is no nested diagnostic context for the current thread,
|
||||
* this method will create it.
|
||||
* - When leaving a context, call `pop()`.
|
||||
* - When exiting a thread make sure to call `remove()`.
|
||||
*
|
||||
* There is no penalty for forgetting to match each push()
|
||||
* operation with a corresponding pop(), except the obvious
|
||||
* mismatch between the real application context and the context
|
||||
* set in the NDC. Use of the NDCContextCreator class can
|
||||
* automate this process and make your code exception-safe.
|
||||
*
|
||||
* If configured to do so, {@link log4cplus::PatternLayout} and
|
||||
* {@link log4cplus::TTCCLayout} instances automatically retrieve
|
||||
* the nested diagnostic context for the current thread without
|
||||
* any user intervention. Hence, even if a server is serving
|
||||
* multiple clients simultaneously, the logs emanating from the
|
||||
* same code (belonging to the same logger) can still be
|
||||
* distinguished because each client request will have a different
|
||||
* NDC tag.
|
||||
*
|
||||
* Heavy duty systems should call the {@link #remove} method when
|
||||
* leaving the run method of a thread. This ensures that the memory
|
||||
* used by the thread can be freed.
|
||||
*
|
||||
* A thread may inherit the nested diagnostic context of another
|
||||
* (possibly parent) thread using the {@link #inherit inherit}
|
||||
* method. A thread may obtain a copy of its NDC with the {@link
|
||||
* #cloneStack cloneStack} method and pass the reference to any other
|
||||
* thread, in particular to a child.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT NDC
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Clear any nested diagnostic information if any. This method is
|
||||
* useful in cases where the same thread can be potentially used
|
||||
* over and over in different unrelated contexts.
|
||||
*
|
||||
* This method is equivalent to calling the {@link #setMaxDepth}
|
||||
* method with a zero <code>maxDepth</code> argument.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Clone the diagnostic context for the current thread.
|
||||
*
|
||||
* Internally a diagnostic context is represented as a stack. A
|
||||
* given thread can supply the stack (i.e. diagnostic context) to a
|
||||
* child thread so that the child can inherit the parent thread's
|
||||
* diagnostic context.
|
||||
*
|
||||
* The child thread uses the {@link #inherit inherit} method to
|
||||
* inherit the parent's diagnostic context.
|
||||
*
|
||||
* @return Stack A clone of the current thread's diagnostic context.
|
||||
*/
|
||||
DiagnosticContextStack cloneStack() const;
|
||||
|
||||
/**
|
||||
* Inherit the diagnostic context of another thread.
|
||||
*
|
||||
* The parent thread can obtain a reference to its diagnostic
|
||||
* context using the {@link #cloneStack} method. It should
|
||||
* communicate this information to its child so that it may inherit
|
||||
* the parent's diagnostic context.
|
||||
*
|
||||
* The parent's diagnostic context is cloned before being
|
||||
* inherited. In other words, once inherited, the two diagnostic
|
||||
* contexts can be managed independently.
|
||||
*
|
||||
* @param stack The diagnostic context of the parent thread.
|
||||
*/
|
||||
void inherit(const DiagnosticContextStack& stack);
|
||||
|
||||
/**
|
||||
* Used when printing the diagnostic context.
|
||||
*/
|
||||
log4cplus::tstring const & get() const;
|
||||
|
||||
/**
|
||||
* Get the current nesting depth of this diagnostic context.
|
||||
*
|
||||
* @see #setMaxDepth
|
||||
*/
|
||||
std::size_t getDepth() const;
|
||||
|
||||
/**
|
||||
* Clients should call this method before leaving a diagnostic
|
||||
* context.
|
||||
*
|
||||
* The returned value is the value that was pushed last. If no
|
||||
* context is available, then the empty string is returned. If
|
||||
* each call to `push()` is paired with a call to `pop()`
|
||||
* (even in presence of thrown exceptions), the last `pop()`
|
||||
* call frees the memory used by NDC for this
|
||||
* thread. Otherwise, `remove()` must be called at the end of
|
||||
* the thread to free the memory used by NDC for the thread.
|
||||
*
|
||||
* @return String The innermost diagnostic context.
|
||||
*
|
||||
* @see NDCContextCreator, remove(), push()
|
||||
*/
|
||||
log4cplus::tstring pop();
|
||||
|
||||
/**
|
||||
* Same as pop() but without the return value.
|
||||
*/
|
||||
void pop_void ();
|
||||
|
||||
/**
|
||||
* Looks at the last diagnostic context at the top of this NDC
|
||||
* without removing it.
|
||||
*
|
||||
* The returned value is the value that was pushed last. If no
|
||||
* context is available, then the empty string is returned.
|
||||
*
|
||||
* @return String The innermost diagnostic context.
|
||||
*/
|
||||
log4cplus::tstring const & peek() const;
|
||||
|
||||
/**
|
||||
* Push new diagnostic context information for the current thread.
|
||||
*
|
||||
* The contents of the <code>message</code> parameter is
|
||||
* determined solely by the client. Each call to push() should
|
||||
* be paired with a call to pop().
|
||||
*
|
||||
* @param message The new diagnostic context information.
|
||||
*
|
||||
* @see NDCContextCreator, pop(), remove()
|
||||
*/
|
||||
void push(const log4cplus::tstring& message);
|
||||
void push(tchar const * message);
|
||||
|
||||
/**
|
||||
* Remove the diagnostic context for this thread.
|
||||
*
|
||||
* Each thread that created a diagnostic context by calling
|
||||
* push() should call this method before exiting. Otherwise,
|
||||
* the memory used by the thread cannot be reclaimed. It is
|
||||
* possible to omit this call if and only if each push() call
|
||||
* is always paired with a pop() call (even in presence of
|
||||
* thrown exceptions). Then the memory used by NDC will be
|
||||
* returned by the last pop() call and a call to remove() will
|
||||
* be no-op.
|
||||
*/
|
||||
void remove();
|
||||
|
||||
/**
|
||||
* Set maximum depth of this diagnostic context. If the
|
||||
* current depth is smaller or equal to `maxDepth`, then no
|
||||
* action is taken.
|
||||
*
|
||||
* This method is a convenient alternative to multiple `pop()`
|
||||
* calls. Moreover, it is often the case that at the end of
|
||||
* complex call sequences, the depth of the NDC is
|
||||
* unpredictable. The `setMaxDepth()` method circumvents this
|
||||
* problem.
|
||||
*
|
||||
* For example, the combination
|
||||
*
|
||||
* ~~~~{.c}
|
||||
* void foo() {
|
||||
* NDC & ndc = getNDC();
|
||||
* std::size_t depth = ndc.getDepth();
|
||||
* //... complex sequence of calls
|
||||
* ndc.setMaxDepth(depth);
|
||||
* }
|
||||
* ~~~~
|
||||
*
|
||||
* ensures that between the entry and exit of foo the depth of the
|
||||
* diagnostic stack is conserved.
|
||||
*
|
||||
* \note Use of the NDCContextCreator class will solve this
|
||||
* particular problem.
|
||||
*
|
||||
* \see NDC::getDepth()
|
||||
*/
|
||||
void setMaxDepth(std::size_t maxDepth);
|
||||
|
||||
// Public ctor but only to be used by internal::DefaultContext.
|
||||
NDC();
|
||||
|
||||
// Dtor
|
||||
virtual ~NDC();
|
||||
|
||||
private:
|
||||
// Methods
|
||||
LOG4CPLUS_PRIVATE static DiagnosticContextStack* getPtr();
|
||||
|
||||
template <typename StringType>
|
||||
LOG4CPLUS_PRIVATE
|
||||
void push_worker (StringType const &);
|
||||
|
||||
// Disallow construction (and copying) except by getNDC()
|
||||
NDC(const NDC&);
|
||||
NDC& operator=(const NDC&);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Return a reference to the singleton object.
|
||||
*/
|
||||
LOG4CPLUS_EXPORT NDC& getNDC();
|
||||
|
||||
|
||||
/**
|
||||
* This is the internal object that is stored on the NDC stack.
|
||||
*/
|
||||
struct LOG4CPLUS_EXPORT DiagnosticContext
|
||||
{
|
||||
// Ctors
|
||||
DiagnosticContext(const log4cplus::tstring& message,
|
||||
DiagnosticContext const * parent);
|
||||
DiagnosticContext(tchar const * message,
|
||||
DiagnosticContext const * parent);
|
||||
DiagnosticContext(const log4cplus::tstring& message);
|
||||
DiagnosticContext(tchar const * message);
|
||||
DiagnosticContext(DiagnosticContext const &);
|
||||
DiagnosticContext & operator = (DiagnosticContext const &);
|
||||
DiagnosticContext(DiagnosticContext &&);
|
||||
DiagnosticContext & operator = (DiagnosticContext &&);
|
||||
|
||||
void swap (DiagnosticContext &);
|
||||
|
||||
// Data
|
||||
log4cplus::tstring message; /*!< The message at this context level. */
|
||||
log4cplus::tstring fullMessage; /*!< The entire message stack. */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This class ensures that a `NDC::push()` call is always matched
|
||||
* with a `NDC::pop()` call even in the face of exceptions.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT NDCContextCreator {
|
||||
public:
|
||||
/** Pushes <code>msg</code> onto the NDC stack. */
|
||||
explicit NDCContextCreator(const log4cplus::tstring& msg);
|
||||
explicit NDCContextCreator(tchar const * msg);
|
||||
|
||||
NDCContextCreator() = delete;
|
||||
NDCContextCreator(NDCContextCreator const &) = delete;
|
||||
NDCContextCreator(NDCContextCreator &&) = delete;
|
||||
NDCContextCreator & operator= (NDCContextCreator const &) = delete;
|
||||
NDCContextCreator & operator= (NDCContextCreator &&) = delete;
|
||||
|
||||
/** Pops the NDC stack. */
|
||||
~NDCContextCreator();
|
||||
};
|
||||
|
||||
} // end namespace log4cplus
|
||||
|
||||
|
||||
#endif // _LO4CPLUS_NDC_HEADER_
|
|
@ -0,0 +1,84 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: nteventlogappender.h
|
||||
// Created: 4/2003
|
||||
// Author: Michael CATANZARITI
|
||||
//
|
||||
// Copyright 2003-2017 Michael CATANZARITI
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_NT_EVENT_LOG_APPENDER_HEADER_
|
||||
#define LOG4CPLUS_NT_EVENT_LOG_APPENDER_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_NT_EVENT_LOG)
|
||||
|
||||
#include <log4cplus/appender.h>
|
||||
#include <log4cplus/config/windowsh-inc.h>
|
||||
|
||||
|
||||
namespace log4cplus {
|
||||
|
||||
/**
|
||||
* Appends log events to NT EventLog.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT NTEventLogAppender : public Appender {
|
||||
public:
|
||||
// ctors
|
||||
NTEventLogAppender(const log4cplus::tstring& server,
|
||||
const log4cplus::tstring& log,
|
||||
const log4cplus::tstring& source);
|
||||
NTEventLogAppender(const log4cplus::helpers::Properties & properties);
|
||||
|
||||
// dtor
|
||||
virtual ~NTEventLogAppender();
|
||||
|
||||
// public Methods
|
||||
virtual void close();
|
||||
|
||||
protected:
|
||||
virtual void append(const spi::InternalLoggingEvent& event);
|
||||
virtual WORD getEventType(const spi::InternalLoggingEvent& event);
|
||||
virtual WORD getEventCategory(const spi::InternalLoggingEvent& event);
|
||||
void init();
|
||||
|
||||
/*
|
||||
* Add this source with appropriate configuration keys to the registry.
|
||||
*/
|
||||
void addRegistryInfo();
|
||||
|
||||
// Data
|
||||
log4cplus::tstring server;
|
||||
log4cplus::tstring log;
|
||||
log4cplus::tstring source;
|
||||
HANDLE hEventLog;
|
||||
SID* pCurrentUserSID;
|
||||
|
||||
private:
|
||||
// Disallow copying of instances of this class
|
||||
NTEventLogAppender(const NTEventLogAppender&);
|
||||
NTEventLogAppender& operator=(const NTEventLogAppender&);
|
||||
};
|
||||
|
||||
} // end namespace log4cplus
|
||||
|
||||
#endif // LOG4CPLUS_HAVE_NT_EVENT_LOG
|
||||
#endif //LOG4CPLUS_NT_EVENT_LOG_APPENDER_HEADER_
|
|
@ -0,0 +1,65 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: nullappender.h
|
||||
// Created: 6/2003
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2003-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_NULL_APPENDER_HEADER_
|
||||
#define LOG4CPLUS_NULL_APPENDER_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/appender.h>
|
||||
|
||||
|
||||
namespace log4cplus {
|
||||
|
||||
/**
|
||||
* Appends log events to a file.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT NullAppender : public Appender {
|
||||
public:
|
||||
// Ctors
|
||||
NullAppender();
|
||||
NullAppender(const log4cplus::helpers::Properties&);
|
||||
|
||||
// Dtor
|
||||
virtual ~NullAppender();
|
||||
|
||||
// Methods
|
||||
virtual void close();
|
||||
|
||||
protected:
|
||||
virtual void append(const log4cplus::spi::InternalLoggingEvent& event);
|
||||
|
||||
private:
|
||||
// Disallow copying of instances of this class
|
||||
NullAppender(const NullAppender&);
|
||||
NullAppender& operator=(const NullAppender&);
|
||||
};
|
||||
|
||||
} // end namespace log4cplus
|
||||
|
||||
#endif // LOG4CPLUS_NULL_APPENDER_HEADER_
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4cplus
|
||||
// File: qt4debugappender.h
|
||||
// Created: 5/2012
|
||||
// Author: Vaclav Zeman
|
||||
//
|
||||
//
|
||||
// Copyright (C) 2012-2017, Vaclav Zeman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
//
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_QT4DEBUGAPPENDER_H
|
||||
#define LOG4CPLUS_QT4DEBUGAPPENDER_H
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/appender.h>
|
||||
|
||||
#if defined (_WIN32)
|
||||
#if defined (log4cplusqt4debugappender_EXPORTS) \
|
||||
|| defined (log4cplusqt4debugappenderU_EXPORTS) \
|
||||
|| (defined (DLL_EXPORT) && defined (INSIDE_LOG4CPLUS_QT4DEBUGAPPENDER))
|
||||
#undef LOG4CPLUS_QT4DEBUGAPPENDER_BUILD_DLL
|
||||
#define LOG4CPLUS_QT4DEBUGAPPENDER_BUILD_DLL
|
||||
#endif
|
||||
#if defined (LOG4CPLUS_QT4DEBUGAPPENDER_BUILD_DLL)
|
||||
#if defined (INSIDE_LOG4CPLUS_QT4DEBUGAPPENDER)
|
||||
#define LOG4CPLUS_QT4DEBUGAPPENDER_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define LOG4CPLUS_QT4DEBUGAPPENDER_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define LOG4CPLUS_QT4DEBUGAPPENDER_EXPORT
|
||||
#endif
|
||||
#else
|
||||
#if defined (INSIDE_LOG4CPLUS_QT4DEBUGAPPENDER)
|
||||
#define LOG4CPLUS_QT4DEBUGAPPENDER_EXPORT LOG4CPLUS_DECLSPEC_EXPORT
|
||||
#else
|
||||
#define LOG4CPLUS_QT4DEBUGAPPENDER_EXPORT LOG4CPLUS_DECLSPEC_IMPORT
|
||||
#endif // defined (INSIDE_LOG4CPLUS_QT4DEBUGAPPENDER)
|
||||
#endif // !_WIN32
|
||||
|
||||
|
||||
namespace log4cplus
|
||||
{
|
||||
|
||||
|
||||
class LOG4CPLUS_QT4DEBUGAPPENDER_EXPORT Qt4DebugAppender
|
||||
: public Appender
|
||||
{
|
||||
public:
|
||||
Qt4DebugAppender ();
|
||||
explicit Qt4DebugAppender (helpers::Properties const &);
|
||||
virtual ~Qt4DebugAppender ();
|
||||
|
||||
virtual void close ();
|
||||
|
||||
static void registerAppender ();
|
||||
|
||||
protected:
|
||||
virtual void append (spi::InternalLoggingEvent const &);
|
||||
|
||||
private:
|
||||
Qt4DebugAppender (Qt4DebugAppender const &);
|
||||
Qt4DebugAppender & operator = (Qt4DebugAppender const &);
|
||||
};
|
||||
|
||||
|
||||
typedef helpers::SharedObjectPtr<Qt4DebugAppender> Qt4DebugAppenderPtr;
|
||||
|
||||
|
||||
} // namespace log4cplus
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_QT4DEBUGAPPENDER_H
|
|
@ -0,0 +1,103 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4cplus
|
||||
// File: qt5debugappender.h
|
||||
// Created: 4/2013
|
||||
// Author: Vaclav Zeman
|
||||
//
|
||||
//
|
||||
// Copyright (C) 2013-2017, Vaclav Zeman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
//
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_QT5DEBUGAPPENDER_H
|
||||
#define LOG4CPLUS_QT5DEBUGAPPENDER_H
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/appender.h>
|
||||
|
||||
#if defined (_WIN32)
|
||||
#if defined (log4cplusqt5debugappender_EXPORTS) \
|
||||
|| defined (log4cplusqt5debugappenderU_EXPORTS) \
|
||||
|| (defined (DLL_EXPORT) && defined (INSIDE_LOG4CPLUS_QT5DEBUGAPPENDER))
|
||||
#undef LOG4CPLUS_QT5DEBUGAPPENDER_BUILD_DLL
|
||||
#define LOG4CPLUS_QT5DEBUGAPPENDER_BUILD_DLL
|
||||
#endif
|
||||
#if defined (LOG4CPLUS_QT5DEBUGAPPENDER_BUILD_DLL)
|
||||
#if defined (INSIDE_LOG4CPLUS_QT5DEBUGAPPENDER)
|
||||
#define LOG4CPLUS_QT5DEBUGAPPENDER_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define LOG4CPLUS_QT5DEBUGAPPENDER_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define LOG4CPLUS_QT5DEBUGAPPENDER_EXPORT
|
||||
#endif
|
||||
#else
|
||||
#if defined (INSIDE_LOG4CPLUS_QT5DEBUGAPPENDER)
|
||||
#define LOG4CPLUS_QT5DEBUGAPPENDER_EXPORT LOG4CPLUS_DECLSPEC_EXPORT
|
||||
#else
|
||||
#define LOG4CPLUS_QT5DEBUGAPPENDER_EXPORT LOG4CPLUS_DECLSPEC_IMPORT
|
||||
#endif // defined (INSIDE_LOG4CPLUS_QT5DEBUGAPPENDER)
|
||||
#endif // !_WIN32
|
||||
|
||||
|
||||
namespace log4cplus
|
||||
{
|
||||
|
||||
|
||||
class LOG4CPLUS_QT5DEBUGAPPENDER_EXPORT Qt5DebugAppender
|
||||
: public Appender
|
||||
{
|
||||
public:
|
||||
Qt5DebugAppender ();
|
||||
explicit Qt5DebugAppender (helpers::Properties const &);
|
||||
virtual ~Qt5DebugAppender ();
|
||||
|
||||
virtual void close ();
|
||||
|
||||
static void registerAppender ();
|
||||
|
||||
protected:
|
||||
virtual void append (spi::InternalLoggingEvent const &);
|
||||
|
||||
private:
|
||||
Qt5DebugAppender (Qt5DebugAppender const &);
|
||||
Qt5DebugAppender & operator = (Qt5DebugAppender const &);
|
||||
};
|
||||
|
||||
|
||||
typedef helpers::SharedObjectPtr<Qt5DebugAppender> Qt5DebugAppenderPtr;
|
||||
|
||||
|
||||
} // namespace log4cplus
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_QT5DEBUGAPPENDER_H
|
|
@ -0,0 +1,164 @@
|
|||
// -*- C++ -*-
|
||||
// Module: LOG4CPLUS
|
||||
// File: socketappender.h
|
||||
// Created: 5/2003
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2003-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_SOCKET_APPENDER_HEADER_
|
||||
#define LOG4CPLUS_SOCKET_APPENDER_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/appender.h>
|
||||
#include <log4cplus/helpers/socket.h>
|
||||
#include <log4cplus/thread/syncprims.h>
|
||||
#include <log4cplus/thread/threads.h>
|
||||
#include <log4cplus/helpers/connectorthread.h>
|
||||
|
||||
|
||||
namespace log4cplus
|
||||
{
|
||||
|
||||
#ifndef UNICODE
|
||||
std::size_t const LOG4CPLUS_MAX_MESSAGE_SIZE = 8*1024;
|
||||
#else
|
||||
std::size_t const LOG4CPLUS_MAX_MESSAGE_SIZE = 2*8*1024;
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Sends {@link spi::InternalLoggingEvent} objects to a remote a log server.
|
||||
*
|
||||
* The SocketAppender has the following properties:
|
||||
*
|
||||
* <ul>
|
||||
*
|
||||
* <li>Remote logging is non-intrusive as far as the log event
|
||||
* is concerned. In other words, the event will be logged with
|
||||
* the same time stamp, NDC, location info as if it were logged
|
||||
* locally by the client.
|
||||
*
|
||||
* <li>SocketAppenders do not use a layout.
|
||||
*
|
||||
* <li>Remote logging uses the TCP protocol. Consequently, if
|
||||
* the server is reachable, then log events will eventually arrive
|
||||
* at the server.
|
||||
*
|
||||
* <li>If the remote server is down, the logging requests are
|
||||
* simply dropped. However, if and when the server comes back up,
|
||||
* then event transmission is resumed transparently. This
|
||||
* transparent reconneciton is performed by a <em>connector</em>
|
||||
* thread which periodically attempts to connect to the server.
|
||||
*
|
||||
* <li>Logging events are automatically <em>buffered</em> by the
|
||||
* native TCP implementation. This means that if the link to server
|
||||
* is slow but still faster than the rate of (log) event production
|
||||
* by the client, the client will not be affected by the slow
|
||||
* network connection. However, if the network connection is slower
|
||||
* then the rate of event production, then the client can only
|
||||
* progress at the network rate. In particular, if the network link
|
||||
* to the the server is down, the client will be blocked.
|
||||
*
|
||||
* <li>On the other hand, if the network link is up, but the server
|
||||
* is down, the client will not be blocked when making log requests
|
||||
* but the log events will be lost due to server unavailability.
|
||||
* </ul>
|
||||
*
|
||||
* <h3>Properties</h3>
|
||||
* <dl>
|
||||
* <dt><tt>host</tt></dt>
|
||||
* <dd>Remote host name to connect and send events to.</dd>
|
||||
*
|
||||
* <dt><tt>port</tt></dt>
|
||||
* <dd>Port on remote host to send events to.</dd>
|
||||
*
|
||||
* <dt><tt>ServerName</tt></dt>
|
||||
* <dd>Host name of event's origin prepended to each event.</dd>
|
||||
*
|
||||
* <dt><tt>IPv6</tt></dt>
|
||||
* <dd>Boolean value specifying whether to use IPv6 (true) or IPv4
|
||||
* (false). Default value is false.</dd>
|
||||
*
|
||||
* </dl>
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT SocketAppender
|
||||
: public Appender
|
||||
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
, protected virtual helpers::IConnectorThreadClient
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
// Ctors
|
||||
SocketAppender(const log4cplus::tstring& host, unsigned short port,
|
||||
const log4cplus::tstring& serverName = tstring(),
|
||||
bool ipv6 = false);
|
||||
SocketAppender(const log4cplus::helpers::Properties & properties);
|
||||
|
||||
// Dtor
|
||||
~SocketAppender();
|
||||
|
||||
// Methods
|
||||
virtual void close();
|
||||
|
||||
protected:
|
||||
void openSocket();
|
||||
void initConnector ();
|
||||
virtual void append(const spi::InternalLoggingEvent& event);
|
||||
|
||||
// Data
|
||||
log4cplus::helpers::Socket socket;
|
||||
log4cplus::tstring host;
|
||||
unsigned int port;
|
||||
log4cplus::tstring serverName;
|
||||
bool ipv6 = false;
|
||||
|
||||
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
virtual thread::Mutex const & ctcGetAccessMutex () const;
|
||||
virtual helpers::Socket & ctcGetSocket ();
|
||||
virtual helpers::Socket ctcConnect ();
|
||||
virtual void ctcSetConnected ();
|
||||
|
||||
volatile bool connected;
|
||||
helpers::SharedObjectPtr<helpers::ConnectorThread> connector;
|
||||
#endif
|
||||
|
||||
private:
|
||||
// Disallow copying of instances of this class
|
||||
SocketAppender(const SocketAppender&);
|
||||
SocketAppender& operator=(const SocketAppender&);
|
||||
};
|
||||
|
||||
namespace helpers {
|
||||
LOG4CPLUS_EXPORT
|
||||
void convertToBuffer (SocketBuffer & buffer,
|
||||
const log4cplus::spi::InternalLoggingEvent& event,
|
||||
const log4cplus::tstring& serverName);
|
||||
|
||||
LOG4CPLUS_EXPORT
|
||||
log4cplus::spi::InternalLoggingEvent readFromBuffer(SocketBuffer& buffer);
|
||||
} // end namespace helpers
|
||||
|
||||
} // end namespace log4cplus
|
||||
|
||||
#endif // LOG4CPLUS_SOCKET_APPENDER_HEADER_
|
|
@ -0,0 +1,88 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: appenderattachable.h
|
||||
// Created: 6/2001
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2001-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_SPI_APPENDER_ATTACHABLE_HEADER_
|
||||
#define LOG4CPLUS_SPI_APPENDER_ATTACHABLE_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/appender.h>
|
||||
#include <log4cplus/tstring.h>
|
||||
#include <log4cplus/helpers/pointer.h>
|
||||
#include <vector>
|
||||
|
||||
namespace log4cplus {
|
||||
// Forward Declarations
|
||||
typedef std::vector<log4cplus::SharedAppenderPtr> SharedAppenderPtrList;
|
||||
|
||||
namespace spi {
|
||||
|
||||
/**
|
||||
* This Interface is for attaching Appenders to objects.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT AppenderAttachable {
|
||||
public:
|
||||
// Methods
|
||||
/**
|
||||
* Add an appender.
|
||||
*/
|
||||
virtual void addAppender(SharedAppenderPtr newAppender) = 0;
|
||||
|
||||
/**
|
||||
* Get all previously added appenders as an Enumeration.
|
||||
*/
|
||||
virtual SharedAppenderPtrList getAllAppenders() = 0;
|
||||
|
||||
/**
|
||||
* Get an appender by name.
|
||||
*/
|
||||
virtual SharedAppenderPtr getAppender(const log4cplus::tstring& name) = 0;
|
||||
|
||||
/**
|
||||
* Remove all previously added appenders.
|
||||
*/
|
||||
virtual void removeAllAppenders() = 0;
|
||||
|
||||
/**
|
||||
* Remove the appender passed as parameter from the list of appenders.
|
||||
*/
|
||||
virtual void removeAppender(SharedAppenderPtr appender) = 0;
|
||||
|
||||
/**
|
||||
* Remove the appender with the name passed as parameter from the
|
||||
* list of appenders.
|
||||
*/
|
||||
virtual void removeAppender(const log4cplus::tstring& name) = 0;
|
||||
|
||||
// Dtor
|
||||
virtual ~AppenderAttachable() = 0;
|
||||
};
|
||||
|
||||
} // end namespace spi
|
||||
} // end namespace log4cplus
|
||||
|
||||
#endif // LOG4CPLUS_SPI_APPENDER_ATTACHABLE_HEADER_
|
|
@ -0,0 +1,275 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: factory.h
|
||||
// Created: 2/2002
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2002-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_SPI_FACTORY_HEADER_
|
||||
#define LOG4CPLUS_SPI_FACTORY_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/appender.h>
|
||||
#include <log4cplus/layout.h>
|
||||
#include <log4cplus/tstring.h>
|
||||
#include <log4cplus/spi/filter.h>
|
||||
#include <log4cplus/spi/objectregistry.h>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <locale>
|
||||
|
||||
|
||||
namespace log4cplus {
|
||||
namespace spi {
|
||||
|
||||
/**
|
||||
* This is the base class for all factories.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT BaseFactory {
|
||||
public:
|
||||
virtual ~BaseFactory() = 0;
|
||||
|
||||
/**
|
||||
* Returns the typename of the objects this factory creates.
|
||||
*/
|
||||
virtual log4cplus::tstring const & getTypeName() const = 0;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This abstract class defines the "Factory" interface to create "Appender"
|
||||
* objects.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT AppenderFactory : public BaseFactory {
|
||||
public:
|
||||
typedef Appender ProductType;
|
||||
typedef SharedAppenderPtr ProductPtr;
|
||||
|
||||
AppenderFactory();
|
||||
virtual ~AppenderFactory() = 0;
|
||||
|
||||
/**
|
||||
* Create an "Appender" object.
|
||||
*/
|
||||
virtual SharedAppenderPtr createObject(const log4cplus::helpers::Properties& props) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This abstract class defines the "Factory" interface to create "Layout"
|
||||
* objects.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT LayoutFactory : public BaseFactory {
|
||||
public:
|
||||
typedef Layout ProductType;
|
||||
typedef std::unique_ptr<Layout> ProductPtr;
|
||||
|
||||
LayoutFactory();
|
||||
virtual ~LayoutFactory() = 0;
|
||||
|
||||
/**
|
||||
* Create a "Layout" object.
|
||||
*/
|
||||
virtual std::unique_ptr<Layout> createObject(const log4cplus::helpers::Properties& props) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This abstract class defines the "Factory" interface to create "Appender"
|
||||
* objects.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT FilterFactory : public BaseFactory {
|
||||
public:
|
||||
typedef Filter ProductType;
|
||||
typedef FilterPtr ProductPtr;
|
||||
|
||||
FilterFactory();
|
||||
virtual ~FilterFactory() = 0;
|
||||
|
||||
/**
|
||||
* Create a "Filter" object.
|
||||
*/
|
||||
virtual FilterPtr createObject(const log4cplus::helpers::Properties& props) = 0;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This abstract class defines the "Factory" interface to
|
||||
* create std::locale instances.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT LocaleFactory
|
||||
: public BaseFactory
|
||||
{
|
||||
public:
|
||||
typedef std::locale ProductType;
|
||||
typedef std::locale ProductPtr;
|
||||
|
||||
LocaleFactory();
|
||||
virtual ~LocaleFactory() = 0;
|
||||
|
||||
//! \returns std::locale instance
|
||||
virtual ProductPtr createObject (
|
||||
const log4cplus::helpers::Properties & props) = 0;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This template class is used as a "Factory Registry". Objects are
|
||||
* "entered" into the registry with a "name" using the
|
||||
* <code>put()</code> method. (The registry then owns the object.)
|
||||
* These object can then be retrieved using the <code>get()</code>
|
||||
* method.
|
||||
*
|
||||
* <b>Note:</b> This class is Thread-safe.
|
||||
*/
|
||||
template<class T>
|
||||
class LOG4CPLUS_EXPORT FactoryRegistry
|
||||
: public ObjectRegistryBase
|
||||
{
|
||||
public:
|
||||
typedef T product_type;
|
||||
|
||||
virtual ~FactoryRegistry() {
|
||||
clear();
|
||||
}
|
||||
|
||||
// public methods
|
||||
/**
|
||||
* Used to enter an object into the registry. (The registry now
|
||||
* owns <code>object</code>.)
|
||||
*/
|
||||
bool put(std::unique_ptr<T> object) {
|
||||
bool putValResult = putVal(object->getTypeName(), object.get());
|
||||
object.release();
|
||||
return putValResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to retrieve an object from the registry. (The registry
|
||||
* owns the returned pointer.)
|
||||
*/
|
||||
T* get(const log4cplus::tstring& name) const {
|
||||
return static_cast<T*>(getVal(name));
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void deleteObject(void *object) const {
|
||||
delete static_cast<T*>(object);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
typedef FactoryRegistry<AppenderFactory> AppenderFactoryRegistry;
|
||||
typedef FactoryRegistry<LayoutFactory> LayoutFactoryRegistry;
|
||||
typedef FactoryRegistry<FilterFactory> FilterFactoryRegistry;
|
||||
typedef FactoryRegistry<LocaleFactory> LocaleFactoryRegistry;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the "singleton" <code>AppenderFactoryRegistry</code>.
|
||||
*/
|
||||
LOG4CPLUS_EXPORT AppenderFactoryRegistry& getAppenderFactoryRegistry();
|
||||
|
||||
/**
|
||||
* Returns the "singleton" <code>LayoutFactoryRegistry</code>.
|
||||
*/
|
||||
LOG4CPLUS_EXPORT LayoutFactoryRegistry& getLayoutFactoryRegistry();
|
||||
|
||||
/**
|
||||
* Returns the "singleton" <code>FilterFactoryRegistry</code>.
|
||||
*/
|
||||
LOG4CPLUS_EXPORT FilterFactoryRegistry& getFilterFactoryRegistry();
|
||||
|
||||
/**
|
||||
* Returns the "singleton" <code>LocaleFactoryRegistry</code>.
|
||||
*/
|
||||
LOG4CPLUS_EXPORT LocaleFactoryRegistry& getLocaleFactoryRegistry();
|
||||
|
||||
|
||||
template <typename ProductFactoryBase>
|
||||
class LocalFactoryBase
|
||||
: public ProductFactoryBase
|
||||
{
|
||||
public:
|
||||
LocalFactoryBase (tchar const * n)
|
||||
: name (n)
|
||||
{ }
|
||||
|
||||
virtual log4cplus::tstring const & getTypeName() const
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
private:
|
||||
log4cplus::tstring name;
|
||||
};
|
||||
|
||||
|
||||
template <typename LocalProduct, typename ProductFactoryBase>
|
||||
class FactoryTempl
|
||||
: public LocalFactoryBase<ProductFactoryBase>
|
||||
{
|
||||
public:
|
||||
typedef typename ProductFactoryBase::ProductPtr ProductPtr;
|
||||
|
||||
FactoryTempl (tchar const * n)
|
||||
: LocalFactoryBase<ProductFactoryBase> (n)
|
||||
{ }
|
||||
|
||||
virtual ProductPtr createObject (helpers::Properties const & props)
|
||||
{
|
||||
return ProductPtr (new LocalProduct (props));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#define LOG4CPLUS_REG_PRODUCT(reg, productprefix, productname, productns, productfact) \
|
||||
reg.put ( \
|
||||
std::unique_ptr<productfact> ( \
|
||||
new log4cplus::spi::FactoryTempl<productns productname, productfact> ( \
|
||||
LOG4CPLUS_TEXT(productprefix) \
|
||||
LOG4CPLUS_TEXT(#productname))))
|
||||
|
||||
#define LOG4CPLUS_REG_APPENDER(reg, appendername) \
|
||||
LOG4CPLUS_REG_PRODUCT (reg, "log4cplus::", appendername, log4cplus::, \
|
||||
log4cplus::spi::AppenderFactory)
|
||||
|
||||
#define LOG4CPLUS_REG_LAYOUT(reg, layoutname) \
|
||||
LOG4CPLUS_REG_PRODUCT (reg, "log4cplus::", layoutname, log4cplus::, \
|
||||
log4cplus::spi::LayoutFactory)
|
||||
|
||||
#define LOG4CPLUS_REG_FILTER(reg, filtername) \
|
||||
LOG4CPLUS_REG_PRODUCT (reg, "log4cplus::spi::", filtername, log4cplus::spi::, \
|
||||
log4cplus::spi::FilterFactory)
|
||||
|
||||
#define LOG4CPLUS_REG_LOCALE(reg, name, factory) \
|
||||
reg.put (std::unique_ptr<log4cplus::spi::LocaleFactory> ( \
|
||||
new factory (name)))
|
||||
} // namespace spi
|
||||
}
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_SPI_FACTORY_HEADER_
|
|
@ -0,0 +1,404 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: filter.h
|
||||
// Created: 5/2003
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 1999-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file
|
||||
* This header defines Filter and all of it's subclasses. */
|
||||
|
||||
#ifndef LOG4CPLUS_SPI_FILTER_HEADER_
|
||||
#define LOG4CPLUS_SPI_FILTER_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include <log4cplus/helpers/pointer.h>
|
||||
#include <log4cplus/loglevel.h>
|
||||
|
||||
|
||||
namespace log4cplus {
|
||||
|
||||
namespace helpers
|
||||
{
|
||||
|
||||
class Properties;
|
||||
|
||||
}
|
||||
|
||||
namespace spi {
|
||||
|
||||
|
||||
enum FilterResult { DENY, /**< The log event must be dropped immediately
|
||||
* without consulting with the remaining
|
||||
* filters, if any, in the chain. */
|
||||
NEUTRAL, /**< This filter is neutral with respect to
|
||||
* the log event; the remaining filters, if
|
||||
* if any, should be consulted for a final
|
||||
* decision. */
|
||||
ACCEPT /**< The log event must be logged immediately
|
||||
* without consulting with the remaining
|
||||
* filters, if any, in the chain. */
|
||||
};
|
||||
|
||||
// Forward Declarations
|
||||
class Filter;
|
||||
class InternalLoggingEvent;
|
||||
|
||||
|
||||
/**
|
||||
* This method is used to filter an InternalLoggingEvent.
|
||||
*
|
||||
* Note: <code>filter</code> can be NULL.
|
||||
*/
|
||||
LOG4CPLUS_EXPORT FilterResult checkFilter(const Filter* filter,
|
||||
const InternalLoggingEvent& event);
|
||||
|
||||
typedef helpers::SharedObjectPtr<Filter> FilterPtr;
|
||||
|
||||
|
||||
/**
|
||||
* Users should extend this class to implement customized logging
|
||||
* event filtering. Note that the {@link Logger} and {@link
|
||||
* Appender} classes have built-in filtering rules. It is suggested
|
||||
* that you first use and understand the built-in rules before rushing
|
||||
* to write your own custom filters.
|
||||
*
|
||||
* This abstract class assumes and also imposes that filters be
|
||||
* organized in a linear chain. The {@link #decide
|
||||
* decide(LoggingEvent)} method of each filter is called sequentially,
|
||||
* in the order of their addition to the chain.
|
||||
*
|
||||
* If the value {@link #DENY} is returned, then the log event is
|
||||
* dropped immediately without consulting with the remaining
|
||||
* filters.
|
||||
*
|
||||
* If the value {@link #NEUTRAL} is returned, then the next filter
|
||||
* in the chain is consulted. If there are no more filters in the
|
||||
* chain, then the log event is logged. Thus, in the presence of no
|
||||
* filters, the default behaviour is to log all logging events.
|
||||
*
|
||||
* If the value {@link #ACCEPT} is returned, then the log
|
||||
* event is logged without consulting the remaining filters.
|
||||
*
|
||||
* The philosophy of log4cplus filters is largely inspired from the
|
||||
* Linux ipchains.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT Filter
|
||||
: public virtual log4cplus::helpers::SharedObject
|
||||
{
|
||||
public:
|
||||
// ctor and dtor
|
||||
Filter();
|
||||
virtual ~Filter();
|
||||
|
||||
// Methods
|
||||
/**
|
||||
* Appends <code>filter</code> to the end of this filter chain.
|
||||
*/
|
||||
void appendFilter(FilterPtr filter);
|
||||
|
||||
/**
|
||||
* If the decision is <code>DENY</code>, then the event will be
|
||||
* dropped. If the decision is <code>NEUTRAL</code>, then the next
|
||||
* filter, if any, will be invoked. If the decision is ACCEPT then
|
||||
* the event will be logged without consulting with other filters in
|
||||
* the chain.
|
||||
*
|
||||
* @param event The LoggingEvent to decide upon.
|
||||
* @return The decision of the filter.
|
||||
*/
|
||||
virtual FilterResult decide(const InternalLoggingEvent& event) const = 0;
|
||||
|
||||
// Data
|
||||
/**
|
||||
* Points to the next filter in the filter chain.
|
||||
*/
|
||||
FilterPtr next;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This filter drops all logging events.
|
||||
*
|
||||
* You can add this filter to the end of a filter chain to
|
||||
* switch from the default "accept all unless instructed otherwise"
|
||||
* filtering behaviour to a "deny all unless instructed otherwise"
|
||||
* behaviour.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT DenyAllFilter : public Filter {
|
||||
public:
|
||||
DenyAllFilter ();
|
||||
DenyAllFilter (const log4cplus::helpers::Properties&);
|
||||
|
||||
/**
|
||||
* Always returns the {@link #DENY} regardless of the
|
||||
* {@link InternalLoggingEvent} parameter.
|
||||
*/
|
||||
virtual FilterResult decide(const InternalLoggingEvent& event) const;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This is a very simple filter based on LogLevel matching.
|
||||
*
|
||||
* The filter admits two options <b>LogLevelToMatch</b> and
|
||||
* <b>AcceptOnMatch</b>. If there is an exact match between the value
|
||||
* of the LogLevelToMatch option and the LogLevel of the {@link
|
||||
* spi::InternalLoggingEvent}, then the {@link #decide} method returns
|
||||
* {@link #ACCEPT} in case the <b>AcceptOnMatch</b> option value is set
|
||||
* to <code>true</code>, if it is <code>false</code> then {@link #DENY}
|
||||
* is returned. If there is no match, {@link #NEUTRAL} is returned.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT LogLevelMatchFilter : public Filter {
|
||||
public:
|
||||
LogLevelMatchFilter();
|
||||
LogLevelMatchFilter(const log4cplus::helpers::Properties& p);
|
||||
|
||||
/**
|
||||
* Return the decision of this filter.
|
||||
*
|
||||
* Returns {@link #NEUTRAL} if the <b>LogLevelToMatch</b>
|
||||
* option is not set or if there is no match. Otherwise, if
|
||||
* there is a match, then the returned decision is {@link #ACCEPT}
|
||||
* if the <b>AcceptOnMatch</b> property is set to <code>true</code>.
|
||||
* The returned decision is {@link #DENY} if the <b>AcceptOnMatch</b>
|
||||
* property is set to <code>false</code>.
|
||||
*/
|
||||
virtual FilterResult decide(const InternalLoggingEvent& event) const;
|
||||
|
||||
private:
|
||||
// Methods
|
||||
LOG4CPLUS_PRIVATE void init();
|
||||
|
||||
// Data
|
||||
/** Do we return ACCEPT when a match occurs. Default is <code>true</code>. */
|
||||
bool acceptOnMatch;
|
||||
LogLevel logLevelToMatch;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This is a very simple filter based on LogLevel matching, which can be
|
||||
* used to reject messages with LogLevels outside a certain range.
|
||||
*
|
||||
* The filter admits three options <b>LogLevelMin</b>, <b>LogLevelMax</b>
|
||||
* and <b>AcceptOnMatch</b>.
|
||||
*
|
||||
* If the LogLevel of the Logging event is not between Min and Max
|
||||
* (inclusive), then {@link #DENY} is returned.
|
||||
*
|
||||
* If the Logging event LogLevel is within the specified range, then if
|
||||
* <b>AcceptOnMatch</b> is true, {@link #ACCEPT} is returned, and if
|
||||
* <b>AcceptOnMatch</b> is false, {@link #NEUTRAL} is returned.
|
||||
*
|
||||
* If <code>LogLevelMin</code> is not defined, then there is no
|
||||
* minimum acceptable LogLevel (ie a LogLevel is never rejected for
|
||||
* being too "low"/unimportant). If <code>LogLevelMax</code> is not
|
||||
* defined, then there is no maximum acceptable LogLevel (ie a
|
||||
* LogLevel is never rejected for beeing too "high"/important).
|
||||
*
|
||||
* Refer to the {@link
|
||||
* Appender#setThreshold setThreshold} method
|
||||
* available to <code>all</code> appenders for a more convenient way to
|
||||
* filter out events by LogLevel.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT LogLevelRangeFilter : public Filter {
|
||||
public:
|
||||
// ctors
|
||||
LogLevelRangeFilter();
|
||||
LogLevelRangeFilter(const log4cplus::helpers::Properties& p);
|
||||
|
||||
/**
|
||||
* Return the decision of this filter.
|
||||
*/
|
||||
virtual FilterResult decide(const InternalLoggingEvent& event) const;
|
||||
|
||||
private:
|
||||
// Methods
|
||||
LOG4CPLUS_PRIVATE void init();
|
||||
|
||||
// Data
|
||||
/** Do we return ACCEPT when a match occurs. Default is <code>true</code>. */
|
||||
bool acceptOnMatch;
|
||||
LogLevel logLevelMin;
|
||||
LogLevel logLevelMax;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This is a very simple filter based on string matching.
|
||||
*
|
||||
* The filter admits two options <b>StringToMatch</b> and
|
||||
* <b>AcceptOnMatch</b>. If there is a match between the value of the
|
||||
* StringToMatch option and the message of the Logging event,
|
||||
* then the {@link #decide} method returns {@link #ACCEPT} if
|
||||
* the <b>AcceptOnMatch</b> option value is true, if it is false then
|
||||
* {@link #DENY} is returned. If there is no match, {@link #NEUTRAL}
|
||||
* is returned.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT StringMatchFilter : public Filter {
|
||||
public:
|
||||
// ctors
|
||||
StringMatchFilter();
|
||||
StringMatchFilter(const log4cplus::helpers::Properties& p);
|
||||
|
||||
/**
|
||||
* Returns {@link #NEUTRAL} is there is no string match.
|
||||
*/
|
||||
virtual FilterResult decide(const InternalLoggingEvent& event) const;
|
||||
|
||||
private:
|
||||
// Methods
|
||||
LOG4CPLUS_PRIVATE void init();
|
||||
|
||||
// Data
|
||||
/** Do we return ACCEPT when a match occurs. Default is <code>true</code>. */
|
||||
bool acceptOnMatch;
|
||||
log4cplus::tstring stringToMatch;
|
||||
};
|
||||
|
||||
/**
|
||||
* This filter allows using `std::function<FilterResult(const
|
||||
* InternalLoggingEvent &)>`.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT FunctionFilter
|
||||
: public Filter
|
||||
{
|
||||
public:
|
||||
typedef std::function<FilterResult (const InternalLoggingEvent &)>
|
||||
Function;
|
||||
|
||||
FunctionFilter (Function);
|
||||
|
||||
/**
|
||||
* Returns result returned by `function`.
|
||||
*/
|
||||
virtual FilterResult decide(const InternalLoggingEvent&) const;
|
||||
|
||||
private:
|
||||
Function function;
|
||||
};
|
||||
|
||||
/**
|
||||
* This is a simple filter based on the string returned by event.getNDC().
|
||||
*
|
||||
* The filter admits three options <b>NeutralOnEmpty</b>, <b>NDCToMatch</b>
|
||||
* and <b>AcceptOnMatch</b>.
|
||||
*
|
||||
* If <code>NeutralOnEmpty</code> is true and <code>NDCToMatch</code> is empty
|
||||
* then {@link #NEUTRAL} is returned.
|
||||
*
|
||||
* If <code>NeutralOnEmpty</code> is true and the value returned by event.getNDC() is empty
|
||||
* then {@link #NEUTRAL} is returned.
|
||||
*
|
||||
* If the string returned by event.getNDC() matches <code>NDCToMatch</code>, then if
|
||||
* <b>AcceptOnMatch</b> is true, {@link #ACCEPT} is returned, and if
|
||||
* <b>AcceptOnMatch</b> is false, {@link #DENY} is returned.
|
||||
*
|
||||
* If the string returned by event.getNDC() does not match <code>NDCToMatch</code>, then if
|
||||
* <b>AcceptOnMatch</b> is true, {@link #DENY} is returned, and if
|
||||
* <b>AcceptOnMatch</b> is false, {@link #ACCEPT} is returned.
|
||||
*
|
||||
*/
|
||||
|
||||
class LOG4CPLUS_EXPORT NDCMatchFilter : public Filter
|
||||
{
|
||||
public:
|
||||
// ctors
|
||||
NDCMatchFilter();
|
||||
NDCMatchFilter(const log4cplus::helpers::Properties& p);
|
||||
|
||||
/**
|
||||
* Returns {@link #NEUTRAL} is there is no string match.
|
||||
*/
|
||||
virtual FilterResult decide(const InternalLoggingEvent& event) const;
|
||||
|
||||
private:
|
||||
// Methods
|
||||
LOG4CPLUS_PRIVATE void init();
|
||||
|
||||
// Data
|
||||
/** Do we return ACCEPT when a match occurs. Default is <code>true</code>. */
|
||||
bool acceptOnMatch;
|
||||
/** return NEUTRAL if event.getNDC() is empty or ndcToMatch is empty. Default is <code>true</code>. */
|
||||
bool neutralOnEmpty;
|
||||
log4cplus::tstring ndcToMatch;
|
||||
};
|
||||
|
||||
/**
|
||||
* This is a simple filter based on the key/value pair stored in MDC.
|
||||
*
|
||||
* The filter admits four options <b>NeutralOnEmpty</b>, <b>MDCKeyToMatch</b>
|
||||
* <b>MDCValueToMatch</b> and <b>AcceptOnMatch</b>.
|
||||
*
|
||||
* If <code>NeutralOnEmpty</code> is true and <code>MDCKeyToMatch</code> or <code>MDCValueToMatch</code>
|
||||
* is empty then {@link #NEUTRAL} is returned.
|
||||
*
|
||||
* If <code>NeutralOnEmpty</code> is true and the string returned by event.getMDC(MDCKeyToMatch) is empty
|
||||
* then {@link #NEUTRAL} is returned.
|
||||
*
|
||||
* If the string returned by event.getMDC(MDCKeyToMatch) matches <code>MDCValueToMatch</code>, then if
|
||||
* <b>AcceptOnMatch</b> is true, {@link #ACCEPT} is returned, and if
|
||||
* <b>AcceptOnMatch</b> is false, {@link #DENY} is returned.
|
||||
*
|
||||
* If the string returned by event.getMDC(MDCKeyToMatch) does not match <code>MDCValueToMatch</code>, then if
|
||||
* <b>AcceptOnMatch</b> is true, {@link #DENY} is returned, and if
|
||||
* <b>AcceptOnMatch</b> is false, {@link #ACCEPT} is returned.
|
||||
*
|
||||
*/
|
||||
|
||||
class LOG4CPLUS_EXPORT MDCMatchFilter : public Filter
|
||||
{
|
||||
public:
|
||||
// ctors
|
||||
MDCMatchFilter();
|
||||
MDCMatchFilter(const log4cplus::helpers::Properties& p);
|
||||
|
||||
/**
|
||||
* Returns {@link #NEUTRAL} is there is no string match.
|
||||
*/
|
||||
virtual FilterResult decide(const InternalLoggingEvent& event) const;
|
||||
|
||||
private:
|
||||
// Methods
|
||||
LOG4CPLUS_PRIVATE void init();
|
||||
|
||||
// Data
|
||||
/** Do we return ACCEPT when a match occurs. Default is <code>true</code>. */
|
||||
bool acceptOnMatch;
|
||||
/** return NEUTRAL if mdcKeyToMatch is empty or event::getMDC(mdcKeyValue) is empty or mdcValueToMatch is empty. Default is <code>true</code>. */
|
||||
bool neutralOnEmpty;
|
||||
/** The MDC key to retrieve **/
|
||||
log4cplus::tstring mdcKeyToMatch;
|
||||
/** the MDC value to match **/
|
||||
log4cplus::tstring mdcValueToMatch;
|
||||
};
|
||||
|
||||
} // end namespace spi
|
||||
} // end namespace log4cplus
|
||||
|
||||
#endif /* LOG4CPLUS_SPI_FILTER_HEADER_ */
|
|
@ -0,0 +1,65 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: loggerfactory.h
|
||||
// Created: 6/2001
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2001-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_SPI_LOGGER_FACTORY_HEADER
|
||||
#define LOG4CPLUS_SPI_LOGGER_FACTORY_HEADER
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/tstring.h>
|
||||
|
||||
|
||||
namespace log4cplus {
|
||||
// Forward Declarations
|
||||
class Logger;
|
||||
class Hierarchy;
|
||||
|
||||
namespace spi {
|
||||
class LoggerImpl;
|
||||
|
||||
/**
|
||||
* Implement this interface to create new instances of Logger or
|
||||
* a sub-class of Logger.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT LoggerFactory {
|
||||
public:
|
||||
/**
|
||||
* Creates a new <code>Logger</code> object.
|
||||
*/
|
||||
virtual Logger makeNewLoggerInstance(const log4cplus::tstring_view& name,
|
||||
Hierarchy& h) = 0;
|
||||
virtual ~LoggerFactory() = 0;
|
||||
|
||||
protected:
|
||||
virtual LoggerImpl * makeNewLoggerImplInstance(
|
||||
const log4cplus::tstring_view& name, Hierarchy& h) = 0;
|
||||
};
|
||||
|
||||
} // end namespace spi
|
||||
} // end namespace log4cplus
|
||||
|
||||
#endif // LOG4CPLUS_SPI_LOGGER_FACTORY_HEADER
|
|
@ -0,0 +1,216 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: loggerimpl.h
|
||||
// Created: 6/2001
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2001-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_SPI_LOGGER_HEADER_
|
||||
#define LOG4CPLUS_SPI_LOGGER_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/tstring.h>
|
||||
#include <log4cplus/helpers/appenderattachableimpl.h>
|
||||
#include <log4cplus/helpers/pointer.h>
|
||||
#include <log4cplus/spi/loggerfactory.h>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace log4cplus {
|
||||
class DefaultLoggerFactory;
|
||||
|
||||
namespace spi {
|
||||
|
||||
/**
|
||||
* This is the central class in the log4cplus package. One of the
|
||||
* distintive features of log4cplus are hierarchical loggers and their
|
||||
* evaluation.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT LoggerImpl
|
||||
: public virtual log4cplus::helpers::SharedObject,
|
||||
public log4cplus::helpers::AppenderAttachableImpl
|
||||
{
|
||||
public:
|
||||
typedef helpers::SharedObjectPtr<LoggerImpl> SharedLoggerImplPtr;
|
||||
|
||||
// Methods
|
||||
|
||||
/**
|
||||
* Call the appenders in the hierrachy starting at
|
||||
* <code>this</code>. If no appenders could be found, emit a
|
||||
* warning.
|
||||
*
|
||||
* This method calls all the appenders inherited from the
|
||||
* hierarchy circumventing any evaluation of whether to log or not
|
||||
* to log the particular log request.
|
||||
*
|
||||
* @param event The event to log.
|
||||
*/
|
||||
virtual void callAppenders(const InternalLoggingEvent& event);
|
||||
|
||||
/**
|
||||
* Close all attached appenders implementing the AppenderAttachable
|
||||
* interface.
|
||||
*/
|
||||
virtual void closeNestedAppenders();
|
||||
|
||||
/**
|
||||
* Check whether this logger is enabled for a given LogLevel passed
|
||||
* as parameter.
|
||||
*
|
||||
* @return boolean True if this logger is enabled for <code>ll</code>.
|
||||
*/
|
||||
virtual bool isEnabledFor(LogLevel ll) const;
|
||||
|
||||
/**
|
||||
* This generic form is intended to be used by wrappers.
|
||||
*/
|
||||
virtual void log(LogLevel ll, const log4cplus::tstring_view& message,
|
||||
const char* file=nullptr, int line=-1,
|
||||
const char* function=nullptr);
|
||||
|
||||
virtual void log(spi::InternalLoggingEvent const &);
|
||||
|
||||
/**
|
||||
* Starting from this logger, search the logger hierarchy for a
|
||||
* "set" LogLevel and return it. Otherwise, return the LogLevel of the
|
||||
* root logger.
|
||||
*
|
||||
* The Logger class is designed so that this method executes as
|
||||
* quickly as possible.
|
||||
*/
|
||||
virtual LogLevel getChainedLogLevel() const;
|
||||
|
||||
/**
|
||||
* Returns the assigned LogLevel, if any, for this Logger.
|
||||
*
|
||||
* @return LogLevel - the assigned LogLevel.
|
||||
*/
|
||||
LogLevel getLogLevel() const { return this->ll; }
|
||||
|
||||
/**
|
||||
* Set the LogLevel of this Logger.
|
||||
*/
|
||||
void setLogLevel(LogLevel _ll) { this->ll = _ll; }
|
||||
|
||||
/**
|
||||
* Return the the {@link Hierarchy} where this <code>Logger</code>
|
||||
* instance is attached.
|
||||
*/
|
||||
virtual Hierarchy& getHierarchy() const;
|
||||
|
||||
/**
|
||||
* Return the logger name.
|
||||
*/
|
||||
log4cplus::tstring const & getName() const { return name; }
|
||||
|
||||
/**
|
||||
* Get the additivity flag for this Logger instance.
|
||||
*/
|
||||
bool getAdditivity() const;
|
||||
|
||||
/**
|
||||
* Set the additivity flag for this Logger instance.
|
||||
*/
|
||||
void setAdditivity(bool additive);
|
||||
|
||||
virtual ~LoggerImpl();
|
||||
|
||||
protected:
|
||||
// Ctors
|
||||
/**
|
||||
* This constructor created a new <code>Logger</code> instance and
|
||||
* sets its name.
|
||||
*
|
||||
* It is intended to be used by sub-classes only. You should not
|
||||
* create loggers directly.
|
||||
*
|
||||
* @param name The name of the logger.
|
||||
* @param h Hierarchy
|
||||
*/
|
||||
LoggerImpl(const log4cplus::tstring_view& name, Hierarchy& h);
|
||||
|
||||
|
||||
// Methods
|
||||
/**
|
||||
* This method creates a new logging event and logs the event
|
||||
* without further checks.
|
||||
*/
|
||||
virtual void forcedLog(LogLevel ll,
|
||||
const log4cplus::tstring_view& message,
|
||||
const char* file,
|
||||
int line,
|
||||
const char* function);
|
||||
|
||||
virtual void forcedLog(spi::InternalLoggingEvent const & ev);
|
||||
|
||||
|
||||
// Data
|
||||
/** The name of this logger */
|
||||
log4cplus::tstring name;
|
||||
|
||||
/**
|
||||
* The assigned LogLevel of this logger.
|
||||
*/
|
||||
LogLevel ll;
|
||||
|
||||
/**
|
||||
* The parent of this logger. All loggers have at least one
|
||||
* ancestor which is the root logger.
|
||||
*/
|
||||
SharedLoggerImplPtr parent;
|
||||
|
||||
/**
|
||||
* Additivity is set to true by default, that is children inherit
|
||||
* the appenders of their ancestors by default. If this variable is
|
||||
* set to <code>false</code> then the appenders found in the
|
||||
* ancestors of this logger are not used. However, the children
|
||||
* of this logger will inherit its appenders, unless the children
|
||||
* have their additivity flag set to <code>false</code> too. See
|
||||
* the user manual for more details.
|
||||
*/
|
||||
bool additive;
|
||||
|
||||
private:
|
||||
// Data
|
||||
/** Loggers need to know what Hierarchy they are in. */
|
||||
Hierarchy& hierarchy;
|
||||
|
||||
// Disallow copying of instances of this class
|
||||
LoggerImpl(const LoggerImpl&) = delete;
|
||||
LoggerImpl& operator=(const LoggerImpl&) = delete;
|
||||
|
||||
// Friends
|
||||
friend class log4cplus::Logger;
|
||||
friend class log4cplus::DefaultLoggerFactory;
|
||||
friend class log4cplus::Hierarchy;
|
||||
};
|
||||
|
||||
typedef LoggerImpl::SharedLoggerImplPtr SharedLoggerImplPtr;
|
||||
|
||||
} // end namespace spi
|
||||
} // end namespace log4cplus
|
||||
|
||||
#endif // LOG4CPLUS_SPI_LOGGER_HEADER_
|
|
@ -0,0 +1,241 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: loggingevent.h
|
||||
// Created: 6/2001
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2001-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_SPI_INTERNAL_LOGGING_EVENT_HEADER_
|
||||
#define LOG4CPLUS_SPI_INTERNAL_LOGGING_EVENT_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <memory>
|
||||
#include <log4cplus/loglevel.h>
|
||||
#include <log4cplus/ndc.h>
|
||||
#include <log4cplus/mdc.h>
|
||||
#include <log4cplus/tstring.h>
|
||||
#include <log4cplus/helpers/timehelper.h>
|
||||
#include <log4cplus/thread/threads.h>
|
||||
|
||||
namespace log4cplus {
|
||||
namespace spi {
|
||||
/**
|
||||
* The internal representation of logging events. When an affirmative
|
||||
* decision is made to log then a <code>InternalLoggingEvent</code>
|
||||
* instance is created. This instance is passed around to the
|
||||
* different log4cplus components.
|
||||
*
|
||||
* This class is of concern to those wishing to extend log4cplus.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT InternalLoggingEvent {
|
||||
public:
|
||||
// Ctors
|
||||
/**
|
||||
* Instantiate a LoggingEvent from the supplied parameters.
|
||||
*
|
||||
* @param logger The logger of this event.
|
||||
* @param loglevel The LogLevel of this event.
|
||||
* @param message The message of this event.
|
||||
* @param filename Name of file where this event has occurred,
|
||||
* can be NULL.
|
||||
* @param line Line number in file specified by
|
||||
* the <code>filename</code> parameter.
|
||||
* @param function Name of function that is logging this event.
|
||||
*/
|
||||
InternalLoggingEvent(const log4cplus::tstring_view& logger,
|
||||
LogLevel loglevel, const log4cplus::tstring_view& message,
|
||||
const char* filename, int line, const char * function = nullptr);
|
||||
|
||||
InternalLoggingEvent(const log4cplus::tstring_view& logger,
|
||||
LogLevel loglevel, const log4cplus::tstring_view& ndc,
|
||||
MappedDiagnosticContextMap const & mdc,
|
||||
const log4cplus::tstring_view& message,
|
||||
const log4cplus::tstring_view& thread,
|
||||
log4cplus::helpers::Time time,
|
||||
const log4cplus::tstring_view& file,
|
||||
int line, const log4cplus::tstring_view & function
|
||||
= log4cplus::tstring_view ()) LOG4CPLUS_ATTRIBUTE_DEPRECATED;
|
||||
|
||||
InternalLoggingEvent(const log4cplus::tstring_view& logger,
|
||||
LogLevel loglevel, const log4cplus::tstring_view& ndc,
|
||||
MappedDiagnosticContextMap const & mdc,
|
||||
const log4cplus::tstring_view& message,
|
||||
const log4cplus::tstring_view& thread,
|
||||
const log4cplus::tstring_view& thread2,
|
||||
log4cplus::helpers::Time time,
|
||||
const log4cplus::tstring_view& file,
|
||||
int line, const log4cplus::tstring_view & function
|
||||
= log4cplus::tstring_view ());
|
||||
|
||||
InternalLoggingEvent ();
|
||||
|
||||
InternalLoggingEvent(
|
||||
const log4cplus::spi::InternalLoggingEvent& rhs);
|
||||
|
||||
virtual ~InternalLoggingEvent();
|
||||
|
||||
void setLoggingEvent (const log4cplus::tstring_view & logger,
|
||||
LogLevel ll, const log4cplus::tstring_view & message,
|
||||
const char * filename, int line,
|
||||
const char * function = nullptr);
|
||||
|
||||
void setFunction (char const * func);
|
||||
void setFunction (log4cplus::tstring_view const &);
|
||||
|
||||
|
||||
// public virtual methods
|
||||
/** The application supplied message of logging event. */
|
||||
virtual const log4cplus::tstring& getMessage() const;
|
||||
|
||||
/** Returns the 'type' of InternalLoggingEvent. Derived classes
|
||||
* should override this method. (NOTE: Values <= 1000 are
|
||||
* reserved for log4cplus and should not be used.)
|
||||
*/
|
||||
virtual unsigned int getType() const;
|
||||
|
||||
/** Returns a copy of this object. Derived classes
|
||||
* should override this method.
|
||||
*/
|
||||
virtual std::unique_ptr<InternalLoggingEvent> clone() const;
|
||||
|
||||
|
||||
// public methods
|
||||
/** The logger of the logging event. It is set by
|
||||
* the LoggingEvent constructor.
|
||||
*/
|
||||
const log4cplus::tstring& getLoggerName() const
|
||||
{
|
||||
return loggerName;
|
||||
}
|
||||
|
||||
/** LogLevel of logging event. */
|
||||
LogLevel getLogLevel() const
|
||||
{
|
||||
return ll;
|
||||
}
|
||||
|
||||
/** The nested diagnostic context (NDC) of logging event. */
|
||||
const log4cplus::tstring& getNDC() const
|
||||
{
|
||||
if (!ndcCached)
|
||||
{
|
||||
ndc = log4cplus::getNDC().get();
|
||||
ndcCached = true;
|
||||
}
|
||||
return ndc;
|
||||
}
|
||||
|
||||
MappedDiagnosticContextMap const & getMDCCopy () const
|
||||
{
|
||||
if (!mdcCached)
|
||||
{
|
||||
mdc = log4cplus::getMDC().getContext ();
|
||||
mdcCached = true;
|
||||
}
|
||||
return mdc;
|
||||
}
|
||||
|
||||
tstring const & getMDC (tstring const & key) const;
|
||||
|
||||
/** The name of thread in which this logging event was generated. */
|
||||
const log4cplus::tstring& getThread() const
|
||||
{
|
||||
if (! threadCached)
|
||||
{
|
||||
thread = thread::getCurrentThreadName ();
|
||||
threadCached = true;
|
||||
}
|
||||
return thread;
|
||||
}
|
||||
|
||||
//! The alternative name of thread in which this logging event
|
||||
//! was generated.
|
||||
const log4cplus::tstring& getThread2() const
|
||||
{
|
||||
if (! thread2Cached)
|
||||
{
|
||||
thread2 = thread::getCurrentThreadName2 ();
|
||||
thread2Cached = true;
|
||||
}
|
||||
return thread2;
|
||||
}
|
||||
|
||||
|
||||
/** Time stamp when the event was created. */
|
||||
const log4cplus::helpers::Time& getTimestamp() const
|
||||
{
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
/** The is the file where this log statement was written */
|
||||
const log4cplus::tstring& getFile() const
|
||||
{
|
||||
return file;
|
||||
}
|
||||
|
||||
/** The is the line where this log statement was written */
|
||||
int getLine() const { return line; }
|
||||
|
||||
log4cplus::tstring const & getFunction () const
|
||||
{
|
||||
return function;
|
||||
}
|
||||
|
||||
void gatherThreadSpecificData () const;
|
||||
|
||||
void swap (InternalLoggingEvent &);
|
||||
|
||||
// public operators
|
||||
log4cplus::spi::InternalLoggingEvent&
|
||||
operator=(const log4cplus::spi::InternalLoggingEvent& rhs);
|
||||
|
||||
// static methods
|
||||
static unsigned int getDefaultType();
|
||||
|
||||
protected:
|
||||
// Data
|
||||
log4cplus::tstring message;
|
||||
log4cplus::tstring loggerName;
|
||||
LogLevel ll;
|
||||
mutable log4cplus::tstring ndc;
|
||||
mutable MappedDiagnosticContextMap mdc;
|
||||
mutable log4cplus::tstring thread;
|
||||
mutable log4cplus::tstring thread2;
|
||||
log4cplus::helpers::Time timestamp;
|
||||
log4cplus::tstring file;
|
||||
log4cplus::tstring function;
|
||||
int line;
|
||||
/** Indicates whether or not the Threadname has been retrieved. */
|
||||
mutable bool threadCached;
|
||||
mutable bool thread2Cached;
|
||||
/** Indicates whether or not the NDC has been retrieved. */
|
||||
mutable bool ndcCached;
|
||||
/** Indicates whether or not the MDC has been retrieved. */
|
||||
mutable bool mdcCached;
|
||||
};
|
||||
|
||||
} // end namespace spi
|
||||
} // end namespace log4cplus
|
||||
|
||||
#endif // LOG4CPLUS_SPI_INTERNAL_LOGGING_EVENT_HEADER_
|
|
@ -0,0 +1,113 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: objectregistry.h
|
||||
// Created: 3/2003
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2003-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_SPI_OBJECT_REGISTRY_HEADER_
|
||||
#define LOG4CPLUS_SPI_OBJECT_REGISTRY_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/tstring.h>
|
||||
#include <log4cplus/thread/syncprims.h>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace log4cplus {
|
||||
namespace spi {
|
||||
|
||||
/**
|
||||
* This is the base class used to implement the functionality required
|
||||
* by the ObjectRegistry template class.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT ObjectRegistryBase {
|
||||
public:
|
||||
// public methods
|
||||
/**
|
||||
* Tests to see whether or not an object is bound in the
|
||||
* registry as <code>name</code>.
|
||||
*/
|
||||
bool exists(const log4cplus::tstring& name) const;
|
||||
|
||||
/**
|
||||
* Returns the names of all registered objects.
|
||||
*/
|
||||
std::vector<log4cplus::tstring> getAllNames() const;
|
||||
|
||||
//! This function is internal implementation detail.
|
||||
//! It is related to work-around needed for initialization when
|
||||
//! using C++11 threads and mutexes.
|
||||
void _enableLocking (bool);
|
||||
|
||||
protected:
|
||||
// Ctor and Dtor
|
||||
ObjectRegistryBase();
|
||||
virtual ~ObjectRegistryBase();
|
||||
|
||||
// protected methods
|
||||
/**
|
||||
* Used to enter an object into the registry. (The registry now
|
||||
* owns <code>object</code>.)
|
||||
*/
|
||||
bool putVal(const log4cplus::tstring& name, void* object);
|
||||
|
||||
/**
|
||||
* Used to retrieve an object from the registry. (The registry
|
||||
* owns the returned pointer.)
|
||||
*/
|
||||
void* getVal(const log4cplus::tstring& name) const;
|
||||
|
||||
/**
|
||||
* Deletes <code>object</code>.
|
||||
*/
|
||||
virtual void deleteObject(void *object) const = 0;
|
||||
|
||||
/**
|
||||
* Deletes all objects from this registry.
|
||||
*/
|
||||
virtual void clear();
|
||||
|
||||
// Types
|
||||
typedef std::map<log4cplus::tstring, void*> ObjectMap;
|
||||
|
||||
// Data
|
||||
thread::Mutex mutex;
|
||||
ObjectMap data;
|
||||
|
||||
private:
|
||||
ObjectRegistryBase (ObjectRegistryBase const &);
|
||||
ObjectRegistryBase & operator = (ObjectRegistryBase const &);
|
||||
|
||||
bool volatile locking;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_SPI_OBJECT_REGISTRY_HEADER_
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: rootlogger.h
|
||||
// Created: 6/2001
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2001-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_SPI_ROOT_LOGGER_HEADER_
|
||||
#define LOG4CPLUS_SPI_ROOT_LOGGER_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/spi/loggerimpl.h>
|
||||
|
||||
namespace log4cplus {
|
||||
namespace spi {
|
||||
|
||||
/**
|
||||
* RootLogger sits at the top of the logger hierachy. It is a
|
||||
* regular logger except that it provides several guarantees.
|
||||
*
|
||||
* First, it cannot be assigned a <code>NOT_SET_LOG_LEVEL</code>
|
||||
* LogLevel. Second, since root logger cannot have a parent, the
|
||||
* getChainedLogLevel method always returns the value of the
|
||||
* ll field without walking the hierarchy.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT RootLogger : public LoggerImpl {
|
||||
public:
|
||||
// Ctors
|
||||
/**
|
||||
* The root logger names itself as "root". However, the root
|
||||
* logger cannot be retrieved by name.
|
||||
*/
|
||||
RootLogger(Hierarchy& h, LogLevel ll);
|
||||
|
||||
// Methods
|
||||
/**
|
||||
* Return the assigned LogLevel value without walking the logger
|
||||
* hierarchy.
|
||||
*/
|
||||
virtual LogLevel getChainedLogLevel() const;
|
||||
|
||||
/**
|
||||
* Setting a NOT_SET_LOG_LEVEL value to the LogLevel of the root logger
|
||||
* may have catastrophic results. We prevent this here.
|
||||
*/
|
||||
void setLogLevel(LogLevel);
|
||||
|
||||
};
|
||||
|
||||
} // end namespace spi
|
||||
} // end namespace log4cplus
|
||||
|
||||
#endif // LOG4CPLUS_SPI_ROOT_LOGGER_HEADER_
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: streams.h
|
||||
// Created: 4/2003
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2003-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_STREAMS_HEADER_
|
||||
#define LOG4CPLUS_STREAMS_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/tchar.h>
|
||||
|
||||
#include <iosfwd>
|
||||
|
||||
|
||||
namespace log4cplus
|
||||
{
|
||||
typedef std::basic_ostream<tchar> tostream;
|
||||
typedef std::basic_istream<tchar> tistream;
|
||||
typedef std::basic_ostringstream<tchar> tostringstream;
|
||||
typedef std::basic_istringstream<tchar> tistringstream;
|
||||
extern LOG4CPLUS_EXPORT tostream & tcout;
|
||||
extern LOG4CPLUS_EXPORT tostream & tcerr;
|
||||
}
|
||||
|
||||
#if defined (UNICODE) && defined (LOG4CPLUS_ENABLE_GLOBAL_C_STRING_STREAM_INSERTER)
|
||||
|
||||
LOG4CPLUS_EXPORT log4cplus::tostream& operator <<(log4cplus::tostream&, const char* psz );
|
||||
|
||||
#endif
|
||||
|
||||
#endif // LOG4CPLUS_STREAMS_HEADER_
|
||||
|
|
@ -0,0 +1,160 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: syslogappender.h
|
||||
// Created: 6/2001
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2001-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_SYSLOG_APPENDER_HEADER_
|
||||
#define LOG4CPLUS_SYSLOG_APPENDER_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/appender.h>
|
||||
#include <log4cplus/helpers/socket.h>
|
||||
#include <log4cplus/helpers/connectorthread.h>
|
||||
|
||||
|
||||
namespace log4cplus
|
||||
{
|
||||
|
||||
/**
|
||||
* Appends log events to a file.
|
||||
*
|
||||
* <h3>Properties</h3>
|
||||
* <dl>
|
||||
* <dt><tt>ident</tt></dt>
|
||||
* <dd>First argument to <code>openlog()</code>, a string that
|
||||
* will be prepended to every message.</dd>
|
||||
*
|
||||
* <dt><tt>facility</tt></dt>
|
||||
* <dd>Facility is used in combination with syslog level in first
|
||||
* argument to syslog(). It can be one of the supported facility
|
||||
* names (case insensitive), e.g. auth, cron, kern, mail, news
|
||||
* etc.</dd>
|
||||
*
|
||||
* <dt><tt>host</tt></dt>
|
||||
* <dd>Destination syslog host. When this property is specified,
|
||||
* messages are sent using UDP to destination host, otherwise
|
||||
* messages are logged to local syslog.</dd>
|
||||
*
|
||||
* <dt><tt>port</tt></dt>
|
||||
* <dd>Destination port of syslog service on host specified by the
|
||||
* <tt>host</tt> property. The default value is port 514.</dd>
|
||||
*
|
||||
* <dt><tt>udp</tt></dt> <dd>When the syslog is remote, this
|
||||
* property picks the IP protocol. When the value is true, UDP is
|
||||
* used. When the value is false, TCP is used. The default value
|
||||
* is true.</dd>
|
||||
*
|
||||
* <dt><tt>IPv6</tt></dt>
|
||||
* <dd>Boolean value specifying whether to use IPv6 (true) or IPv4
|
||||
* (false). Default value is false.</dd>
|
||||
*
|
||||
* </dl>
|
||||
*
|
||||
* \note Messages sent to remote syslog using UDP are conforming
|
||||
* to RFC5424. Messages sent to remote syslog using TCP are
|
||||
* using octet counting as described in RFC6587.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT SysLogAppender
|
||||
: public Appender
|
||||
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
, protected virtual helpers::IConnectorThreadClient
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
//! Remote syslog IP protocol type.
|
||||
enum RemoteSyslogType
|
||||
{
|
||||
RSTUdp,
|
||||
RSTTcp
|
||||
};
|
||||
|
||||
// Ctors
|
||||
#if defined (LOG4CPLUS_HAVE_SYSLOG_H)
|
||||
SysLogAppender(const tstring& ident);
|
||||
#endif
|
||||
SysLogAppender(const tstring& ident, const tstring & host,
|
||||
int port = 514, const tstring & facility = tstring (),
|
||||
RemoteSyslogType remoteSyslogType = RSTUdp, bool ipv6 = false);
|
||||
SysLogAppender(const log4cplus::helpers::Properties & properties);
|
||||
|
||||
// Dtor
|
||||
virtual ~SysLogAppender();
|
||||
|
||||
// Methods
|
||||
virtual void close();
|
||||
|
||||
protected:
|
||||
virtual int getSysLogLevel(const LogLevel& ll) const;
|
||||
virtual void append(const spi::InternalLoggingEvent& event);
|
||||
#if defined (LOG4CPLUS_HAVE_SYSLOG_H)
|
||||
//! Local syslog (served by `syslog()`) worker function.
|
||||
void appendLocal(const spi::InternalLoggingEvent& event);
|
||||
#endif
|
||||
//! Remote syslog worker function.
|
||||
void appendRemote(const spi::InternalLoggingEvent& event);
|
||||
|
||||
// Data
|
||||
tstring ident;
|
||||
int facility;
|
||||
|
||||
typedef void (SysLogAppender:: * AppendFuncType) (
|
||||
const spi::InternalLoggingEvent&);
|
||||
AppendFuncType appendFunc;
|
||||
|
||||
tstring host;
|
||||
int port;
|
||||
RemoteSyslogType remoteSyslogType;
|
||||
helpers::Socket syslogSocket;
|
||||
bool connected;
|
||||
bool ipv6 = false;
|
||||
|
||||
static tstring const remoteTimeFormat;
|
||||
|
||||
void initConnector ();
|
||||
void openSocket ();
|
||||
|
||||
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
virtual thread::Mutex const & ctcGetAccessMutex () const;
|
||||
virtual helpers::Socket & ctcGetSocket ();
|
||||
virtual helpers::Socket ctcConnect ();
|
||||
virtual void ctcSetConnected ();
|
||||
|
||||
helpers::SharedObjectPtr<helpers::ConnectorThread> connector;
|
||||
#endif
|
||||
|
||||
private:
|
||||
// Disallow copying of instances of this class
|
||||
SysLogAppender(const SysLogAppender&);
|
||||
SysLogAppender& operator=(const SysLogAppender&);
|
||||
|
||||
std::string identStr;
|
||||
tstring hostname;
|
||||
};
|
||||
|
||||
} // end namespace log4cplus
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_SYSLOG_APPENDER_HEADER_
|
|
@ -0,0 +1,63 @@
|
|||
// -*- C++ -*-
|
||||
// Copyright (C) 2010-2017, Vaclav Haisman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_TCHAR_HEADER_
|
||||
#define LOG4CPLUS_TCHAR_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if defined (_WIN32)
|
||||
#include <cstddef>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef UNICODE
|
||||
# define LOG4CPLUS_TEXT2(STRING) L##STRING
|
||||
#else
|
||||
# define LOG4CPLUS_TEXT2(STRING) STRING
|
||||
#endif // UNICODE
|
||||
#define LOG4CPLUS_TEXT(STRING) LOG4CPLUS_TEXT2(STRING)
|
||||
|
||||
|
||||
namespace log4cplus
|
||||
{
|
||||
|
||||
#if defined (UNICODE)
|
||||
typedef wchar_t tchar;
|
||||
|
||||
#else
|
||||
typedef char tchar;
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace log4cplus
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_TCHAR_HEADER_
|
|
@ -0,0 +1,35 @@
|
|||
// -*- C++ -*-
|
||||
// Copyright (C) 2013-2017, Vaclav Zeman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
//! @file
|
||||
//! This file contains implementations of synchronization
|
||||
//! primitives using the C++11 API. It does not contain any include
|
||||
//! guards because it is only a fragment to be included by
|
||||
//! syncprims.h.
|
||||
|
||||
namespace log4cplus { namespace thread { namespace impl {
|
||||
|
||||
#include "log4cplus/thread/impl/syncprims-pmsm.h"
|
||||
|
||||
} } } // namespace log4cplus { namespace thread { namespace impl {
|
|
@ -0,0 +1,90 @@
|
|||
// -*- C++ -*-
|
||||
// Copyright (C) 2009-2017, Vaclav Haisman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef LOG4CPLUS_THREAD_SYNCPRIMS_IMPL_H
|
||||
#define LOG4CPLUS_THREAD_SYNCPRIMS_IMPL_H
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if ! defined (INSIDE_LOG4CPLUS)
|
||||
# error "This header must not be be used outside log4cplus' implementation files."
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
#include <log4cplus/thread/syncprims.h>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <condition_variable>
|
||||
|
||||
|
||||
namespace log4cplus { namespace thread { namespace impl {
|
||||
|
||||
|
||||
LOG4CPLUS_EXPORT void LOG4CPLUS_ATTRIBUTE_NORETURN
|
||||
syncprims_throw_exception (char const * const msg,
|
||||
char const * const file, int line);
|
||||
|
||||
|
||||
class SharedMutex
|
||||
: public SharedMutexImplBase
|
||||
{
|
||||
public:
|
||||
SharedMutex ();
|
||||
~SharedMutex ();
|
||||
|
||||
void rdlock () const;
|
||||
void wrlock () const;
|
||||
void rdunlock () const;
|
||||
void wrunlock () const;
|
||||
|
||||
private:
|
||||
Mutex m1;
|
||||
Mutex m2;
|
||||
Mutex m3;
|
||||
Semaphore w;
|
||||
mutable unsigned writer_count;
|
||||
Semaphore r;
|
||||
mutable unsigned reader_count;
|
||||
|
||||
SharedMutex (SharedMutex const &);
|
||||
SharedMutex & operator = (SharedMutex const &);
|
||||
};
|
||||
|
||||
|
||||
} } } // namespace log4cplus { namespace thread { namespace impl {
|
||||
|
||||
|
||||
// Include the appropriate implementations of the classes declared
|
||||
// above.
|
||||
|
||||
#include <log4cplus/thread/impl/syncprims-cxx11.h>
|
||||
|
||||
#undef LOG4CPLUS_THROW_RTE
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_THREAD_SYNCPRIMS_IMPL_H
|
|
@ -0,0 +1,119 @@
|
|||
// -*- C++ -*-
|
||||
// Copyright (C) 2010-2017, Vaclav Haisman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
//! @file
|
||||
//! This file contains implementations of reader-writer locking
|
||||
//! primitive using other primitives, IOW poor man's rwlock.
|
||||
//! It does not contain any include guards because it is only a fragment
|
||||
//! to be included by syncprims-{pthreads,win32}.h.
|
||||
|
||||
|
||||
#if ! defined (INSIDE_LOG4CPLUS)
|
||||
# error "This header must not be be used outside log4cplus' implementation files."
|
||||
#endif
|
||||
|
||||
|
||||
// This implements algorithm described in "Concurrent Control with "Readers"
|
||||
// and "Writers"; P.J. Courtois, F. Heymans, and D.L. Parnas;
|
||||
// MBLE Research Laboratory; Brussels, Belgium"
|
||||
|
||||
|
||||
inline
|
||||
SharedMutex::SharedMutex ()
|
||||
: m1 ()
|
||||
, m2 ()
|
||||
, m3 ()
|
||||
, w (1, 1)
|
||||
, writer_count (0)
|
||||
, r (1, 1)
|
||||
, reader_count (0)
|
||||
{ }
|
||||
|
||||
|
||||
inline
|
||||
SharedMutex::~SharedMutex ()
|
||||
{ }
|
||||
|
||||
|
||||
inline
|
||||
void
|
||||
SharedMutex::rdlock () const
|
||||
{
|
||||
MutexGuard m3_guard (m3);
|
||||
SemaphoreGuard r_guard (r);
|
||||
MutexGuard m1_guard (m1);
|
||||
if (reader_count + 1 == 1)
|
||||
w.lock ();
|
||||
|
||||
reader_count += 1;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
void
|
||||
SharedMutex::rdunlock () const
|
||||
{
|
||||
MutexGuard m1_guard (m1);
|
||||
if (reader_count - 1 == 0)
|
||||
w.unlock ();
|
||||
|
||||
reader_count -= 1;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
void
|
||||
SharedMutex::wrlock () const
|
||||
{
|
||||
{
|
||||
MutexGuard m2_guard (m2);
|
||||
if (writer_count + 1 == 1)
|
||||
r.lock ();
|
||||
|
||||
writer_count += 1;
|
||||
}
|
||||
try
|
||||
{
|
||||
w.lock ();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
MutexGuard m2_guard (m2);
|
||||
writer_count -= 1;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
void
|
||||
SharedMutex::wrunlock () const
|
||||
{
|
||||
w.unlock ();
|
||||
MutexGuard m2_guard (m2);
|
||||
if (writer_count - 1 == 0)
|
||||
r.unlock ();
|
||||
|
||||
writer_count -= 1;
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: threads.h
|
||||
// Created: 6/2001
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2001-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_IMPL_THREADS_IMPL_HEADER_
|
||||
#define LOG4CPLUS_IMPL_THREADS_IMPL_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if defined (_WIN32)
|
||||
#include <log4cplus/config/windowsh-inc.h>
|
||||
#endif
|
||||
#include <log4cplus/tstring.h>
|
||||
#include <log4cplus/helpers/pointer.h>
|
||||
#include <log4cplus/thread/threads.h>
|
||||
|
||||
#if ! defined (INSIDE_LOG4CPLUS)
|
||||
# error "This header must not be be used outside log4cplus' implementation files."
|
||||
#endif
|
||||
|
||||
|
||||
namespace log4cplus { namespace thread { namespace impl {
|
||||
|
||||
|
||||
#if defined (LOG4CPLUS_USE_PTHREADS)
|
||||
|
||||
typedef pthread_t os_handle_type;
|
||||
typedef pthread_t os_id_type;
|
||||
|
||||
|
||||
inline
|
||||
pthread_t
|
||||
getCurrentThreadId ()
|
||||
{
|
||||
return pthread_self ();
|
||||
}
|
||||
|
||||
|
||||
#elif defined (LOG4CPLUS_USE_WIN32_THREADS)
|
||||
|
||||
typedef HANDLE os_handle_type;
|
||||
typedef DWORD os_id_type;
|
||||
|
||||
|
||||
inline
|
||||
DWORD
|
||||
getCurrentThreadId ()
|
||||
{
|
||||
return GetCurrentThreadId ();
|
||||
}
|
||||
|
||||
|
||||
#elif defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
|
||||
typedef void * os_handle_type;
|
||||
typedef int os_id_type;
|
||||
|
||||
|
||||
inline
|
||||
int
|
||||
getCurrentThreadId ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
} } } // namespace log4cplus { namespace thread { namespace impl {
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_IMPL_THREADS_IMPL_HEADER_
|
|
@ -0,0 +1,193 @@
|
|||
// -*- C++ -*-
|
||||
// Copyright (C) 2010-2017, Vaclav Haisman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef LOG4CPLUS_THREAD_IMPL_TLS_H
|
||||
#define LOG4CPLUS_THREAD_IMPL_TLS_H
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <new>
|
||||
#include <cassert>
|
||||
#include <system_error>
|
||||
|
||||
#if ! defined (INSIDE_LOG4CPLUS)
|
||||
# error "This header must not be be used outside log4cplus' implementation files."
|
||||
#endif
|
||||
|
||||
#ifdef LOG4CPLUS_USE_PTHREADS
|
||||
# include <pthread.h>
|
||||
|
||||
#elif defined (LOG4CPLUS_USE_WIN32_THREADS)
|
||||
# include <log4cplus/config/windowsh-inc.h>
|
||||
|
||||
#elif defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
# include <vector>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
namespace log4cplus { namespace thread { namespace impl {
|
||||
|
||||
|
||||
typedef void * tls_value_type;
|
||||
|
||||
#ifdef LOG4CPLUS_USE_PTHREADS
|
||||
typedef pthread_key_t * tls_key_type;
|
||||
typedef void (* tls_init_cleanup_func_type)(void *);
|
||||
|
||||
#elif defined (LOG4CPLUS_USE_WIN32_THREADS)
|
||||
typedef DWORD tls_key_type;
|
||||
typedef PFLS_CALLBACK_FUNCTION tls_init_cleanup_func_type;
|
||||
|
||||
#elif defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
typedef std::size_t tls_key_type;
|
||||
typedef void (* tls_init_cleanup_func_type)(void *);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
inline tls_key_type tls_init (tls_init_cleanup_func_type);
|
||||
inline tls_value_type tls_get_value (tls_key_type);
|
||||
inline void tls_set_value (tls_key_type, tls_value_type);
|
||||
inline void tls_cleanup (tls_key_type);
|
||||
|
||||
|
||||
#if defined (LOG4CPLUS_USE_PTHREADS)
|
||||
tls_key_type
|
||||
tls_init (tls_init_cleanup_func_type cleanupfunc)
|
||||
{
|
||||
pthread_key_t * key = new pthread_key_t;
|
||||
int ret = pthread_key_create (key, cleanupfunc);
|
||||
if (LOG4CPLUS_UNLIKELY (ret != 0))
|
||||
throw std::system_error(ret, std::system_category (),
|
||||
"pthread_key_create() failed");
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
tls_value_type
|
||||
tls_get_value (tls_key_type key)
|
||||
{
|
||||
return pthread_getspecific (*key);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
tls_set_value (tls_key_type key, tls_value_type value)
|
||||
{
|
||||
pthread_setspecific(*key, value);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
tls_cleanup (tls_key_type key)
|
||||
{
|
||||
pthread_key_delete (*key);
|
||||
delete key;
|
||||
}
|
||||
|
||||
|
||||
#elif defined (LOG4CPLUS_USE_WIN32_THREADS)
|
||||
tls_key_type
|
||||
tls_init (tls_init_cleanup_func_type cleanupfunc)
|
||||
{
|
||||
DWORD const slot = FlsAlloc (cleanupfunc);
|
||||
if (LOG4CPLUS_UNLIKELY (slot == FLS_OUT_OF_INDEXES))
|
||||
{
|
||||
DWORD const eno = GetLastError ();
|
||||
throw std::system_error (static_cast<int>(eno),
|
||||
std::system_category (), "FlsAlloc() failed");
|
||||
}
|
||||
return slot;
|
||||
}
|
||||
|
||||
|
||||
tls_value_type tls_get_value (tls_key_type k)
|
||||
{
|
||||
return FlsGetValue (k);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
tls_set_value (tls_key_type k, tls_value_type value)
|
||||
{
|
||||
FlsSetValue (k, value);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
tls_cleanup (tls_key_type k)
|
||||
{
|
||||
FlsFree (k);
|
||||
}
|
||||
|
||||
|
||||
#elif defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
extern std::vector<tls_value_type> * tls_single_threaded_values;
|
||||
|
||||
|
||||
tls_key_type
|
||||
tls_init (tls_init_cleanup_func_type)
|
||||
{
|
||||
if (! tls_single_threaded_values)
|
||||
tls_single_threaded_values = new std::vector<tls_value_type>;
|
||||
tls_key_type key = tls_single_threaded_values->size ();
|
||||
tls_single_threaded_values->resize (key + 1);
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
tls_value_type
|
||||
tls_get_value (tls_key_type k)
|
||||
{
|
||||
assert (k < tls_single_threaded_values->size ());
|
||||
return (*tls_single_threaded_values)[k];
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
tls_set_value (tls_key_type k, tls_value_type val)
|
||||
{
|
||||
assert (k < tls_single_threaded_values->size ());
|
||||
(*tls_single_threaded_values)[k] = val;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
tls_cleanup (tls_key_type k)
|
||||
{
|
||||
assert (k < tls_single_threaded_values->size ());
|
||||
(*tls_single_threaded_values)[k] = 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
} } } // namespace log4cplus { namespace thread { namespace impl {
|
||||
|
||||
#endif // LOG4CPLUS_THREAD_IMPL_TLS_H
|
|
@ -0,0 +1,317 @@
|
|||
// -*- C++ -*-
|
||||
// Copyright (C) 2010-2017, Vaclav Haisman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef LOG4CPLUS_THREAD_SYNCPRIMS_PUB_IMPL_H
|
||||
#define LOG4CPLUS_THREAD_SYNCPRIMS_PUB_IMPL_H
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#if (defined (LOG4CPLUS_INLINES_ARE_EXPORTED) \
|
||||
&& defined (LOG4CPLUS_BUILD_DLL)) \
|
||||
|| defined (LOG4CPLUS_ENABLE_SYNCPRIMS_PUB_IMPL)
|
||||
#include <log4cplus/thread/syncprims.h>
|
||||
|
||||
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
# include <log4cplus/thread/impl/syncprims-impl.h>
|
||||
#endif
|
||||
|
||||
#define LOG4CPLUS_THROW_RTE(msg) \
|
||||
do { log4cplus::thread::impl::syncprims_throw_exception (msg, __FILE__, \
|
||||
__LINE__); } while (0)
|
||||
|
||||
namespace log4cplus { namespace thread {
|
||||
|
||||
namespace impl
|
||||
{
|
||||
|
||||
LOG4CPLUS_EXPORT void LOG4CPLUS_ATTRIBUTE_NORETURN
|
||||
syncprims_throw_exception(char const * const msg,
|
||||
char const * const file, int line);
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
LOG4CPLUS_INLINE_EXPORT
|
||||
Mutex::Mutex ()
|
||||
LOG4CPLUS_THREADED (: mtx ())
|
||||
{ }
|
||||
|
||||
|
||||
LOG4CPLUS_INLINE_EXPORT
|
||||
Mutex::~Mutex ()
|
||||
{ }
|
||||
|
||||
|
||||
LOG4CPLUS_INLINE_EXPORT
|
||||
void
|
||||
Mutex::lock () const
|
||||
{
|
||||
LOG4CPLUS_THREADED (mtx.lock ());
|
||||
}
|
||||
|
||||
|
||||
LOG4CPLUS_INLINE_EXPORT
|
||||
void
|
||||
Mutex::unlock () const
|
||||
{
|
||||
LOG4CPLUS_THREADED (mtx.unlock ());
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
LOG4CPLUS_INLINE_EXPORT
|
||||
Semaphore::Semaphore (unsigned LOG4CPLUS_THREADED (max),
|
||||
unsigned LOG4CPLUS_THREADED (initial))
|
||||
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
: max_ (max)
|
||||
, val ((std::min) (max_, initial))
|
||||
#endif
|
||||
{ }
|
||||
|
||||
|
||||
LOG4CPLUS_INLINE_EXPORT
|
||||
Semaphore::~Semaphore ()
|
||||
{ }
|
||||
|
||||
|
||||
LOG4CPLUS_INLINE_EXPORT
|
||||
void
|
||||
Semaphore::unlock () const
|
||||
{
|
||||
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
std::lock_guard<std::mutex> guard (mtx);
|
||||
|
||||
if (val >= max_)
|
||||
LOG4CPLUS_THROW_RTE ("Semaphore::unlock(): val >= max");
|
||||
|
||||
++val;
|
||||
cv.notify_all ();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
LOG4CPLUS_INLINE_EXPORT
|
||||
void
|
||||
Semaphore::lock () const
|
||||
{
|
||||
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
std::unique_lock<std::mutex> guard (mtx);
|
||||
|
||||
if (LOG4CPLUS_UNLIKELY(val > max_))
|
||||
LOG4CPLUS_THROW_RTE ("Semaphore::unlock(): val > max");
|
||||
|
||||
while (val == 0)
|
||||
cv.wait (guard);
|
||||
|
||||
--val;
|
||||
|
||||
if (LOG4CPLUS_UNLIKELY(val >= max_))
|
||||
LOG4CPLUS_THROW_RTE ("Semaphore::unlock(): val >= max");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
LOG4CPLUS_INLINE_EXPORT
|
||||
ManualResetEvent::ManualResetEvent (bool LOG4CPLUS_THREADED (sig))
|
||||
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
: signaled (sig)
|
||||
, sigcount (0)
|
||||
#endif
|
||||
{ }
|
||||
|
||||
|
||||
LOG4CPLUS_INLINE_EXPORT
|
||||
ManualResetEvent::~ManualResetEvent ()
|
||||
{ }
|
||||
|
||||
|
||||
LOG4CPLUS_INLINE_EXPORT
|
||||
void
|
||||
ManualResetEvent::signal () const
|
||||
{
|
||||
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
std::unique_lock<std::mutex> guard (mtx);
|
||||
|
||||
signaled = true;
|
||||
sigcount += 1;
|
||||
cv.notify_all ();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
LOG4CPLUS_INLINE_EXPORT
|
||||
void
|
||||
ManualResetEvent::wait () const
|
||||
{
|
||||
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
std::unique_lock<std::mutex> guard (mtx);
|
||||
|
||||
if (! signaled)
|
||||
{
|
||||
unsigned prev_count = sigcount;
|
||||
do
|
||||
{
|
||||
cv.wait (guard);
|
||||
}
|
||||
while (prev_count == sigcount);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
LOG4CPLUS_INLINE_EXPORT
|
||||
bool
|
||||
ManualResetEvent::timed_wait (unsigned long LOG4CPLUS_THREADED (msec)) const
|
||||
{
|
||||
#if defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
return true;
|
||||
|
||||
#else
|
||||
std::unique_lock<std::mutex> guard (mtx);
|
||||
|
||||
if (! signaled)
|
||||
{
|
||||
unsigned prev_count = sigcount;
|
||||
|
||||
std::chrono::steady_clock::time_point const wait_until_time
|
||||
= std::chrono::steady_clock::now ()
|
||||
+ std::chrono::milliseconds (msec);
|
||||
|
||||
do
|
||||
{
|
||||
int ret = static_cast<int>(
|
||||
cv.wait_until (guard, wait_until_time));
|
||||
switch (ret)
|
||||
{
|
||||
case static_cast<int>(std::cv_status::no_timeout):
|
||||
break;
|
||||
|
||||
case static_cast<int>(std::cv_status::timeout):
|
||||
return false;
|
||||
|
||||
default:
|
||||
guard.unlock ();
|
||||
guard.release ();
|
||||
LOG4CPLUS_THROW_RTE ("ManualResetEvent::timed_wait");
|
||||
}
|
||||
}
|
||||
while (prev_count == sigcount);
|
||||
}
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
LOG4CPLUS_INLINE_EXPORT
|
||||
void
|
||||
ManualResetEvent::reset () const
|
||||
{
|
||||
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
std::lock_guard<std::mutex> guard (mtx);
|
||||
|
||||
signaled = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
LOG4CPLUS_INLINE_EXPORT
|
||||
SharedMutexImplBase::~SharedMutexImplBase ()
|
||||
{ }
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
LOG4CPLUS_INLINE_EXPORT
|
||||
SharedMutex::SharedMutex ()
|
||||
: sm (LOG4CPLUS_THREADED (new impl::SharedMutex))
|
||||
{ }
|
||||
|
||||
|
||||
LOG4CPLUS_INLINE_EXPORT
|
||||
SharedMutex::~SharedMutex ()
|
||||
{
|
||||
LOG4CPLUS_THREADED (delete static_cast<impl::SharedMutex *>(sm));
|
||||
}
|
||||
|
||||
|
||||
LOG4CPLUS_INLINE_EXPORT
|
||||
void
|
||||
SharedMutex::rdlock () const
|
||||
{
|
||||
LOG4CPLUS_THREADED (static_cast<impl::SharedMutex *>(sm)->rdlock ());
|
||||
}
|
||||
|
||||
|
||||
LOG4CPLUS_INLINE_EXPORT
|
||||
void
|
||||
SharedMutex::wrlock () const
|
||||
{
|
||||
LOG4CPLUS_THREADED (static_cast<impl::SharedMutex *>(sm)->wrlock ());
|
||||
}
|
||||
|
||||
|
||||
LOG4CPLUS_INLINE_EXPORT
|
||||
void
|
||||
SharedMutex::rdunlock () const
|
||||
{
|
||||
LOG4CPLUS_THREADED (static_cast<impl::SharedMutex *>(sm)->rdunlock ());
|
||||
}
|
||||
|
||||
|
||||
LOG4CPLUS_INLINE_EXPORT
|
||||
void
|
||||
SharedMutex::wrunlock () const
|
||||
{
|
||||
LOG4CPLUS_THREADED (static_cast<impl::SharedMutex *>(sm)->wrunlock ());
|
||||
}
|
||||
|
||||
|
||||
} } // namespace log4cplus { namespace thread {
|
||||
|
||||
#endif // LOG4CPLUS_ENABLE_SYNCPRIMS_PUB_IMPL
|
||||
|
||||
#endif // LOG4CPLUS_THREAD_SYNCPRIMS_PUB_IMPL_H
|
|
@ -0,0 +1,335 @@
|
|||
// -*- C++ -*-
|
||||
// Copyright (C) 2010-2017, Vaclav Haisman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef LOG4CPLUS_THREAD_SYNCPRIMS_H
|
||||
#define LOG4CPLUS_THREAD_SYNCPRIMS_H
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
|
||||
|
||||
namespace log4cplus { namespace thread {
|
||||
|
||||
|
||||
template <typename SyncPrim>
|
||||
class SyncGuard
|
||||
{
|
||||
public:
|
||||
SyncGuard ();
|
||||
SyncGuard (SyncPrim const &);
|
||||
~SyncGuard ();
|
||||
SyncGuard (SyncGuard const &) = delete;
|
||||
SyncGuard & operator = (SyncGuard const &) = delete;
|
||||
|
||||
|
||||
void lock ();
|
||||
void unlock ();
|
||||
void attach (SyncPrim const &);
|
||||
void attach_and_lock (SyncPrim const &);
|
||||
void detach ();
|
||||
|
||||
private:
|
||||
SyncPrim const * sp;
|
||||
};
|
||||
|
||||
|
||||
class LOG4CPLUS_EXPORT Mutex
|
||||
{
|
||||
public:
|
||||
Mutex ();
|
||||
~Mutex ();
|
||||
Mutex (Mutex const &) = delete;
|
||||
Mutex & operator = (Mutex const &) = delete;
|
||||
|
||||
void lock () const;
|
||||
void unlock () const;
|
||||
|
||||
private:
|
||||
LOG4CPLUS_THREADED (mutable std::recursive_mutex mtx;)
|
||||
};
|
||||
|
||||
|
||||
typedef SyncGuard<Mutex> MutexGuard;
|
||||
|
||||
|
||||
class LOG4CPLUS_EXPORT Semaphore
|
||||
{
|
||||
public:
|
||||
Semaphore (unsigned max, unsigned initial);
|
||||
~Semaphore ();
|
||||
Semaphore (Semaphore const &) = delete;
|
||||
Semaphore & operator = (Semaphore const &) = delete;
|
||||
|
||||
void lock () const;
|
||||
void unlock () const;
|
||||
|
||||
private:
|
||||
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
mutable std::mutex mtx;
|
||||
mutable std::condition_variable cv;
|
||||
mutable unsigned max_;
|
||||
mutable unsigned val;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
typedef SyncGuard<Semaphore> SemaphoreGuard;
|
||||
|
||||
|
||||
class LOG4CPLUS_EXPORT ManualResetEvent
|
||||
{
|
||||
public:
|
||||
explicit ManualResetEvent (bool = false);
|
||||
~ManualResetEvent ();
|
||||
ManualResetEvent (ManualResetEvent const &) = delete;
|
||||
ManualResetEvent & operator = (ManualResetEvent const &) = delete;
|
||||
|
||||
void signal () const;
|
||||
void wait () const;
|
||||
bool timed_wait (unsigned long msec) const;
|
||||
void reset () const;
|
||||
|
||||
private:
|
||||
#if ! defined (LOG4CPLUS_SINGLE_THREADED)
|
||||
mutable std::mutex mtx;
|
||||
mutable std::condition_variable cv;
|
||||
mutable bool signaled;
|
||||
mutable unsigned sigcount;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
class SharedMutexImplBase
|
||||
{
|
||||
protected:
|
||||
~SharedMutexImplBase ();
|
||||
};
|
||||
|
||||
|
||||
template <typename SyncPrim, void (SyncPrim:: * lock_func) () const,
|
||||
void (SyncPrim:: * unlock_func) () const>
|
||||
class SyncGuardFunc
|
||||
{
|
||||
public:
|
||||
SyncGuardFunc (SyncPrim const &);
|
||||
~SyncGuardFunc ();
|
||||
|
||||
void lock ();
|
||||
void unlock ();
|
||||
void attach (SyncPrim const &);
|
||||
void detach ();
|
||||
|
||||
private:
|
||||
SyncPrim const * sp;
|
||||
|
||||
SyncGuardFunc (SyncGuardFunc const &);
|
||||
SyncGuardFunc & operator = (SyncGuardFunc const &);
|
||||
};
|
||||
|
||||
|
||||
class LOG4CPLUS_EXPORT SharedMutex
|
||||
{
|
||||
public:
|
||||
SharedMutex ();
|
||||
~SharedMutex ();
|
||||
|
||||
void rdlock () const;
|
||||
void rdunlock () const;
|
||||
|
||||
void wrlock () const;
|
||||
void wrunlock () const;
|
||||
|
||||
private:
|
||||
SharedMutexImplBase * sm;
|
||||
|
||||
SharedMutex (SharedMutex const &);
|
||||
SharedMutex & operator = (SharedMutex const &);
|
||||
};
|
||||
|
||||
|
||||
typedef SyncGuardFunc<SharedMutex, &SharedMutex::rdlock,
|
||||
&SharedMutex::rdunlock> SharedMutexReaderGuard;
|
||||
|
||||
|
||||
typedef SyncGuardFunc<SharedMutex, &SharedMutex::wrlock,
|
||||
&SharedMutex::wrunlock> SharedMutexWriterGuard;
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
template <typename SyncPrim>
|
||||
inline
|
||||
SyncGuard<SyncPrim>::SyncGuard ()
|
||||
: sp (0)
|
||||
{ }
|
||||
|
||||
|
||||
template <typename SyncPrim>
|
||||
inline
|
||||
SyncGuard<SyncPrim>::SyncGuard (SyncPrim const & m)
|
||||
: sp (&m)
|
||||
{
|
||||
sp->lock ();
|
||||
}
|
||||
|
||||
|
||||
template <typename SyncPrim>
|
||||
inline
|
||||
SyncGuard<SyncPrim>::~SyncGuard ()
|
||||
{
|
||||
if (sp)
|
||||
sp->unlock ();
|
||||
}
|
||||
|
||||
|
||||
template <typename SyncPrim>
|
||||
inline
|
||||
void
|
||||
SyncGuard<SyncPrim>::lock ()
|
||||
{
|
||||
sp->lock ();
|
||||
}
|
||||
|
||||
|
||||
template <typename SyncPrim>
|
||||
inline
|
||||
void
|
||||
SyncGuard<SyncPrim>::unlock ()
|
||||
{
|
||||
sp->unlock ();
|
||||
}
|
||||
|
||||
|
||||
template <typename SyncPrim>
|
||||
inline
|
||||
void
|
||||
SyncGuard<SyncPrim>::attach (SyncPrim const & m)
|
||||
{
|
||||
sp = &m;
|
||||
}
|
||||
|
||||
|
||||
template <typename SyncPrim>
|
||||
inline
|
||||
void
|
||||
SyncGuard<SyncPrim>::attach_and_lock (SyncPrim const & m)
|
||||
{
|
||||
attach (m);
|
||||
try
|
||||
{
|
||||
lock();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
detach ();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename SyncPrim>
|
||||
inline
|
||||
void
|
||||
SyncGuard<SyncPrim>::detach ()
|
||||
{
|
||||
sp = 0;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
template <typename SyncPrim, void (SyncPrim:: * lock_func) () const,
|
||||
void (SyncPrim:: * unlock_func) () const>
|
||||
inline
|
||||
SyncGuardFunc<SyncPrim, lock_func, unlock_func>::SyncGuardFunc (SyncPrim const & m)
|
||||
: sp (&m)
|
||||
{
|
||||
(sp->*lock_func) ();
|
||||
}
|
||||
|
||||
|
||||
template <typename SyncPrim, void (SyncPrim:: * lock_func) () const,
|
||||
void (SyncPrim:: * unlock_func) () const>
|
||||
inline
|
||||
SyncGuardFunc<SyncPrim, lock_func, unlock_func>::~SyncGuardFunc ()
|
||||
{
|
||||
if (sp)
|
||||
(sp->*unlock_func) ();
|
||||
}
|
||||
|
||||
|
||||
template <typename SyncPrim, void (SyncPrim:: * lock_func) () const,
|
||||
void (SyncPrim:: * unlock_func) () const>
|
||||
inline
|
||||
void
|
||||
SyncGuardFunc<SyncPrim, lock_func, unlock_func>::lock ()
|
||||
{
|
||||
(sp->*lock_func) ();
|
||||
}
|
||||
|
||||
|
||||
template <typename SyncPrim, void (SyncPrim:: * lock_func) () const,
|
||||
void (SyncPrim:: * unlock_func) () const>
|
||||
inline
|
||||
void
|
||||
SyncGuardFunc<SyncPrim, lock_func, unlock_func>::unlock ()
|
||||
{
|
||||
(sp->*unlock_func) ();
|
||||
}
|
||||
|
||||
|
||||
template <typename SyncPrim, void (SyncPrim:: * lock_func) () const,
|
||||
void (SyncPrim:: * unlock_func) () const>
|
||||
inline
|
||||
void
|
||||
SyncGuardFunc<SyncPrim, lock_func, unlock_func>::attach (SyncPrim const & m)
|
||||
{
|
||||
sp = &m;
|
||||
}
|
||||
|
||||
|
||||
template <typename SyncPrim, void (SyncPrim:: * lock_func) () const,
|
||||
void (SyncPrim:: * unlock_func) () const>
|
||||
inline
|
||||
void
|
||||
SyncGuardFunc<SyncPrim, lock_func, unlock_func>::detach ()
|
||||
{
|
||||
sp = 0;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace log4cplus { namespace thread {
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_THREAD_SYNCPRIMS_H
|
|
@ -0,0 +1,113 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: threads.h
|
||||
// Created: 6/2001
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2001-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_THREADS_HEADER_
|
||||
#define LOG4CPLUS_THREADS_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
|
||||
#include <log4cplus/tstring.h>
|
||||
#include <log4cplus/helpers/pointer.h>
|
||||
|
||||
|
||||
namespace log4cplus { namespace thread {
|
||||
|
||||
|
||||
LOG4CPLUS_EXPORT log4cplus::tstring const & getCurrentThreadName();
|
||||
LOG4CPLUS_EXPORT log4cplus::tstring const & getCurrentThreadName2();
|
||||
LOG4CPLUS_EXPORT void setCurrentThreadName(const log4cplus::tstring & name);
|
||||
LOG4CPLUS_EXPORT void setCurrentThreadName2(const log4cplus::tstring & name);
|
||||
LOG4CPLUS_EXPORT void yield();
|
||||
LOG4CPLUS_EXPORT void blockAllSignals();
|
||||
|
||||
/**
|
||||
* This class blocks all POSIX signals when created and unblocks them when
|
||||
* destroyed.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT SignalsBlocker
|
||||
{
|
||||
public:
|
||||
SignalsBlocker();
|
||||
~SignalsBlocker();
|
||||
|
||||
private:
|
||||
struct SignalsBlockerImpl;
|
||||
std::unique_ptr<SignalsBlockerImpl> impl;
|
||||
};
|
||||
|
||||
|
||||
#ifndef LOG4CPLUS_SINGLE_THREADED
|
||||
|
||||
|
||||
/**
|
||||
* There are many cross-platform C++ Threading libraries. The goal of
|
||||
* this class is not to replace (or match in functionality) those
|
||||
* libraries. The goal of this class is to provide a simple Threading
|
||||
* class with basic functionality.
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT AbstractThread
|
||||
: public virtual log4cplus::helpers::SharedObject
|
||||
{
|
||||
public:
|
||||
AbstractThread();
|
||||
// Disallow copying of instances of this class.
|
||||
AbstractThread(const AbstractThread&) = delete;
|
||||
AbstractThread& operator=(const AbstractThread&) = delete;
|
||||
|
||||
bool isRunning() const;
|
||||
virtual void start();
|
||||
void join () const;
|
||||
virtual void run() = 0;
|
||||
|
||||
protected:
|
||||
// Force objects to be constructed on the heap
|
||||
virtual ~AbstractThread();
|
||||
|
||||
private:
|
||||
enum Flags
|
||||
{
|
||||
fRUNNING = 1,
|
||||
fJOINED = 2
|
||||
};
|
||||
|
||||
std::unique_ptr<std::thread> thread;
|
||||
mutable std::atomic<int> flags;
|
||||
};
|
||||
|
||||
typedef helpers::SharedObjectPtr<AbstractThread> AbstractThreadPtr;
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_SINGLE_THREADED
|
||||
|
||||
|
||||
} } // namespace log4cplus { namespace thread {
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_THREADS_HEADER_
|
|
@ -0,0 +1,87 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: tracelogger.h
|
||||
// Created: 1/2009
|
||||
// Author: Vaclav Haisman
|
||||
//
|
||||
//
|
||||
// Copyright 2009-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_TRACELOGGER_H
|
||||
#define LOG4CPLUS_TRACELOGGER_H
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <log4cplus/logger.h>
|
||||
|
||||
|
||||
namespace log4cplus
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* This class is used to produce "Trace" logging. When an instance of
|
||||
* this class is created, it will log a <code>"ENTER: " + msg</code>
|
||||
* log message if TRACE_LOG_LEVEL is enabled for <code>logger</code>.
|
||||
* When an instance of this class is destroyed, it will log a
|
||||
* <code>"ENTER: " + msg</code> log message if TRACE_LOG_LEVEL is enabled
|
||||
* for <code>logger</code>.
|
||||
* <p>
|
||||
* @see LOG4CPLUS_TRACE
|
||||
*/
|
||||
class TraceLogger
|
||||
{
|
||||
public:
|
||||
TraceLogger(Logger l, log4cplus::tstring _msg,
|
||||
const char* _file = LOG4CPLUS_CALLER_FILE (),
|
||||
int _line = LOG4CPLUS_CALLER_LINE (),
|
||||
char const * _function = LOG4CPLUS_CALLER_FUNCTION ())
|
||||
: logger(std::move (l)), msg(std::move (_msg)), file(_file),
|
||||
function(_function), line(_line)
|
||||
{
|
||||
if(logger.isEnabledFor(TRACE_LOG_LEVEL))
|
||||
logger.forcedLog(TRACE_LOG_LEVEL, LOG4CPLUS_TEXT("ENTER: ") + msg,
|
||||
file, line, function);
|
||||
}
|
||||
|
||||
~TraceLogger()
|
||||
{
|
||||
if(logger.isEnabledFor(TRACE_LOG_LEVEL))
|
||||
logger.forcedLog(TRACE_LOG_LEVEL, LOG4CPLUS_TEXT("EXIT: ") + msg,
|
||||
file, line, function);
|
||||
}
|
||||
|
||||
private:
|
||||
TraceLogger (TraceLogger const &);
|
||||
TraceLogger & operator = (TraceLogger const &);
|
||||
|
||||
Logger logger;
|
||||
log4cplus::tstring msg;
|
||||
const char* file;
|
||||
const char* function;
|
||||
int line;
|
||||
};
|
||||
|
||||
|
||||
} // log4cplus
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_TRACELOGGER_H
|
|
@ -0,0 +1,154 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: tstring.h
|
||||
// Created: 4/2003
|
||||
// Author: Tad E. Smith
|
||||
//
|
||||
//
|
||||
// Copyright 2003-2017 Tad E. Smith
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_TSTRING_HEADER_
|
||||
#define LOG4CPLUS_TSTRING_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <type_traits>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <log4cplus/tchar.h>
|
||||
|
||||
namespace log4cplus
|
||||
{
|
||||
|
||||
using tstring = std::basic_string<tchar>;
|
||||
using tstring_view = std::basic_string_view<tchar>;
|
||||
|
||||
namespace helpers
|
||||
{
|
||||
|
||||
inline
|
||||
std::string
|
||||
tostring (char const * str)
|
||||
{
|
||||
return std::string (str);
|
||||
}
|
||||
|
||||
template <typename SV>
|
||||
inline
|
||||
std::enable_if_t<
|
||||
std::is_convertible_v<SV const &, std::string_view>
|
||||
&& std::is_convertible_v<SV const &, char const *>,
|
||||
std::string>
|
||||
tostring (SV const & sv)
|
||||
{
|
||||
return std::string (sv);
|
||||
}
|
||||
|
||||
inline
|
||||
std::string
|
||||
tostring (std::string const & str)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
|
||||
inline
|
||||
std::string const &
|
||||
tostring (std::string & str)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
|
||||
inline
|
||||
std::string
|
||||
tostring (std::string && str)
|
||||
{
|
||||
return std::move (str);
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
std::wstring
|
||||
towstring (wchar_t const * str)
|
||||
{
|
||||
return std::wstring (str);
|
||||
}
|
||||
|
||||
template <typename SV>
|
||||
inline
|
||||
std::enable_if_t<
|
||||
std::is_convertible_v<SV const &, std::wstring_view>
|
||||
&& std::is_convertible_v<SV const &, wchar_t const *>,
|
||||
std::wstring>
|
||||
towstring (SV const & sv)
|
||||
{
|
||||
return std::wstring (sv);
|
||||
}
|
||||
|
||||
inline
|
||||
std::wstring
|
||||
towstring (std::wstring const & str)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
|
||||
inline
|
||||
std::wstring const &
|
||||
towstring (std::wstring & str)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
|
||||
inline
|
||||
std::wstring
|
||||
towstring (std::wstring && str)
|
||||
{
|
||||
return std::move (str);
|
||||
}
|
||||
|
||||
|
||||
LOG4CPLUS_EXPORT std::string tostring(const std::wstring&);
|
||||
LOG4CPLUS_EXPORT std::string tostring(const std::wstring_view&);
|
||||
LOG4CPLUS_EXPORT std::string tostring(wchar_t const *);
|
||||
|
||||
LOG4CPLUS_EXPORT std::wstring towstring(const std::string&);
|
||||
LOG4CPLUS_EXPORT std::wstring towstring(const std::string_view&);
|
||||
LOG4CPLUS_EXPORT std::wstring towstring(char const *);
|
||||
|
||||
} // namespace helpers
|
||||
|
||||
#ifdef UNICODE
|
||||
|
||||
#define LOG4CPLUS_C_STR_TO_TSTRING(STRING) log4cplus::helpers::towstring(STRING)
|
||||
#define LOG4CPLUS_STRING_TO_TSTRING(STRING) log4cplus::helpers::towstring(STRING)
|
||||
#define LOG4CPLUS_TSTRING_TO_STRING(STRING) log4cplus::helpers::tostring(STRING)
|
||||
|
||||
#else // UNICODE
|
||||
|
||||
#define LOG4CPLUS_C_STR_TO_TSTRING(STRING) (std::string(STRING))
|
||||
#define LOG4CPLUS_STRING_TO_TSTRING(STRING) STRING
|
||||
#define LOG4CPLUS_TSTRING_TO_STRING(STRING) STRING
|
||||
|
||||
#endif // UNICODE
|
||||
|
||||
} // namespace log4cplus
|
||||
|
||||
|
||||
#endif // LOG4CPLUS_TSTRING_HEADER_
|
|
@ -0,0 +1,58 @@
|
|||
// -*- C++ -*-
|
||||
// Copyright (C) 2010-2017, Vaclav Haisman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
#if ! defined (LOG4CPLUS_VERSION_H)
|
||||
#define LOG4CPLUS_VERSION_H
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#define LOG4CPLUS_MAKE_VERSION(major, minor, point) \
|
||||
(major * 1000 * 1000u + minor * 1000u + point)
|
||||
|
||||
#define LOG4CPLUS_MAKE_VERSION_STR(major, minor, point) \
|
||||
#major "." #minor "." #point
|
||||
|
||||
//! This is log4cplus version number as unsigned integer. This must
|
||||
//! be kept on a single line. It is used by Autotool and CMake build
|
||||
//! systems to parse version number.
|
||||
#define LOG4CPLUS_VERSION LOG4CPLUS_MAKE_VERSION(3, 0, 0)
|
||||
|
||||
//! This is log4cplus version number as a string.
|
||||
#define LOG4CPLUS_VERSION_STR LOG4CPLUS_MAKE_VERSION_STR(3, 0, 0)
|
||||
|
||||
|
||||
namespace log4cplus
|
||||
{
|
||||
|
||||
extern LOG4CPLUS_EXPORT unsigned const version;
|
||||
extern LOG4CPLUS_EXPORT char const versionStr[];
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,93 @@
|
|||
// -*- C++ -*-
|
||||
// Copyright (C) 2009-2017, Vaclav Haisman. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modifica-
|
||||
// tion, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
|
||||
// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#ifndef LOG4CPLUS_WIN32CONSOLEAPPENDER_H
|
||||
#define LOG4CPLUS_WIN32CONSOLEAPPENDER_H
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && defined (LOG4CPLUS_HAVE_WIN32_CONSOLE)
|
||||
|
||||
#include <log4cplus/appender.h>
|
||||
|
||||
|
||||
namespace log4cplus
|
||||
{
|
||||
|
||||
/**
|
||||
* Prints events to Win32 console.
|
||||
*
|
||||
* <h3>Properties</h3>
|
||||
* <dl>
|
||||
* <dt><tt>AllocConsole</tt></dt>
|
||||
* <dd>This boolean property specifies whether or not this appender
|
||||
* will try to allocate new console using the
|
||||
* <code>AllocConsole()</code> Win32 function.</dd>
|
||||
*
|
||||
* <dt><tt>logToStdErr</tt></dt>
|
||||
* <dd>When it is set true, the output will be into
|
||||
* <code>STD_ERROR_HANDLE</code> instead of <code>STD_OUTPUT_HANDLE</code>.
|
||||
* </dd>
|
||||
*
|
||||
* <dt><tt>TextColor</tt></dt>
|
||||
* <dd>See MSDN documentation for
|
||||
* <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms682088(v=vs.85).aspx#_win32_character_attributes">
|
||||
* Character Attributes</a>.
|
||||
* </dl>
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT Win32ConsoleAppender
|
||||
: public Appender
|
||||
{
|
||||
public:
|
||||
explicit Win32ConsoleAppender (bool allocConsole = true,
|
||||
bool logToStdErr = false, unsigned int textColor = 0);
|
||||
Win32ConsoleAppender (helpers::Properties const & properties);
|
||||
virtual ~Win32ConsoleAppender ();
|
||||
|
||||
virtual void close ();
|
||||
|
||||
protected:
|
||||
virtual void append (spi::InternalLoggingEvent const &);
|
||||
|
||||
void write_handle (void *, tchar const *, std::size_t);
|
||||
void write_console (void *, tchar const *, std::size_t);
|
||||
|
||||
bool alloc_console;
|
||||
bool log_to_std_err;
|
||||
unsigned int text_color;
|
||||
|
||||
private:
|
||||
Win32ConsoleAppender (Win32ConsoleAppender const &);
|
||||
Win32ConsoleAppender & operator = (Win32ConsoleAppender const &);
|
||||
};
|
||||
|
||||
} // namespace log4cplus
|
||||
|
||||
#endif
|
||||
|
||||
#endif // LOG4CPLUS_WIN32CONSOLEAPPENDER_H
|
|
@ -0,0 +1,69 @@
|
|||
// -*- C++ -*-
|
||||
// Module: Log4CPLUS
|
||||
// File: win32debugappender.h
|
||||
// Created: 12/2003
|
||||
// Author: Eduardo Francos, Odalio SARL
|
||||
//
|
||||
//
|
||||
// Copyright 2003-2017 Odalio SARL
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef LOG4CPLUS_WIN32DEBUG_APPENDER_HEADER_
|
||||
#define LOG4CPLUS_WIN32DEBUG_APPENDER_HEADER_
|
||||
|
||||
#include <log4cplus/config.hxx>
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if defined (LOG4CPLUS_HAVE_OUTPUTDEBUGSTRING)
|
||||
|
||||
#include <log4cplus/appender.h>
|
||||
|
||||
|
||||
namespace log4cplus {
|
||||
|
||||
/**
|
||||
* Prints log events using OutputDebugString().
|
||||
*/
|
||||
class LOG4CPLUS_EXPORT Win32DebugAppender
|
||||
: public Appender
|
||||
{
|
||||
public:
|
||||
// Ctors
|
||||
Win32DebugAppender();
|
||||
Win32DebugAppender(const log4cplus::helpers::Properties& properties);
|
||||
|
||||
// Dtor
|
||||
virtual ~Win32DebugAppender();
|
||||
|
||||
// Methods
|
||||
virtual void close();
|
||||
|
||||
protected:
|
||||
virtual void append(const log4cplus::spi::InternalLoggingEvent& event);
|
||||
|
||||
private:
|
||||
// Disallow copying of instances of this class
|
||||
Win32DebugAppender(const Win32DebugAppender&);
|
||||
Win32DebugAppender& operator=(const Win32DebugAppender&);
|
||||
};
|
||||
|
||||
} // end namespace log4cplus
|
||||
|
||||
#endif // LOG4CPLUS_HAVE_OUTPUTDEBUGSTRING
|
||||
#endif // LOG4CPLUS_WIN32DEBUG_APPENDER_HEADER_
|
Binary file not shown.
Binary file not shown.
|
@ -141,12 +141,6 @@ void CBasicPage::DoDataExchange(CDataExchange* pDX)
|
|||
BOOL CBasicPage::OnInitDialog()
|
||||
{
|
||||
CTabPageSSL::OnInitDialog();
|
||||
#ifndef G200
|
||||
((CButton*)GetDlgItem(IDC_CKBSIZEDETECT))->ShowWindow(SW_HIDE);
|
||||
#endif // !G200
|
||||
|
||||
|
||||
|
||||
m_cmBoxColorMode = (CComboBox*)GetDlgItem(IDC_CMBCOLORTYPE);
|
||||
m_cmBoxSS = (CComboBox*)GetDlgItem(IDC_CMBSS);
|
||||
m_cmBoxDuplex = (CComboBox*)GetDlgItem(IDC_CMBDUPLEX);
|
||||
|
@ -270,23 +264,35 @@ void CBasicPage::updateCmbDuplex(BOOL insert)
|
|||
//int tmp_resindex = m_cmBoxResultion->GetCurSel();
|
||||
int tmp_resindex = m_Slider_Dpi.m_iPosition;
|
||||
int totalcount = m_cmBoxDuplex->GetCount();
|
||||
if (tmp_colorindex == 0 && tmp_paperindex >= 18 && tmp_resindex >= 300) {
|
||||
if (tmp_colorindex == 0 && tmp_paperindex > 19 && tmp_resindex >= 300) {
|
||||
if (m_cmBoxDuplex->GetCurSel() == 4)
|
||||
{
|
||||
m_cmBoxDuplex->SetCurSel(1);
|
||||
}
|
||||
m_cmBoxDuplex->DeleteString(4);
|
||||
m_cmBoxDuplex->SetCurSel(1);
|
||||
//m_cmBoxDuplex->SetCurSel(1);
|
||||
}
|
||||
else {
|
||||
if (totalcount != 5) {
|
||||
m_cmBoxDuplex->InsertString(4, TEXT("对折"));
|
||||
}
|
||||
}
|
||||
#ifdef G200
|
||||
if (tmp_paperindex == 16 || tmp_paperindex == 17){
|
||||
#ifndef G300
|
||||
if (tmp_paperindex == 19 || tmp_paperindex == 20 || tmp_paperindex == 21){
|
||||
(((CButton*)GetDlgItem(IDC_CKBSIZEDETECT)))->SetCheck(false);
|
||||
GetDlgItem(IDC_CKBSIZEDETECT)->EnableWindow(false);
|
||||
}
|
||||
else{
|
||||
GetDlgItem(IDC_CKBSIZEDETECT)->EnableWindow(true);
|
||||
}
|
||||
#else
|
||||
if (tmp_paperindex == 8) {
|
||||
(((CButton*)GetDlgItem(IDC_CKBSIZEDETECT)))->SetCheck(false);
|
||||
GetDlgItem(IDC_CKBSIZEDETECT)->EnableWindow(false);
|
||||
}
|
||||
else {
|
||||
GetDlgItem(IDC_CKBSIZEDETECT)->EnableWindow(true);
|
||||
}
|
||||
#endif // G200
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,14 @@ void CIndicatorDlg::DoDataExchange(CDataExchange* pDX)
|
|||
CDialogEx::DoDataExchange(pDX);
|
||||
}
|
||||
|
||||
BOOL CIndicatorDlg::OnInitDialog()
|
||||
{
|
||||
#ifdef LANXUM
|
||||
GetDlgItem(IDC_BTNSTOPSCAN)->ShowWindow(SW_HIDE);
|
||||
#endif // LANXUM
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CIndicatorDlg, CDialogEx)
|
||||
ON_BN_CLICKED(IDC_BTNSTOPSCAN, &CIndicatorDlg::OnBnClickedBtnstopscan)
|
||||
|
@ -36,6 +44,13 @@ END_MESSAGE_MAP()
|
|||
// CIndicatorDlg 消息处理程序
|
||||
|
||||
|
||||
void CIndicatorDlg::setindicatortext(int aquire, int updata)
|
||||
{
|
||||
wchar_t text[260] = { 0 };
|
||||
_stprintf(text, L"扫描中,已扫描%d份文件,已上传%d张图片。", aquire,updata);
|
||||
GetDlgItem(IDC_STATIC)->SetWindowTextW(text);
|
||||
}
|
||||
|
||||
void CIndicatorDlg::OnBnClickedBtnstopscan()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
|
|
|
@ -11,7 +11,7 @@ class CIndicatorDlg : public CDialogEx
|
|||
public:
|
||||
CIndicatorDlg(std::function<void()> stop = std::function<void()>(), CWnd* pParent = nullptr); // 标准构造函数
|
||||
virtual ~CIndicatorDlg();
|
||||
|
||||
void setindicatortext(int aquire, int updata);
|
||||
// 对话框数据
|
||||
#ifdef AFX_DESIGN_TIME
|
||||
enum { IDD = IDD_INDICATOR };
|
||||
|
@ -19,9 +19,9 @@ public:
|
|||
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
|
||||
|
||||
virtual BOOL OnInitDialog();
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
|
||||
afx_msg void OnBnClickedBtnstopscan();
|
||||
|
||||
std::function<void()> m_stop;
|
||||
|
|
|
@ -20,6 +20,7 @@ G400ScanConfig::G400ScanConfig(GScanCap& gcap)
|
|||
size = PaperSize.GetPaperSize(gcap.papertype, 200.0f, gcap.paperAlign);
|
||||
#endif// G300
|
||||
cfg.params.dstHeight = (int)((size.cy+200)/100);
|
||||
cfg.params.sizedetect = gcap.en_sizecheck;
|
||||
cfg.params.reversed1 = cfg.params.reversed2 = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,8 @@ public:
|
|||
unsigned int doubleFeeded : 1;
|
||||
unsigned int enableStable : 1;
|
||||
unsigned int enableLed : 1;
|
||||
unsigned int reversed1 : 6;
|
||||
unsigned int sizedetect : 1;
|
||||
unsigned int reversed1 : 5;
|
||||
unsigned int isCorrect : 1;
|
||||
unsigned int dstHeight : 8;
|
||||
unsigned int reversed2 : 6;
|
||||
|
|
|
@ -72,6 +72,10 @@ typedef enum tagUsbSupported {
|
|||
DOG_EAR=74,
|
||||
//幅面检测错误
|
||||
SIZE_ERROR=75,
|
||||
//取图超时
|
||||
AQUIRE_IMAGE_TIMEOUT=76,
|
||||
//获取图片与扫描张数不匹配
|
||||
LOSE_IMAGE=77,
|
||||
//USB 未连接
|
||||
USB_DISCONNECTED = 200,
|
||||
//用户点击停止
|
||||
|
@ -83,6 +87,24 @@ typedef enum tagUsbSupported {
|
|||
HAVE_PAPER
|
||||
} UsbSupported, * PUsbSupported;
|
||||
|
||||
static map<UsbSupported, string> msgs = {
|
||||
{UsbSupported::OPEN_COVER,"扫描仪开盖!请关闭扫描仪上盖!"},
|
||||
{UsbSupported::NO_FEED,"无纸!请放置纸张!"},
|
||||
{UsbSupported::FEED_IN_ERROR,"搓纸失败!请整理纸张!"},
|
||||
{UsbSupported::PAPER_JAM,"卡纸!"},
|
||||
{UsbSupported::DETECT_DOUBLE_FEED,"双张"},
|
||||
{UsbSupported::DETECT_STAPLE,"检测到订书针!"},
|
||||
{UsbSupported::PAPER_SKEW,"纸张歪斜!请整理纸张!"},
|
||||
{UsbSupported::COUNT_MODE,"计数模式,请退出计数模式!"},
|
||||
{UsbSupported::HARDWARE_ERROR,"硬件异常!请重启扫描仪!"},
|
||||
{UsbSupported::USB_DISCONNECTED,"USB连接异常!"},
|
||||
{UsbSupported::USER_STOP,"未找到扫描仪!请检查电源或者USB连接线是否接通!"},
|
||||
{UsbSupported::AUTO_FLAT_FINISHED,"设备已被其他程序占用,请关闭占用程序之后再重试!"},
|
||||
{UsbSupported::DOG_EAR,"检测到折角!"},
|
||||
{UsbSupported::SIZE_ERROR,"幅面检测异常!"},
|
||||
{UsbSupported::AQUIRE_IMAGE_TIMEOUT,"取图超时!"},
|
||||
{UsbSupported::LOSE_IMAGE,"上传图片与扫描张数不匹配!"}
|
||||
};
|
||||
|
||||
enum tagEventIndex
|
||||
{
|
||||
|
@ -98,9 +120,15 @@ typedef void(*deviceevent_callback)(int eventID, void* userdata);
|
|||
class IScanner
|
||||
{
|
||||
public:
|
||||
IScanner() { bFilterMsg = false; }
|
||||
IScanner() { bFilterMsg = false; aquire_image_count = updata_image_count = updata_image_count = roller_num = lose_image_num= 0; }
|
||||
virtual ~IScanner() { bFilterMsg = true; }
|
||||
void ResetMsgFiter() { bFilterMsg = true; }
|
||||
int get_aquire_image_count() { return aquire_image_count; };
|
||||
int get_updata_image_count() { return updata_image_count; };
|
||||
int get_lose_image_num() { return lose_image_num; };
|
||||
void set_lose_image_num(int value) { lose_image_num = value; };
|
||||
void set_aquire_image_count(int aquire, int updata) { aquire_image_count = aquire; updata_image_count = updata; if (setindicatortext) setindicatortext(aquire, updata); };
|
||||
void regist_indicatortext_callback(std::function<void(int, int)> indicatortext) { if (indicatortext) setindicatortext = indicatortext; };
|
||||
virtual void open(int vid, int pid) = 0;
|
||||
virtual void regist_deviceevent_callback(deviceevent_callback callback, void* usrdata = 0) = 0;
|
||||
virtual void DogEar_callback(std::function<void(int)> fun)=0;
|
||||
|
@ -110,6 +138,7 @@ public:
|
|||
virtual std::string GetSerialNum() = 0;
|
||||
virtual bool is_scan() = 0;
|
||||
virtual BOOL Get_Scanner_PaperOn() = 0;
|
||||
virtual int Get_Roller_num() = 0;
|
||||
virtual void config_params(GScanCap& params) = 0;
|
||||
virtual void Scanner_StartScan(UINT16 count) = 0;
|
||||
virtual void Stop_scan() = 0;
|
||||
|
@ -140,6 +169,11 @@ protected:
|
|||
std::string fwVersion;
|
||||
std::string SerialNum;
|
||||
std::string scannercode;
|
||||
std::function<void(int, int)> setindicatortext;
|
||||
int aquire_image_count;
|
||||
int updata_image_count;
|
||||
int roller_num;
|
||||
int pixType;
|
||||
int lose_image_num;
|
||||
bool bFilterMsg;
|
||||
};
|
|
@ -134,7 +134,7 @@ typedef enum tagUsbKeyWords : UINT32
|
|||
//ÉèÖÃɨÃèÒDZàÂë
|
||||
GET_CODE_G400 = 0x59,
|
||||
//¶ÁȡɨÃèÒDZàÂë
|
||||
SET_CODE_G400 = 0x60,
|
||||
SET_CODE_G400 = 0x5A,
|
||||
//ÉèÖÃɨÃèÒDZàÂë
|
||||
SET_CODE_G200=0x63,
|
||||
//¶ÁȡɨÃèÒDZàÂë
|
||||
|
@ -324,6 +324,17 @@ BOOL GScanO200::Get_Scanner_PaperOn()
|
|||
return usbcb.u32_Data != 0;
|
||||
}
|
||||
|
||||
int GScanO200::Get_Roller_num()
|
||||
{
|
||||
if (!(m_usb.get() && m_usb->is_open()))
|
||||
return false;
|
||||
USBCB usbcb = { GET_ROLLER_NUM ,0,0 };
|
||||
std::lock_guard<std::mutex> lck(m_imgLocker);
|
||||
m_usb->write_bulk(&usbcb, sizeof(usbcb));
|
||||
m_usb->read_bulk(&usbcb, sizeof(usbcb));
|
||||
return usbcb.u32_Data;
|
||||
}
|
||||
|
||||
void GScanO200::config_params(GScanCap& params)
|
||||
{
|
||||
if (m_usb.get() && m_usb->is_connected()) {
|
||||
|
@ -331,19 +342,20 @@ void GScanO200::config_params(GScanCap& params)
|
|||
gcap = params;
|
||||
UINT32 cfgdata = cfg.GetData();
|
||||
USBCB usbcb = { CONFIGURED_DATA,cfgdata,0 };
|
||||
FileTools::write_log("¿ªÊ¼Ï·¢Ó²¼þ²ÎÊý ===>\n\tUSB config_params:" + to_string(cfgdata) + "\n\tpaper:" + to_string(cfgdata & 0x1f)
|
||||
+ "\n\tcolor:" + to_string((cfgdata >> 5) & 0x1)
|
||||
+ "\n\tdpi:" + to_string((cfgdata >> 6) & 0x3)
|
||||
+ "\n\tdouble_feed_enbale:" + to_string((cfgdata >> 8) & 0x1)
|
||||
+ "\n\tstable_enbale:" + to_string((cfgdata >> 9) & 0x1)
|
||||
+ "\n\tscrew_detect_enable:" + to_string((cfgdata >> 10) & 0x1)
|
||||
+ "\n\tscrew_detect_level:" + to_string((cfgdata >> 11) & 0x7)
|
||||
+ "\n\tunused_one:" + to_string((cfgdata >> 14) & 0x3F)
|
||||
+ "\n\tpc_correct:" + to_string((cfgdata >> 20) & 0x1)
|
||||
+ "\n\tenable_sizecheck:" + to_string((cfgdata >> 21) & 0x1)
|
||||
+ "\n\tenabledsp_cache:" + to_string((cfgdata >> 22) & 0x1)
|
||||
+ "\n\tlowpowermode:" + to_string((cfgdata >> 23) & 0x7)
|
||||
+ "\n\tunused_two:" + to_string((cfgdata >> 26) & 0x3f));
|
||||
//FileTools::write_log("开始下发硬件参数 ===>\n\tUSB config_params:" + to_string(cfgdata) + "\n\tpaper:" + to_string(cfgdata & 0x1f)
|
||||
// + "\n\tcolor:" + to_string((cfgdata >> 5) & 0x1)
|
||||
// + "\n\tdpi:" + to_string((cfgdata >> 6) & 0x3)
|
||||
// + "\n\tdouble_feed_enbale:" + to_string((cfgdata >> 8) & 0x1)
|
||||
// + "\n\tstable_enbale:" + to_string((cfgdata >> 9) & 0x1)
|
||||
// + "\n\tscrew_detect_enable:" + to_string((cfgdata >> 10) & 0x1)
|
||||
// + "\n\tscrew_detect_level:" + to_string((cfgdata >> 11) & 0x7)
|
||||
// + "\n\tunused_one:" + to_string((cfgdata >> 14) & 0x3F)
|
||||
// + "\n\tpc_correct:" + to_string((cfgdata >> 20) & 0x1)
|
||||
// + "\n\tenable_sizecheck:" + to_string((cfgdata >> 21) & 0x1)
|
||||
// + "\n\tenabledsp_cache:" + to_string((cfgdata >> 22) & 0x1)
|
||||
// + "\n\tlowpowermode:" + to_string((cfgdata >> 23) & 0x7)
|
||||
// + "\n\tunused_two:" + to_string((cfgdata >> 26) & 0x3f));
|
||||
FileTools::writelog(log_INFO, "config hardware param");
|
||||
m_usb->write_bulk(&usbcb, sizeof(USBCB));
|
||||
this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||
m_pImages->setparam(params);
|
||||
|
@ -352,6 +364,7 @@ void GScanO200::config_params(GScanCap& params)
|
|||
|
||||
void GScanO200::Scanner_StartScan(UINT16 count)
|
||||
{
|
||||
roller_num = Get_Roller_num();
|
||||
std::lock_guard<std::mutex> lck(m_imgLocker);
|
||||
if (m_threadUsb && m_threadUsb->joinable()) {
|
||||
devState = DEV_STOP;
|
||||
|
@ -523,6 +536,7 @@ void GScanO200::usbhotplug_callback(bool isconnect, void* userdata)
|
|||
|
||||
void GScanO200::usbhotplug(bool isleft)
|
||||
{
|
||||
FileTools::writelog(log_ERROR, "enable usb callback ");
|
||||
if (isleft) {
|
||||
devState = DEV_WRONG;
|
||||
Error_Code = USB_DISCONNECTED;
|
||||
|
@ -567,10 +581,11 @@ void GScanO200::usbmain()
|
|||
}
|
||||
|
||||
|
||||
if (sw.elapsed_ms() > 13000)
|
||||
if (sw.elapsed_ms() > 30000)
|
||||
{
|
||||
m_pImages->setscanflags(false);
|
||||
devState = haveError ? DevState::DEV_WRONG : DevState::DEV_STOP;
|
||||
FileTools::writelog(log_ERROR, "USBmain aquire image timeout");
|
||||
return;
|
||||
}
|
||||
if(gcap.resolution_dst>200.0f)
|
||||
|
@ -598,18 +613,26 @@ void GScanO200::usbmain()
|
|||
imgData = Get_Img_Data(totalNum);
|
||||
if (!imgData->size()) {
|
||||
Stop_scan();
|
||||
writelog("imgData->size() error");
|
||||
FileTools::writelog(log_ERROR,"imgData->size() error send stop scan");
|
||||
break;
|
||||
}
|
||||
if(!m_pImages->get_isDogEar())
|
||||
m_pImages->pushMat(std::shared_ptr<IDecode>(new G200Decode(imgData)));
|
||||
m_usb->set_timeout(200);
|
||||
Pop_Image();
|
||||
set_aquire_image_count(get_aquire_image_count() + 1,get_updata_image_count());
|
||||
FileTools::writelog(log_INFO, "从扫描仪接收"+to_string(get_aquire_image_count())+"份文件。");
|
||||
sw.reset();
|
||||
break;
|
||||
}
|
||||
case STOP_SCAN:
|
||||
m_pImages->setscanflags(false);
|
||||
if (get_aquire_image_count() != (Get_Roller_num() - roller_num))
|
||||
{
|
||||
Set_ErrorCode(LOSE_IMAGE);
|
||||
set_lose_image_num(std::abs((Get_Roller_num() - roller_num) - get_aquire_image_count()));
|
||||
haveError = true;
|
||||
}
|
||||
devState = haveError ? DevState::DEV_WRONG : DevState::DEV_STOP;
|
||||
//m_pImages->setscanflags(false);
|
||||
//devState = DEV_STOP;
|
||||
|
@ -628,6 +651,8 @@ void GScanO200::usbmain()
|
|||
Set_ErrorCode(usbcb.u32_Data);
|
||||
m_pImages->setscanflags(false);
|
||||
devState = DEV_WRONG;
|
||||
if (get_aquire_image_count() != (Get_Roller_num() - roller_num))
|
||||
set_lose_image_num(std::abs((Get_Roller_num() - roller_num) - get_aquire_image_count()));
|
||||
if (huagods)
|
||||
dev_callback(usbcb.u32_Data, huagods);
|
||||
break;
|
||||
|
@ -641,7 +666,8 @@ void GScanO200::usbmain()
|
|||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
writelog(e.what());
|
||||
//writelog(e.what());
|
||||
FileTools::writelog(log_ERROR, e.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -664,36 +690,43 @@ USBCB GScanO200::Get_Scanner_Status()
|
|||
|
||||
std::shared_ptr<std::vector<char>> GScanO200::Get_Img_Data(int bufferSize)
|
||||
{
|
||||
if (!(m_usb.get() && m_usb->is_connected()))
|
||||
return std::shared_ptr<std::vector<char>>(new std::vector<char>());
|
||||
|
||||
std::shared_ptr<std::vector<char>> imData(new std::vector<char>(bufferSize));
|
||||
StopWatch sw;
|
||||
int readed = 0;
|
||||
USBCB usbcb = { GET_IMAGE,0,bufferSize };
|
||||
m_usb->write_bulk(&usbcb, sizeof(usbcb));
|
||||
int totalength = bufferSize;
|
||||
int startindex = 0;
|
||||
while (totalength > 0)
|
||||
try
|
||||
{
|
||||
int dstlength = 1024 * 1024;
|
||||
if (totalength <= dstlength)
|
||||
if (!(m_usb.get() && m_usb->is_connected()))
|
||||
return std::shared_ptr<std::vector<char>>(new std::vector<char>());
|
||||
|
||||
std::shared_ptr<std::vector<char>> imData(new std::vector<char>(bufferSize));
|
||||
StopWatch sw;
|
||||
int readed = 0;
|
||||
USBCB usbcb = { GET_IMAGE,0,bufferSize };
|
||||
m_usb->write_bulk(&usbcb, sizeof(usbcb));
|
||||
int totalength = bufferSize;
|
||||
int startindex = 0;
|
||||
while (totalength > 0)
|
||||
{
|
||||
dstlength = totalength;
|
||||
totalength = 0;
|
||||
int dstlength = 1024 * 1024;
|
||||
if (totalength <= dstlength)
|
||||
{
|
||||
dstlength = totalength;
|
||||
totalength = 0;
|
||||
}
|
||||
else
|
||||
totalength -= dstlength;
|
||||
|
||||
int tt = m_usb->read_bulk(imData->data() + startindex, dstlength);
|
||||
startindex += dstlength;
|
||||
}
|
||||
else
|
||||
totalength -= dstlength;
|
||||
|
||||
int tt = m_usb->read_bulk(imData->data() + startindex, dstlength);
|
||||
startindex += dstlength;
|
||||
if (sw.elapsed_ms() > 5000)
|
||||
{
|
||||
FileTools::writelog(log_ERROR,"Usb read data timeout\n");
|
||||
}
|
||||
return imData;
|
||||
}
|
||||
|
||||
if (sw.elapsed_ms() > 5000)
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
writelog("Usb read data timeout\n");
|
||||
FileTools::writelog(log_ERROR, e.what());
|
||||
}
|
||||
return imData;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -17,6 +17,7 @@ public:
|
|||
virtual std::string GetSerialNum() override;
|
||||
virtual bool is_scan() override;
|
||||
virtual BOOL Get_Scanner_PaperOn() override;
|
||||
virtual int Get_Roller_num() override;
|
||||
virtual void config_params(GScanCap& params) override;
|
||||
virtual void Scanner_StartScan(UINT16 count) override;
|
||||
virtual void Stop_scan() override;
|
||||
|
|
|
@ -12,135 +12,135 @@
|
|||
//u32_CMD
|
||||
typedef enum tagUsbKeyWords : UINT32
|
||||
{
|
||||
//无命令
|
||||
//无命令
|
||||
NO_COMMAND = 0,
|
||||
//获取dsp 状态
|
||||
//获取dsp 状态
|
||||
GET_DSP_STATUS = 1,
|
||||
//取图
|
||||
//取图
|
||||
GET_IMAGE = 2,
|
||||
//销毁DSP中驻存的图
|
||||
//销毁DSP中驻存的图
|
||||
POP_IMAGE = 3,
|
||||
//开始扫描命令
|
||||
//开始扫描命令
|
||||
START_COMMAND = 4,
|
||||
//停止扫描命令
|
||||
//停止扫描命令
|
||||
STOP = 5,
|
||||
//获取扫描仪扫描模式
|
||||
//获取扫描仪扫描模式
|
||||
GET_SCAN_MODE = 6,
|
||||
//获取固件版本号
|
||||
//获取固件版本号
|
||||
GET_FW_VERSION = 7,
|
||||
//返回PC端的状态
|
||||
//返回PC端的状态
|
||||
SEND_STATUS_PC = 8,
|
||||
//下发扫描配置参数
|
||||
//下发扫描配置参数
|
||||
CONFIGURED_DATA = 9,
|
||||
//下发固件信息
|
||||
//下发固件信息
|
||||
SEND_FW = 10,
|
||||
//获取扫描参数
|
||||
//获取扫描参数
|
||||
GET_CONFIG_DATA = 11,
|
||||
//获取扫描总张数
|
||||
//获取扫描总张数
|
||||
GET_SCANN_NUM = 12,
|
||||
//获取有无纸的状态
|
||||
//获取有无纸的状态
|
||||
GET_PAPERFEEDER_STATUS = 13,
|
||||
//DSP初始化
|
||||
//DSP初始化
|
||||
INIT_HARDWARE_SYS = 14,
|
||||
//获取有无纸的状态
|
||||
//获取有无纸的状态
|
||||
GET_PAPER_STATUS = 0x0d,
|
||||
//下发元器件配置参数(灰度,LED R曝光时间)
|
||||
//下发元器件配置参数(灰度,LED R曝光时间)
|
||||
SEND_COMPONENTS_GR = 15,
|
||||
//下发元器件配置参数(LED G/B曝光时间)
|
||||
//下发元器件配置参数(LED G/B曝光时间)
|
||||
SEND_COMPONENTS_GB = 16,
|
||||
//下发扫描模式
|
||||
//下发扫描模式
|
||||
SEND_SCAN_MODE = 17,
|
||||
//开始进行平场矫正
|
||||
//开始进行平场矫正
|
||||
START_FLAT = 18,
|
||||
//停止平场矫正
|
||||
//停止平场矫正
|
||||
STOP_FLAT = 19,
|
||||
//下发200dpi彩色平场矫正参数
|
||||
//下发200dpi彩色平场矫正参数
|
||||
SEND_200_COLOR_FLAT_DATA = 20,
|
||||
//下发300dpi彩色平场矫正参数
|
||||
//下发300dpi彩色平场矫正参数
|
||||
SEND_300_COLOR_FLAT_DATA = 21,
|
||||
//获取200dpi彩色平场矫正参数
|
||||
//获取200dpi彩色平场矫正参数
|
||||
GET_200_COLOR_FLAT_DATA = 22,
|
||||
//获取300dpi彩色平场矫正参数
|
||||
//获取300dpi彩色平场矫正参数
|
||||
GET_300_COLOR_FLAT_DATA = 23,
|
||||
//下发200dpi灰度平场校正参数
|
||||
//下发200dpi灰度平场校正参数
|
||||
SEND_200_GRAY_FLAT_DATA = 24,
|
||||
//下发300dpi灰度平场校正参数
|
||||
//下发300dpi灰度平场校正参数
|
||||
SEND_300_GRAY_FLAT_DATA = 25,
|
||||
//获取200DPI灰度平场校正参数
|
||||
//获取200DPI灰度平场校正参数
|
||||
GET_200_GRAY_FLAT_DATA = 26,
|
||||
//获取300DPI灰度平场校正参数
|
||||
//获取300DPI灰度平场校正参数
|
||||
GET_300_GRAY_FLAT_DATA = 27,
|
||||
//下发序列号命令
|
||||
//下发序列号命令
|
||||
SEND_SERIAL = 28,
|
||||
//获取序列号命令
|
||||
//获取序列号命令
|
||||
GET_SERIAL = 29,
|
||||
//获取滚轴数
|
||||
//获取滚轴数
|
||||
GET_ROLLER_NUM = 0x1e,
|
||||
//清零滚轴数
|
||||
//清零滚轴数
|
||||
CLR_ROLLER_NUM = 0x1f,
|
||||
//清除扫描总张数
|
||||
//清除扫描总张数
|
||||
CLR_SCAN_NUM = 0x20,
|
||||
//准备更新固件
|
||||
//准备更新固件
|
||||
PRE_UPGRADE = 0X21,
|
||||
//开始更新固件
|
||||
//开始更新固件
|
||||
START_UPGRADE = 0x22,
|
||||
//彩色的AD参数
|
||||
//彩色的AD参数
|
||||
RGB_ADI_PARA = 0x23,
|
||||
//灰度的AD参数
|
||||
//灰度的AD参数
|
||||
ADI_PARA = 0x24,
|
||||
//获取CIS参数(曝光时间,ad参数)
|
||||
//获取CIS参数(曝光时间,ad参数)
|
||||
GET_CIS_PARA = 0x25,
|
||||
//扫描张数
|
||||
//扫描张数
|
||||
START_COMMAND_COUNT = 0x26,
|
||||
//下发休眠时间
|
||||
//下发休眠时间
|
||||
SET_SLEEP_TIME = 0x27,
|
||||
//获取休眠时间
|
||||
//获取休眠时间
|
||||
GET_SLEEP_TIME = 0x28,
|
||||
//清除缓存
|
||||
//清除缓存
|
||||
CLR_CACHE = 0x29,
|
||||
//下发速度模式
|
||||
//下发速度模式
|
||||
SET_SPEED_MODE = 0x2a,
|
||||
//获取扫描速度模式
|
||||
//获取扫描速度模式
|
||||
GET_SPEED_MODE = 0X2b,
|
||||
//设置固件版本一共8个字节
|
||||
//设置固件版本一共8个字节
|
||||
SET_FW_VERSION = 0X2c,
|
||||
//获取DSP版本
|
||||
//获取DSP版本
|
||||
GET_DSP_VERSION = 0X2d,
|
||||
//采集板FPGA固件版本
|
||||
//采集板FPGA固件版本
|
||||
GET_SCANFPGA_VERSION = 0x2e,
|
||||
//电机板FPGA固件版本
|
||||
//电机板FPGA固件版本
|
||||
GET_MOTORFPGA_VERSION = 0X2f,
|
||||
//设置制造商信息
|
||||
//设置制造商信息
|
||||
SET_USB_INFOR_MANUFACTURE = 0X30,
|
||||
//获取制造商信息
|
||||
//获取制造商信息
|
||||
GET_USB_INFOR_MANUFACTURE = 0X31,
|
||||
//设置产品型号信息
|
||||
//设置产品型号信息
|
||||
SET_USB_INFOR_MODEL_NAME = 0X32,
|
||||
//获取产品型号信息
|
||||
//获取产品型号信息
|
||||
GET_USB_INFOR_MODEL_NAME = 0X33,
|
||||
//设置USB PID / VID信息
|
||||
//设置USB PID / VID信息
|
||||
SET_USB_INFOR_VIDPID = 0X34,
|
||||
GET_USB_INFOR_VIDPID = 0X35,
|
||||
//设置卡纸急停检测灵敏度
|
||||
//设置卡纸急停检测灵敏度
|
||||
SET_JAM_DETECT_SENSITIVE = 0X36,
|
||||
//获取卡纸急停检测灵敏度
|
||||
//获取卡纸急停检测灵敏度
|
||||
GET_JAM_DETECT_SENSITIVE = 0X37,
|
||||
//设置横向畸变系数
|
||||
//设置横向畸变系数
|
||||
SET_JUST_COF_H = 0x38,
|
||||
//读取横向畸变系数
|
||||
//读取横向畸变系数
|
||||
GET_JUST_COF_H = 0x39,
|
||||
CLEAR_HWERROR = 0x40,//G400 清除硬件异常
|
||||
//设置纵向畸变系数
|
||||
CLEAR_HWERROR = 0x40,//G400 清除硬件异常
|
||||
//设置纵向畸变系数
|
||||
SET_JUST_COF_V = 0x41,
|
||||
//读取纵向畸变系数
|
||||
//读取纵向畸变系数
|
||||
GET_JUST_COF_V=0x42,
|
||||
//设置扫描仪编码
|
||||
//设置扫描仪编码
|
||||
GET_CODE_G400 = 0x59,
|
||||
//读取扫描仪编码
|
||||
//读取扫描仪编码
|
||||
SET_CODE_G400 = 0x60,
|
||||
//设置扫描仪编码
|
||||
//设置扫描仪编码
|
||||
SET_CODE_G200 = 0x63,
|
||||
//读取扫描仪编码
|
||||
//读取扫描仪编码
|
||||
GET_CODE_G200 = 0x64,
|
||||
|
||||
} UsbKeyWords, * PUsbKeyWords;
|
||||
|
@ -228,7 +228,7 @@ int GScanO400::aquire_bmpdata(std::vector<unsigned char>& bmpdata)
|
|||
m_threadUsb.reset();
|
||||
//writelog("aquire_bmpdata m_threadUsb.reset();");
|
||||
}
|
||||
Stop_scan();//停止扫描
|
||||
Stop_scan();//停止扫描
|
||||
ResetScanner();
|
||||
return HARDWARE_ERROR;
|
||||
}
|
||||
|
@ -308,12 +308,17 @@ bool GScanO400::is_scan()
|
|||
BOOL GScanO400::Get_Scanner_PaperOn()
|
||||
{
|
||||
if (!(m_usb.get() && m_usb->is_open()))
|
||||
return false;
|
||||
USBCB usbcb = { GET_PAPER_STATUS ,0,0 };
|
||||
{
|
||||
Set_ErrorCode(USB_DISCONNECTED);
|
||||
return true;
|
||||
}
|
||||
//return false;
|
||||
USBCB usbcb = { GET_PAPER_STATUS ,2,0 };
|
||||
std::lock_guard<std::mutex> lck(m_imgLocker);
|
||||
m_usb->write_bulk(&usbcb, sizeof(usbcb));
|
||||
if (m_usb.get() && m_usb->is_connected()) {
|
||||
if (0 == m_usb->read_bulk(&usbcb, sizeof(usbcb)))
|
||||
m_usb->read_bulk(&usbcb, sizeof(usbcb));
|
||||
if (usbcb.u32_Data == 2)
|
||||
{
|
||||
Set_ErrorCode(USB_DISCONNECTED);
|
||||
return true;
|
||||
|
@ -326,6 +331,17 @@ BOOL GScanO400::Get_Scanner_PaperOn()
|
|||
return usbcb.u32_Data != 0;
|
||||
}
|
||||
|
||||
int GScanO400::Get_Roller_num()
|
||||
{
|
||||
if (!(m_usb.get() && m_usb->is_open()))
|
||||
return false;
|
||||
USBCB usbcb = { GET_ROLLER_NUM ,0,0 };
|
||||
std::lock_guard<std::mutex> lck(m_imgLocker);
|
||||
m_usb->write_bulk(&usbcb, sizeof(usbcb));
|
||||
m_usb->read_bulk(&usbcb, sizeof(usbcb));
|
||||
return usbcb.u32_Data;
|
||||
}
|
||||
|
||||
void GScanO400::config_params(GScanCap& params)
|
||||
{
|
||||
if (m_usb.get() && m_usb->is_connected()) {
|
||||
|
@ -333,16 +349,17 @@ void GScanO400::config_params(GScanCap& params)
|
|||
gcap = params;
|
||||
UINT32 cfgdata = cfg.GetData();
|
||||
USBCB usbcb = { CONFIGURED_DATA,cfgdata,0 };
|
||||
FileTools::write_log("开始下发硬件参数 ===> \n\tUSB config_params:"+to_string(cfgdata)+"\n\tpaper:"+to_string(cfgdata&0x1f)
|
||||
+ "\n\tcolor:" + to_string((cfgdata>>5) & 0x1)
|
||||
+ "\n\tdpi:" + to_string((cfgdata>>6) & 0x3)
|
||||
+ "\n\tdouble_feed_enbale:" + to_string((cfgdata>>8) & 0x1)
|
||||
+ "\n\tstable_enbale:" + to_string((cfgdata>>9) & 0x1)
|
||||
+ "\n\tenableLed:" + to_string((cfgdata>>10) & 0x1)
|
||||
+ "\n\treversed1:" + to_string((cfgdata>>11) & 0x3F)
|
||||
+ "\n\tisCorrect:" + to_string((cfgdata>>17) & 0x1)
|
||||
+ "\n\tdstHeight:" + to_string((cfgdata>>18) & 0xFF)
|
||||
+ "\n\treversed2:" + to_string((cfgdata>>26) & 0x3F));
|
||||
//FileTools::write_log("开始下发硬件参数 ===> \n\tUSB config_params:"+to_string(cfgdata)+"\n\tpaper:"+to_string(cfgdata&0x1f)
|
||||
// + "\n\tcolor:" + to_string((cfgdata>>5) & 0x1)
|
||||
// + "\n\tdpi:" + to_string((cfgdata>>6) & 0x3)
|
||||
// + "\n\tdouble_feed_enbale:" + to_string((cfgdata>>8) & 0x1)
|
||||
// + "\n\tstable_enbale:" + to_string((cfgdata>>9) & 0x1)
|
||||
// + "\n\tenableLed:" + to_string((cfgdata>>10) & 0x1)
|
||||
// + "\n\treversed1:" + to_string((cfgdata>>11) & 0x3F)
|
||||
// + "\n\tisCorrect:" + to_string((cfgdata>>17) & 0x1)
|
||||
// + "\n\tdstHeight:" + to_string((cfgdata>>18) & 0xFF)
|
||||
// + "\n\treversed2:" + to_string((cfgdata>>26) & 0x3F));
|
||||
FileTools::writelog(log_INFO, "config hardware param");
|
||||
m_usb->write_bulk(&usbcb, sizeof(USBCB));
|
||||
this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||
m_pImages->setparam(params);
|
||||
|
@ -351,6 +368,7 @@ void GScanO400::config_params(GScanCap& params)
|
|||
|
||||
void GScanO400::Scanner_StartScan(UINT16 count)
|
||||
{
|
||||
roller_num= Get_Roller_num();
|
||||
std::lock_guard<std::mutex> lck(m_imgLocker);
|
||||
if (m_threadUsb && m_threadUsb->joinable()) {
|
||||
devState = DEV_STOP;
|
||||
|
@ -517,6 +535,7 @@ void GScanO400::usbhotplug_callback(bool isconnect, void* userdata)
|
|||
|
||||
void GScanO400::usbhotplug(bool isleft)
|
||||
{
|
||||
FileTools::writelog(log_ERROR, "enable usb callback ");
|
||||
if (isleft) {
|
||||
devState = DEV_WRONG;
|
||||
Error_Code = USB_DISCONNECTED;
|
||||
|
@ -560,10 +579,12 @@ void GScanO400::usbmain()
|
|||
}
|
||||
|
||||
|
||||
if (sw.elapsed_ms() > 13000)
|
||||
if (sw.elapsed_ms() > 30000)
|
||||
{
|
||||
m_pImages->setscanflags(false);
|
||||
Set_ErrorCode(AQUIRE_IMAGE_TIMEOUT);
|
||||
devState = haveError ? DevState::DEV_WRONG : DevState::DEV_STOP;
|
||||
FileTools::writelog(log_ERROR, "USBmain aquire image timeout");
|
||||
return;
|
||||
}
|
||||
if(gcap.resolution_dst>200.0f)
|
||||
|
@ -590,19 +611,28 @@ void GScanO400::usbmain()
|
|||
imgData = Get_Img_Data(totalNum);
|
||||
if (!imgData->size()) {
|
||||
Stop_scan();
|
||||
writelog("imgData->size() error");
|
||||
FileTools::writelog(log_ERROR,"imgData->size() error");
|
||||
break;
|
||||
}
|
||||
if(!m_pImages->get_isDogEar())
|
||||
m_pImages->pushMat(std::shared_ptr<IDecode>(new G400Decode(imgData)));
|
||||
m_usb->set_timeout(200);
|
||||
set_aquire_image_count(get_aquire_image_count() + 1,get_updata_image_count());
|
||||
FileTools::writelog(log_INFO, "从扫描仪接收" + to_string(get_aquire_image_count()) + "份文件。");
|
||||
Pop_Image();
|
||||
sw.reset();
|
||||
break;
|
||||
}
|
||||
case STOP_SCAN:
|
||||
m_pImages->setscanflags(false);
|
||||
if (get_aquire_image_count() != (Get_Roller_num() - roller_num))
|
||||
{
|
||||
Set_ErrorCode(LOSE_IMAGE);
|
||||
set_lose_image_num(std::abs((Get_Roller_num() - roller_num) - get_aquire_image_count()));
|
||||
haveError = true;
|
||||
}
|
||||
devState = haveError ? DevState::DEV_WRONG : DevState::DEV_STOP;
|
||||
|
||||
//m_pImages->setscanflags(false);
|
||||
//devState = DEV_STOP;
|
||||
break;
|
||||
|
@ -620,7 +650,11 @@ void GScanO400::usbmain()
|
|||
if (!haveError)
|
||||
{
|
||||
haveError = true;
|
||||
devState = DEV_WRONG;
|
||||
m_pImages->setscanflags(false);
|
||||
Set_ErrorCode(usbcb.u32_Data);
|
||||
if (get_aquire_image_count() != (Get_Roller_num() - roller_num))
|
||||
set_lose_image_num(std::abs((Get_Roller_num() - roller_num) - get_aquire_image_count()));
|
||||
if (huagods)
|
||||
dev_callback(usbcb.u32_Data, huagods);
|
||||
}
|
||||
|
@ -635,7 +669,8 @@ void GScanO400::usbmain()
|
|||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
writelog(e.what());
|
||||
//writelog(e.what());
|
||||
FileTools::writelog(log_ERROR,e.what());
|
||||
}
|
||||
|
||||
////FileTools::write_log("D:\\1.txt", "thread usb exit");
|
||||
|
@ -652,7 +687,6 @@ USBCB GScanO400::Get_Scanner_Status()
|
|||
USBCB usbcb = { GET_DSP_STATUS ,0,0 };
|
||||
if (m_usb.get() && m_usb->is_connected())
|
||||
m_usb->write_bulk(&usbcb, sizeof(usbcb));
|
||||
|
||||
if (m_usb.get() && m_usb->is_connected())
|
||||
m_usb->read_bulk(&usbcb, sizeof(usbcb));
|
||||
|
||||
|
@ -661,36 +695,43 @@ USBCB GScanO400::Get_Scanner_Status()
|
|||
|
||||
std::shared_ptr<std::vector<char>> GScanO400::Get_Img_Data(int bufferSize)
|
||||
{
|
||||
if (!(m_usb.get() && m_usb->is_connected()))
|
||||
return std::shared_ptr<std::vector<char>>(new std::vector<char>());
|
||||
|
||||
std::shared_ptr<std::vector<char>> imData(new std::vector<char>(bufferSize));
|
||||
StopWatch sw;
|
||||
int readed = 0;
|
||||
USBCB usbcb = { GET_IMAGE,0,bufferSize };
|
||||
m_usb->write_bulk(&usbcb, sizeof(usbcb));
|
||||
int totalength = bufferSize;
|
||||
int startindex = 0;
|
||||
while (totalength > 0)
|
||||
try
|
||||
{
|
||||
int dstlength = 1024 * 1024;
|
||||
if (totalength <= dstlength)
|
||||
if (!(m_usb.get() && m_usb->is_connected()))
|
||||
return std::shared_ptr<std::vector<char>>(new std::vector<char>());
|
||||
|
||||
std::shared_ptr<std::vector<char>> imData(new std::vector<char>(bufferSize));
|
||||
StopWatch sw;
|
||||
int readed = 0;
|
||||
USBCB usbcb = { GET_IMAGE,0,bufferSize };
|
||||
m_usb->write_bulk(&usbcb, sizeof(usbcb));
|
||||
int totalength = bufferSize;
|
||||
int startindex = 0;
|
||||
while (totalength > 0)
|
||||
{
|
||||
dstlength = totalength;
|
||||
totalength = 0;
|
||||
int dstlength = 1024 * 1024;
|
||||
if (totalength <= dstlength)
|
||||
{
|
||||
dstlength = totalength;
|
||||
totalength = 0;
|
||||
}
|
||||
else
|
||||
totalength -= dstlength;
|
||||
|
||||
int tt = m_usb->read_bulk(imData->data() + startindex, dstlength);
|
||||
startindex += dstlength;
|
||||
}
|
||||
else
|
||||
totalength -= dstlength;
|
||||
|
||||
int tt = m_usb->read_bulk(imData->data() + startindex, dstlength);
|
||||
startindex += dstlength;
|
||||
if (sw.elapsed_ms() > 5000)
|
||||
{
|
||||
FileTools::writelog(log_ERROR,"Usb read data timeout\n");
|
||||
}
|
||||
return imData;
|
||||
}
|
||||
|
||||
if (sw.elapsed_ms() > 5000)
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
writelog("Usb read data timeout\n");
|
||||
FileTools::writelog(log_ERROR, e.what());
|
||||
}
|
||||
return imData;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -17,6 +17,7 @@ public:
|
|||
virtual std::string GetSerialNum() override;
|
||||
virtual bool is_scan() override;
|
||||
virtual BOOL Get_Scanner_PaperOn() override;
|
||||
virtual int Get_Roller_num() override;
|
||||
virtual void config_params(GScanCap& params) override;
|
||||
virtual void Scanner_StartScan(UINT16 count) override;
|
||||
virtual void Stop_scan() override;
|
||||
|
|
|
@ -81,13 +81,13 @@ int ImageMatQueue::orginimgcount()
|
|||
|
||||
void ImageMatQueue::updatefixratio(float& hratio, float& vratio)
|
||||
{
|
||||
if (hratio > 0.80f && hratio < 1.2f && vratio >0.80f && vratio < 1.2f) {
|
||||
if (hratio > 0.10f && hratio < 3.0f && vratio >0.10f && vratio < 3.0f) {
|
||||
this->fx = hratio;
|
||||
this->fy = vratio;
|
||||
}
|
||||
else
|
||||
{
|
||||
writelog("error horizental or vertical ratio");
|
||||
FileTools::writelog(log_ERROR,"error horizental or vertical ratio");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,10 +161,12 @@ void ImageMatQueue::setparam(const GScanCap& param)
|
|||
#else // REAL300DPI
|
||||
fixedSize = papersize.GetPaperSize(param.papertype, 200.0f, param.paperAlign);
|
||||
#endif
|
||||
m_iaList.push_back(shared_ptr<CImageApply>(new CImageApplyAutoCrop(islongcustomcrop ? islongcustomcrop : param.is_autocrop, param.autodescrew, param.fillbackground, cv::Size(fixedSize.cx, fixedSize.cy), param.is_convex,false,param.AutoCrop_threshold,param.noise,param.indent)));
|
||||
//m_iaList.push_back(shared_ptr<CImageApply>(new CImageApplyAutoCrop(true, param.autodescrew, param.fillbackground, cv::Size(fixedSize.cx, fixedSize.cy), param.is_convex, false, param.AutoCrop_threshold, param.noise, param.indent)));
|
||||
//if(!islongcustomcrop)
|
||||
// m_iaList.push_back(shared_ptr<CImageApply>(new CImageApplyResize(CImageApplyResize::ResizeType::DSIZE, cv::Size(fixedSize.cx, fixedSize.cy), 1.0, 1.0)));
|
||||
m_iaList.push_back(shared_ptr<CImageApply>(new CImageApplyAutoCrop(islongcustomcrop ? islongcustomcrop : param.is_autocrop,
|
||||
param.autodescrew, param.fillbackground, cv::Size(fixedSize.cx, fixedSize.cy), param.is_convex,false,param.AutoCrop_threshold,param.noise,param.indent)));
|
||||
|
||||
/* m_iaList.push_back(shared_ptr<CImageApply>(new CImageApplyAutoCrop(true, param.autodescrew, param.fillbackground, cv::Size(fixedSize.cx, fixedSize.cy), param.is_convex, false, param.AutoCrop_threshold, param.noise, param.indent)));
|
||||
if(!(islongcustomcrop ? islongcustomcrop : param.is_autocrop))
|
||||
m_iaList.push_back(shared_ptr<CImageApply>(new CImageApplyResize(CImageApplyResize::ResizeType::DSIZE, cv::Size(fixedSize.cx, fixedSize.cy), 1.0, 1.0)));*/
|
||||
}
|
||||
if (param.is_autodiscradblank_normal || param.is_autodiscradblank_vince) {
|
||||
//m_iaList.push_back(shared_ptr<CImageApply>(new CImageApplyDiscardBlank()));
|
||||
|
@ -347,6 +349,13 @@ void ImageMatQueue::proc()
|
|||
auto& buffs = m_rawBuffs.Take()->getImageBuffs();
|
||||
if (!m_rawBuffs.IsShutDown() && !buffs.empty()) {
|
||||
//m_threadpool->enqueue(&ImageMatQueue::imageproceing, this, buffs);
|
||||
//try {
|
||||
// imageproceing(buffs);
|
||||
//}
|
||||
//catch (std::exception& e)
|
||||
//{
|
||||
// FileTools::writelog(log_ERROR, " image proc error " + std::string(e.what()));
|
||||
//}
|
||||
imageproceing(buffs);
|
||||
}
|
||||
}
|
||||
|
@ -372,7 +381,7 @@ void ImageMatQueue::imageproceing(std::vector<std::shared_ptr<std::vector<char>>
|
|||
cv::Mat mat = cv::imdecode(*buf, rmc);
|
||||
buf.reset();
|
||||
if (mat.empty()) {
|
||||
writelog("decode image data error");
|
||||
FileTools::writelog(log_ERROR,"decode image data error");
|
||||
}
|
||||
#ifdef G200
|
||||
cv::resize(mat, mat, cv::Size(), fx, fy);//用于修正与佳能机器幅面大小不匹配问题 此系数请勿轻易动
|
||||
|
@ -391,11 +400,12 @@ void ImageMatQueue::imageproceing(std::vector<std::shared_ptr<std::vector<char>>
|
|||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
writelog(e.what());
|
||||
//writelog(e.what());
|
||||
FileTools::writelog(log_ERROR, e.what());
|
||||
}
|
||||
}
|
||||
buffs.clear();
|
||||
//DogEar_index++; //ÔÝʱÆÁ±Î
|
||||
//DogEar_index++; //ÔÝʱÆÁ±Î 2021.3.18
|
||||
//StopWatch sw;
|
||||
//sw.reset();
|
||||
//if (ischeck_dogear)
|
||||
|
@ -445,7 +455,7 @@ void ImageMatQueue::imageproceing(std::vector<std::shared_ptr<std::vector<char>>
|
|||
}
|
||||
else
|
||||
{
|
||||
writelog("enqueue image is empty " + std::to_string(index++));
|
||||
FileTools::writelog(log_ERROR,"enqueue image is empty " + std::to_string(index++));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ bool UsbScanEx::open()
|
|||
CloseHandle(m_h_dev);
|
||||
m_h_dev = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
FileTools::write_log("USB Open!");
|
||||
FileTools::writelog(log_lv::log_INFO,"USB Open!");
|
||||
return m_h_dev;
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ bool UsbScanEx::close()
|
|||
}
|
||||
}
|
||||
m_b_is_connected = FALSE;
|
||||
FileTools::write_log("USB Close!");
|
||||
FileTools::writelog(log_lv::log_INFO,"USB Close!");
|
||||
return b_ret;
|
||||
}
|
||||
|
||||
|
@ -170,13 +170,13 @@ int UsbScanEx::read_bulk(void* data, int len)
|
|||
case ERROR_FILE_NOT_FOUND:
|
||||
case ERROR_ACCESS_DENIED:
|
||||
m_b_is_connected = false;
|
||||
FileTools::write_log(error_code == 2 ? "USB connection error: ERROR_FILE_NOT_FOUND" : "USB connection error: ERROR_ACCESS_DENIED");
|
||||
FileTools::writelog(log_lv::log_WARN, "errorcode =" + std::to_string(error_code));
|
||||
if (hotplug_call) {
|
||||
hotplug_call(true, usrdata);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
//writelog("Usb read_bulk error code ID: " + std::to_string(error_code));
|
||||
FileTools::writelog(log_INFO,"Usb read_bulk error code : " + std::to_string(error_code));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -207,13 +207,13 @@ int UsbScanEx::write_bulk(void* data, int len)
|
|||
case ERROR_FILE_NOT_FOUND:
|
||||
case ERROR_ACCESS_DENIED:
|
||||
m_b_is_connected = false;
|
||||
FileTools::write_log(errorcode == 2 ? "USB connection error: ERROR_FILE_NOT_FOUND" : "USB connection error: ERROR_ACCESS_DENIED");
|
||||
FileTools::writelog(log_lv::log_WARN,"errorcode ="+ std::to_string(errorcode));
|
||||
if (hotplug_call) {
|
||||
hotplug_call(true, usrdata);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
//writelog("Usb write_bulk error code ID: " + std::to_string(errorcode));
|
||||
FileTools::writelog(log_INFO,"Usb write_bulk error code: " + std::to_string(errorcode));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ int UsbScanEx::read_int(void* data, int len)
|
|||
|
||||
case ERROR_FILE_NOT_FOUND:
|
||||
m_b_is_connected = false;
|
||||
FileTools::write_log("USB connection error: ERROR_FILE_NOT_FOUND");
|
||||
FileTools::writelog(log_lv::log_ERROR,"USB connection error: ERROR_FILE_NOT_FOUND");
|
||||
if (hotplug_call) {
|
||||
hotplug_call(true, usrdata);
|
||||
}
|
||||
|
|
|
@ -3,9 +3,10 @@
|
|||
#include <io.h>
|
||||
#include <fstream>
|
||||
#include <time.h>
|
||||
//#include <log4cplus/log4cplus.h>
|
||||
#include <log4cplus/log4cplus.h>
|
||||
#include "PublicFunc.h"
|
||||
|
||||
|
||||
enum log_lv :int {
|
||||
log_TRACE = 0,
|
||||
log_DEBUG = 10000,
|
||||
|
@ -15,11 +16,10 @@ enum log_lv :int {
|
|||
log_FATAL = 50000,
|
||||
};
|
||||
|
||||
|
||||
class FileTools
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
static std::vector<std::string> getFiles(std::string path)
|
||||
{
|
||||
std::vector<std::string> files;
|
||||
|
@ -38,11 +38,9 @@ public:
|
|||
std::string savepath = TCHAR2STRING(szIniFile);
|
||||
write_log(savepath, log);
|
||||
}
|
||||
|
||||
static void write_log(std::string filename, std::string log)
|
||||
{
|
||||
//std::string savepath;
|
||||
//std::string str = "D:";
|
||||
//savepath = str+"\\"+filename;
|
||||
std::ofstream ofs(filename, std::ios::app);
|
||||
time_t timp;
|
||||
tm* p;
|
||||
|
@ -50,23 +48,75 @@ public:
|
|||
p=localtime(&timp);
|
||||
ofs << p->tm_year+1900 << "/" << p->tm_mon+1 << "/" << p->tm_mday << " " << p->tm_hour << ":" << p->tm_min << ":" << p->tm_sec << " "<<log << std::endl;
|
||||
}
|
||||
//static void writelog(std::wstring path, int lv, std::string log)
|
||||
//{
|
||||
// log4cplus::SharedAppenderPtr rf(new log4cplus::RollingFileAppender(
|
||||
// path,
|
||||
// 200 * 1024,
|
||||
// 5
|
||||
// ));
|
||||
// rf->setName(LOG4CPLUS_TEXT("file"));
|
||||
// log4cplus::tstring pattern = LOG4CPLUS_TEXT("%D{%m/%d/%y %H:%M:%S,%Q} [%t] %-5p %c - %m [%l]%n");
|
||||
// rf->setLayout(std::unique_ptr<log4cplus::Layout>(new log4cplus::PatternLayout(pattern)));
|
||||
|
||||
// log4cplus::Logger logger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("hglog"));
|
||||
// logger.setLogLevel(lv);
|
||||
// logger.addAppender(rf);
|
||||
// LOG4CPLUS_WARN(logger, log.c_str());
|
||||
// logger.removeAllAppenders();
|
||||
//}
|
||||
|
||||
|
||||
static void writelog(std::wstring path, int lv, std::string log)
|
||||
{
|
||||
log4cplus::SharedAppenderPtr rf(new log4cplus::RollingFileAppender(
|
||||
path,
|
||||
2048 * 1024,
|
||||
5
|
||||
));
|
||||
rf->setName(LOG4CPLUS_TEXT("file"));
|
||||
log4cplus::tstring pattern = LOG4CPLUS_TEXT("%D{%m/%d/%y %H:%M:%S,%Q} [%t] %-5p %c - %m %n");
|
||||
rf->setLayout(std::unique_ptr<log4cplus::Layout>(new log4cplus::PatternLayout(pattern)));
|
||||
|
||||
log4cplus::Logger logger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("hglog"));
|
||||
logger.setLogLevel(lv);
|
||||
logger.addAppender(rf);
|
||||
switch (lv)
|
||||
{
|
||||
case log_lv::log_TRACE:
|
||||
LOG4CPLUS_TRACE(logger, log.c_str()); break;
|
||||
case log_lv::log_DEBUG:
|
||||
LOG4CPLUS_DEBUG(logger, log.c_str()); break;
|
||||
case log_lv::log_INFO:
|
||||
LOG4CPLUS_INFO(logger, log.c_str()); break;
|
||||
case log_lv::log_WARN:
|
||||
LOG4CPLUS_WARN(logger, log.c_str()); break;
|
||||
case log_lv::log_ERROR:
|
||||
LOG4CPLUS_ERROR(logger, log.c_str()); break;
|
||||
case log_lv::log_FATAL:
|
||||
LOG4CPLUS_FATAL(logger, log.c_str()); break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
logger.removeAllAppenders();
|
||||
|
||||
}
|
||||
|
||||
static void writelog(int lv, std::string log)
|
||||
{
|
||||
TCHAR szIniFile[MAX_PATH] = { 0 };
|
||||
SHGetSpecialFolderPath(NULL, szIniFile, CSIDL_LOCAL_APPDATA, TRUE);
|
||||
_tcscat(szIniFile, HUAGAO_SCAN);
|
||||
_tcscat(szIniFile, TWAIN_INIPATH);
|
||||
_tcscat(szIniFile, TEXT("\\"));
|
||||
_tcscat(szIniFile, TWAIN_LOG_NAME);
|
||||
writelog(std::wstring(szIniFile), lv, log);
|
||||
}
|
||||
|
||||
static void writedebuglog(std::string log)
|
||||
{
|
||||
TCHAR szIniFile[MAX_PATH] = { 0 };
|
||||
SHGetSpecialFolderPath(NULL, szIniFile, CSIDL_LOCAL_APPDATA, TRUE);
|
||||
_tcscat(szIniFile, HUAGAO_SCAN);
|
||||
_tcscat(szIniFile, TWAIN_INIPATH);
|
||||
_tcscat(szIniFile, TEXT("\\"));
|
||||
_tcscat(szIniFile, TWAIN_LOG_NAME);
|
||||
writelog(std::wstring(szIniFile), log_lv::log_DEBUG, log);
|
||||
}
|
||||
static void writeerrorlog(std::string log)
|
||||
{
|
||||
TCHAR szIniFile[MAX_PATH] = { 0 };
|
||||
SHGetSpecialFolderPath(NULL, szIniFile, CSIDL_LOCAL_APPDATA, TRUE);
|
||||
_tcscat(szIniFile, HUAGAO_SCAN);
|
||||
_tcscat(szIniFile, TWAIN_INIPATH);
|
||||
_tcscat(szIniFile, TEXT("\\"));
|
||||
_tcscat(szIniFile, TWAIN_LOG_NAME);
|
||||
writelog(std::wstring(szIniFile), log_lv::log_ERROR, log);
|
||||
}
|
||||
private:
|
||||
static void getFiles(std::string path, std::vector<std::string>& files)
|
||||
{
|
||||
|
|
|
@ -18,7 +18,7 @@ hgConfigClass::hgConfigClass(GScanCap param)
|
|||
m_param.double_feed_enbale = (unsigned int)param.hardwarecaps.en_doublefeed;
|
||||
m_param.stable_enbale =(unsigned int) param.hardwarecaps.en_stapledetect;
|
||||
m_param.screw_detect_enable = (unsigned int)param.hardwarecaps.en_skrewdetect;
|
||||
m_param.screw_detect_level = (unsigned int)m_param.screw_detect_enable? secrewMaps[param.hardwarecaps.skrewdetectlevel]:0;
|
||||
m_param.screw_detect_level = (unsigned int)m_param.screw_detect_enable ? secrewMaps[param.hardwarecaps.skrewdetectlevel] : 0;
|
||||
#ifdef G200
|
||||
m_param.pc_correct = 0;
|
||||
#endif
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <fstream>
|
||||
#include <stdio.h>
|
||||
#include <sstream>
|
||||
#include "Device/filetools.h"
|
||||
#include "Device/CJsonObject.hpp"
|
||||
|
||||
|
||||
|
@ -278,6 +279,7 @@ GScanCap GscanJsonConfig::ReadGscanCap()
|
|||
}
|
||||
}
|
||||
catch (...){
|
||||
FileTools::writelog(log_ERROR, "ReadGscanCap Error");
|
||||
remove((dirpath + TCHAR2STRING(TWAIN_JSON_NAME)).c_str());
|
||||
createDirectory((char*)dirpath.c_str());
|
||||
SaveGscancapJson(JsonToGscancap(GetDefaultJson()), dirpath + TCHAR2STRING(TWAIN_JSON_NAME));
|
||||
|
@ -689,6 +691,7 @@ void GscanJsonConfig::SaveGscancapJson(GScanCap cap, std::string path)
|
|||
catch (...) {
|
||||
if (of.is_open())
|
||||
of.close();
|
||||
FileTools::writelog(log_ERROR, "save json error");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -865,6 +868,7 @@ json GscanJsonConfig::Readjson(std::string path)
|
|||
}
|
||||
catch (...)
|
||||
{
|
||||
FileTools::writelog(log_ERROR, "read json error");
|
||||
f.is_open() ? f.close() : void();
|
||||
return GetDefaultJson();
|
||||
}
|
||||
|
|
|
@ -55,6 +55,9 @@ void CImageApplyAutoCrop::apply(cv::Mat& pDib, int side)
|
|||
if (m_maxContour.size() == 0)
|
||||
{
|
||||
thre.release();
|
||||
#ifdef LOG
|
||||
FileTools::write_log("imgprc.txt", "exit CImageApplyAutoCrop apply");
|
||||
#endif // LOG
|
||||
return;
|
||||
}
|
||||
thre.release();
|
||||
|
@ -78,6 +81,7 @@ void CImageApplyAutoCrop::apply(cv::Mat& pDib, int side)
|
|||
dstTri[2] = cv::Point2f(rect.size.width - 1, 0);
|
||||
cv::Mat warp_mat;
|
||||
warp_mat = cv::getAffineTransform(srcTri, dstTri);
|
||||
//cv::warpAffine(src, dst, warp_mat, rect.size,cv::INTER_LANCZOS4);
|
||||
cv::warpAffine(src, dst, warp_mat, rect.size);
|
||||
}
|
||||
else
|
||||
|
@ -100,7 +104,7 @@ void CImageApplyAutoCrop::apply(cv::Mat& pDib, int side)
|
|||
cv::Point(thre_dst.cols - 1, thre_dst.rows - 1), cv::Point(0, thre_dst.rows - 1) };
|
||||
std::vector<std::vector<cv::Point>> rectEdges{ rectEdge };
|
||||
cv::drawContours(thre_dst, rectEdges, 0, cv::Scalar::all(0));
|
||||
cv::Mat element = cv::getStructuringElement(cv::MorphShapes::MORPH_RECT, cv::Size(m_indent*2, m_indent*2));
|
||||
cv::Mat element = cv::getStructuringElement(cv::MorphShapes::MORPH_RECT, cv::Size(m_indent, m_indent));
|
||||
cv::erode(thre_dst, thre_dst, element, cv::Point(-1, -1), 1);
|
||||
}
|
||||
hierarchy.clear();
|
||||
|
@ -143,6 +147,9 @@ void CImageApplyAutoCrop::apply(cv::Mat& pDib, int side)
|
|||
p += roi.tl();
|
||||
dst(roi).copyTo(pDib(rect));
|
||||
}
|
||||
#ifdef LOG
|
||||
FileTools::write_log("imgprc.txt", "exit CImageApplyAutoCrop apply8");
|
||||
#endif // LOG
|
||||
}
|
||||
|
||||
void CImageApplyAutoCrop::apply(std::vector<cv::Mat>& mats, bool isTwoSide)
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue