Hello community, here is the log from the commit of package yder for openSUSE:Leap:15.2 checked in at 2020-01-17 11:59:32 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Leap:15.2/yder (Old) and /work/SRC/openSUSE:Leap:15.2/.yder.new.26092 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yder" Fri Jan 17 11:59:32 2020 rev:4 rq:763564 version:1.4.8 Changes: -------- --- /work/SRC/openSUSE:Leap:15.2/yder/yder.changes 2020-01-15 16:32:33.708887662 +0100 +++ /work/SRC/openSUSE:Leap:15.2/.yder.new.26092/yder.changes 2020-01-17 11:59:35.420455182 +0100 @@ -1,0 +2,22 @@ +Sat Oct 5 20:34:27 UTC 2019 - Martin Hauke <[email protected]> + +- Update to versin 1.4.8 + * Avoid running y_init_logs without closing between + +------------------------------------------------------------------- +Fri Jul 12 21:03:56 UTC 2019 - Martin Hauke <[email protected]> + +- Update to version 1.4.7 + * Clean build process + * Clean static variables if error initializing logs with file +- Drop not longer needed patch: + * yder-fix-build.patch + +------------------------------------------------------------------- +Tue Jul 2 20:44:42 UTC 2019 - Martin Hauke <[email protected]> + +- Update to version 1.4.6 + * Fix package dependencies in cmake script + * Fix pkgconfig bugs + +------------------------------------------------------------------- Old: ---- yder-1.4.4.tar.gz yder-fix-build.patch New: ---- yder-1.4.8.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yder.spec ++++++ --- /var/tmp/diff_new_pack.6bXH3c/_old 2020-01-17 11:59:35.776455339 +0100 +++ /var/tmp/diff_new_pack.6bXH3c/_new 2020-01-17 11:59:35.780455341 +0100 @@ -1,7 +1,7 @@ # # spec file for package yder # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # Copyright (c) 2018, Martin Hauke <[email protected]> # # All modifications and additions to the file contributed by third parties @@ -13,24 +13,23 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # %define sover 1_4 Name: yder -Version: 1.4.4 +Version: 1.4.8 Release: 0 Summary: Logging library written in C License: LGPL-2.1-or-later Group: Development/Languages/C and C++ URL: https://github.com/babelouest/yder Source: https://github.com/babelouest/yder/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz -Patch0: yder-fix-build.patch BuildRequires: cmake BuildRequires: gcc-c++ BuildRequires: pkgconfig -BuildRequires: pkgconfig(liborcania) +BuildRequires: pkgconfig(liborcania) >= 2.0.0 BuildRequires: pkgconfig(libsystemd) %description @@ -61,7 +60,6 @@ %prep %setup -q -%patch0 -p1 %build %cmake \ ++++++ yder-1.4.4.tar.gz -> yder-1.4.8.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yder-1.4.4/.github/workflows/main.yml new/yder-1.4.8/.github/workflows/main.yml --- old/yder-1.4.4/.github/workflows/main.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/yder-1.4.8/.github/workflows/main.yml 2019-09-04 17:41:06.000000000 +0200 @@ -0,0 +1,26 @@ +on: [push, pull_request] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: install dependencies + run: | + sudo apt-get update + sudo apt-get install -y cmake pkg-config check libsubunit-dev cppcheck libsystemd-dev + - name: cppcheck + run: cppcheck --force --enable=warning,missingInclude --error-exitcode=1 . + - name: build + run: | + mkdir build + cd build + cmake -DBUILD_YDER_TESTING=on .. + make test package + sudo make install + sudo ldconfig + cd .. + make + make clean check diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yder-1.4.4/.gitignore new/yder-1.4.8/.gitignore --- old/yder-1.4.4/.gitignore 2018-10-27 20:34:43.000000000 +0200 +++ new/yder-1.4.8/.gitignore 2019-09-04 17:41:06.000000000 +0200 @@ -2,6 +2,7 @@ *.so *.so.*.* *.a +*.pc log_combined log_console log_file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yder-1.4.4/.travis.yml new/yder-1.4.8/.travis.yml --- old/yder-1.4.4/.travis.yml 2018-10-27 20:34:43.000000000 +0200 +++ new/yder-1.4.8/.travis.yml 2019-09-04 17:41:06.000000000 +0200 @@ -5,13 +5,27 @@ language: c addons: apt: - packages: [ libjansson-dev, check, libsubunit-dev, cppcheck ] + packages: [ check, libsubunit-dev, cppcheck, pkg-config ] matrix: include: - - os: linux + - env: LABEL=linux-gcc + os: linux compiler: gcc - - os: linux + - env: LABEL=linux-clang + os: linux compiler: clang + - env: LABEL=osx + os: osx + addons: + homebrew: + packages: + - check + - pkg-config + update: true + script: + - mkdir build && cd build + - cmake -DBUILD_YDER_TESTING=on -DWITH_JOURNALD=off .. + - make test - env: LABEL=cppcheck os: linux script: @@ -21,5 +35,7 @@ - cmake -DBUILD_YDER_TESTING=on -DWITH_JOURNALD=off .. - make test package - sudo make install - - cd ../src + - sudo ldconfig + - cd ../ - make Y_DISABLE_JOURNALD=1 + - make check diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yder-1.4.4/CHANGELOG.md new/yder-1.4.8/CHANGELOG.md --- old/yder-1.4.4/CHANGELOG.md 2018-10-27 20:34:43.000000000 +0200 +++ new/yder-1.4.8/CHANGELOG.md 2019-09-04 17:41:06.000000000 +0200 @@ -1,5 +1,26 @@ # Yder Changelog +## 1.4.8 + +- Avoid running `y_init_logs` without closing between + +## 1.4.7 + +- Fix build for MacOSX (thanks JohnAZoidberg!) +- Clean build process +- Clean static variables if error initializing logs with file + +## 1.4.6 + +- Fix package dependencies in cmake script + +## 1.4.5 + +- Install pkgconfig file when using Makefile +- Update src/Makefile to show more information +- Adapt for MSVC +- Fix pkgconfig bugs + ## 1.4.4 - Improve build config file and install headers diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yder-1.4.4/CMakeLists.txt new/yder-1.4.8/CMakeLists.txt --- old/yder-1.4.4/CMakeLists.txt 2018-10-27 20:34:43.000000000 +0200 +++ new/yder-1.4.8/CMakeLists.txt 2019-09-04 17:41:06.000000000 +0200 @@ -19,7 +19,9 @@ project(yder C) set(CMAKE_C_STANDARD 99) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror") +if (NOT MSVC) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror") +endif() # library info @@ -28,12 +30,12 @@ set(PROJECT_BUGREPORT_PATH "https://github.com/babelouest/yder/issues") set(LIBRARY_VERSION_MAJOR "1") set(LIBRARY_VERSION_MINOR "4") -set(LIBRARY_VERSION_PATCH "4") +set(LIBRARY_VERSION_PATCH "8") set(PROJECT_VERSION "${LIBRARY_VERSION_MAJOR}.${LIBRARY_VERSION_MINOR}.${LIBRARY_VERSION_PATCH}") set(LIBRARY_VERSION "${LIBRARY_VERSION_MAJOR}.${LIBRARY_VERSION_MINOR}.${LIBRARY_VERSION_PATCH}") set(LIBRARY_SOVERSION "${LIBRARY_VERSION_MAJOR}.${LIBRARY_VERSION_MINOR}") -set(ORCANIA_VERSION_DOWNLOAD "1.2.8") +set(ORCANIA_VERSION_REQUIRED "2.0.1") # cmake modules @@ -78,27 +80,26 @@ if (SYSTEMD_FOUND) set(SYSTEMD_LIBRARIES systemd) include_directories(${SYSTEMD_INCLUDE_DIRS}) - set(DISABLE_JOURNALD OFF) + set(Y_DISABLE_JOURNALD OFF) endif () else() - add_definitions(-DY_DISABLE_JOURNALD) - set(DISABLE_JOURNALD ON) + set(Y_DISABLE_JOURNALD ON) endif () # shared library add_library(yder SHARED ${LIB_SRC}) -set_target_properties(yder PROPERTIES - COMPILE_OPTIONS -Wextra - PUBLIC_HEADER "${INC_DIR}/yder.h;${PROJECT_BINARY_DIR}/yder-cfg.h" - VERSION "${LIBRARY_VERSION}" - SOVERSION "${LIBRARY_SOVERSION}") +if (NOT MSVC) + set_target_properties(yder PROPERTIES + COMPILE_OPTIONS -Wextra + PUBLIC_HEADER "${INC_DIR}/yder.h;${PROJECT_BINARY_DIR}/yder-cfg.h" + VERSION "${LIBRARY_VERSION}" + SOVERSION "${LIBRARY_SOVERSION}") +endif() if (WIN32) set_target_properties(yder PROPERTIES SUFFIX "-${LIBRARY_VERSION_MAJOR}.dll") endif () -target_link_libraries(yder ${LIBS} ${ORCANIA_LIBRARIES} ${SYSTEMD_LIBRARIES}) - # static library option(BUILD_STATIC "Build static library." OFF) @@ -114,11 +115,11 @@ if (SEARCH_ORCANIA) set(Orcania_FIND_QUIETLY ON) # force to find Orcania quietly include(FindOrcania) - find_package(Orcania 1.1 QUIET) # try to find orcania + find_package(Orcania ${ORCANIA_VERSION_REQUIRED} QUIET) # try to find orcania if (NOT ORCANIA_FOUND) include(DownloadProject) download_project(PROJ orcania # ... otherwise, download archive - URL "https://github.com/babelouest/orcania/archive/v${ORCANIA_VERSION_DOWNLOAD}.tar.gz" + URL "https://github.com/babelouest/orcania/archive/v${ORCANIA_VERSION_REQUIRED}.tar.gz" QUIET) add_subdirectory(${orcania_SOURCE_DIR} ${orcania_BINARY_DIR}) include_directories(${orcania_SOURCE_DIR}/include) @@ -133,9 +134,11 @@ endif () endif () +target_link_libraries(yder ${LIBS} ${ORCANIA_LIBRARIES} ${SYSTEMD_LIBRARIES}) + if (WITH_JOURNALD) set(PKGCONF_REQ "") - set(PKGCONF_REQ_PRIVATE "libsystemd, liborcania") + set(PKGCONF_REQ_PRIVATE "systemd, liborcania") else () set(PKGCONF_REQ "") set(PKGCONF_REQ_PRIVATE "liborcania") @@ -154,7 +157,7 @@ include(FindCheck) find_package(Check) if (CHECK_FOUND) - if (NOT WIN32) + if (NOT WIN32 AND NOT APPLE) include(FindSubunit) find_package(Subunit REQUIRED) endif () @@ -164,10 +167,16 @@ set(CMAKE_CTEST_COMMAND ctest -V) set(TST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/test) - set(LIBS yder ${LIBS} ${CHECK_LIBRARIES}) + set(LIBS yder ${LIBS} ${CHECK_LIBRARIES} ${ORCANIA_LIBRARIES}) if (NOT WIN32) find_package(Threads REQUIRED) - set(LIBS ${LIBS} ${SUBUNIT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} m rt) + set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT} m) + endif () + if (NOT APPLE) + set(LIBS ${LIBS} rt) + endif () + if (NOT WIN32 AND NOT APPLE) + set(LIBS ${LIBS} ${SUBUNIT_LIBRARIES}) endif () set(TESTS yder_test) @@ -261,10 +270,18 @@ endif () set(CPACK_DEBIAN_PACKAGE_MAINTAINER "[email protected]") -set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.4), liborcania (>= 1.2)") -if (WITH_SYSTEMD) - set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, libsystemd0") + +set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.4), liborcania (>= ${ORCANIA_VERSION_REQUIRED})") +if (INSTALL_HEADER) + if (WITH_SYSTEMD) + set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, libsystemd-dev") + endif () +else () + if (WITH_SYSTEMD) + set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, libsystemd0") + endif () endif () + set(CPACK_PACKAGE_FILE_NAME ${PACKAGE_FILE_NAME}) set(CPACK_SOURCE_GENERATOR "TGZ") @@ -278,6 +295,6 @@ message(STATUS "Journald support: ${WITH_JOURNALD}") message(STATUS "Build static library: ${BUILD_STATIC}") -message(STATUS "Build testing tree: ${BUILD_ULFIUS_TESTING}") +message(STATUS "Build testing tree: ${BUILD_YDER_TESTING}") message(STATUS "Install the header files: ${INSTALL_HEADER}") message(STATUS "Build RPM package: ${BUILD_RPM}") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yder-1.4.4/Makefile new/yder-1.4.8/Makefile --- old/yder-1.4.4/Makefile 2018-10-27 20:34:43.000000000 +0200 +++ new/yder-1.4.8/Makefile 2019-09-04 17:41:06.000000000 +0200 @@ -18,10 +18,10 @@ EXAMPLE_LOCATION=./examples TEST_LOCATION=./test -all: libyder.so +all: release debug: - cd $(LIBYDER_LOCATION) && $(MAKE) debug + cd $(LIBYDER_LOCATION) && $(MAKE) debug $* install: cd $(LIBYDER_LOCATION) && $(MAKE) install @@ -31,10 +31,10 @@ cd $(EXAMPLE_LOCATION) && $(MAKE) clean cd $(TEST_LOCATION) && $(MAKE) clean -run_test: +check: cd $(TEST_LOCATION) && $(MAKE) test -libyder.so: +release: cd $(LIBYDER_LOCATION) && $(MAKE) log_console: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yder-1.4.4/include/yder-cfg.h.in new/yder-1.4.8/include/yder-cfg.h.in --- old/yder-1.4.4/include/yder-cfg.h.in 2018-10-27 20:34:43.000000000 +0200 +++ new/yder-1.4.8/include/yder-cfg.h.in 2019-09-04 17:41:06.000000000 +0200 @@ -27,6 +27,6 @@ #define _YDER_CFG_H_ #define YDER_VERSION ${PROJECT_VERSION} -#cmakedefine DISABLE_JOURNALD +#cmakedefine Y_DISABLE_JOURNALD #endif /* _YDER_CFG_H_ */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yder-1.4.4/src/Makefile new/yder-1.4.8/src/Makefile --- old/yder-1.4.4/src/Makefile 2018-10-27 20:34:43.000000000 +0200 +++ new/yder-1.4.8/src/Makefile 2019-09-04 17:41:06.000000000 +0200 @@ -18,15 +18,27 @@ # You should have received a copy of the GNU General Public # License along with this library. If not, see <http://www.gnu.org/licenses/>. # +PROJECT_NAME=yder +PROJECT_DESCRIPTION=Logging library for C applications +PROJECT_BUGREPORT_PATH=https://github.com/babelouest/yder/issues +PKGCONF_REQ= +PKGCONF_REQ_PRIVATE= DESTDIR=/usr/local YDER_INCLUDE=../include CONFIG_TEMPLATE=$(YDER_INCLUDE)/yder-cfg.h.in CONFIG_FILE=$(YDER_INCLUDE)/yder-cfg.h +PKGCONFIG_FILE=../libyder.pc +PKGCONFIG_TEMPLATE=../libyder.pc.in CC=gcc -CFLAGS+=-c -fPIC -Wall -D_REENTRANT -I$(YDER_INCLUDE) $(ADDITIONALFLAGS) $(CPPFLAGS) +CFLAGS+=-c -fPIC -Wall -Werror -Wextra -D_REENTRANT -I$(YDER_INCLUDE) $(ADDITIONALFLAGS) $(CPPFLAGS) LIBS=-lc -lorcania $(ADDITIONALLIBS) OUTPUT=libyder.so -VERSION=1.4.4 +VERSION=1.4.8 + +SONAME = -soname +ifeq ($(shell uname -s),Darwin) + SONAME = -install_name +endif ifndef Y_DISABLE_JOURNALD DISABLE_JOURNALD=0 @@ -39,35 +51,52 @@ $(CONFIG_FILE): @cp $(CONFIG_TEMPLATE) $(CONFIG_FILE) + @echo Config file $(CONFIG_FILE) generated @sed -i -e 's/$${PROJECT_VERSION}/$(VERSION)/g' $(CONFIG_FILE) @if [ "$(DISABLE_JOURNALD)" = "1" ]; then \ - sed -i -e 's/\#cmakedefine DISABLE_JOURNALD/\#define Y_DISABLE_JOURNALD/g' $(CONFIG_FILE); \ + echo "JOURNALD SUPPORT DISABLED"; \ + sed -i -e 's/\#cmakedefine Y_DISABLE_JOURNALD/\#define Y_DISABLE_JOURNALD/g' $(CONFIG_FILE); \ else \ - sed -i -e 's/\#cmakedefine DISABLE_JOURNALD/\/* #undef Y_DISABLE_JOURNALD *\//g' $(CONFIG_FILE); \ + echo "JOURNALD SUPPORT ENABLED"; \ + sed -i -e 's/\#cmakedefine Y_DISABLE_JOURNALD/\/* #undef Y_DISABLE_JOURNALD *\//g' $(CONFIG_FILE); \ fi - @echo Config file $(CONFIG_FILE) generated -libyder.so: $(CONFIG_FILE) yder.o - $(CC) -shared -fPIC -Wl,-soname,$(OUTPUT) -o $(OUTPUT).$(VERSION) yder.o $(LIBS) $(LDFLAGS) +$(PKGCONFIG_FILE): + @cp $(PKGCONFIG_TEMPLATE) $(PKGCONFIG_FILE) + @echo Pkgconfig file $(PKGCONFIG_FILE) generated + @sed -i -e 's#@CMAKE_INSTALL_PREFIX@#$(DESTDIR)#g' $(PKGCONFIG_FILE) + @sed -i -e 's/@CMAKE_INSTALL_LIBDIR@/lib/g' $(PKGCONFIG_FILE) + @sed -i -e 's/@CMAKE_INSTALL_INCLUDEDIR@/include/g' $(PKGCONFIG_FILE) + @sed -i -e 's/@PROJECT_NAME@/$(PROJECT_NAME)/g' $(PKGCONFIG_FILE) + @sed -i -e 's/@PROJECT_DESCRIPTION@/$(PROJECT_DESCRIPTION)/g' $(PKGCONFIG_FILE) + @sed -i -e 's|@PROJECT_BUGREPORT_PATH@|$(PROJECT_BUGREPORT_PATH)|g' $(PKGCONFIG_FILE) + @sed -i -e 's/@LIBRARY_VERSION@/$(VERSION)/g' $(PKGCONFIG_FILE) + @sed -i -e 's/@PKGCONF_REQ@/$(PKGCONF_REQ)/g' $(PKGCONFIG_FILE) + @sed -i -e 's/@PKGCONF_REQ_PRIVATE@/$(PKGCONF_REQ_PRIVATE)/g' $(PKGCONFIG_FILE) + +libyder.so: yder.o + $(CC) -shared -fPIC -Wl,$(SONAME),$(OUTPUT) -o $(OUTPUT).$(VERSION) yder.o $(LIBS) $(LDFLAGS) ln -sf $(OUTPUT).$(VERSION) $(OUTPUT) -libyder.a: $(CONFIG_FILE) yder.o +libyder.a: yder.o ar rcs libyder.a yder.o -yder.o: $(YDER_INCLUDE)/yder.h yder.c - $(CC) $(CFLAGS) $(CPPFLAGS) yder.c +yder.o: $(CONFIG_FILE) $(YDER_INCLUDE)/yder.h yder.c + $(CC) $(CFLAGS) yder.c clean: - rm -f *.o *.so *.a $(OUTPUT) $(OUTPUT).* $(YDER_INCLUDE)/yder-cfg.h + rm -f *.o *.so *.a $(OUTPUT) $(PKGCONFIG_FILE) $(OUTPUT).* $(YDER_INCLUDE)/yder-cfg.h -install: all +install: all $(PKGCONFIG_FILE) install $(OUTPUT).$(VERSION) $(DESTDIR)/lib + install -m644 $(PKGCONFIG_FILE) $(DESTDIR)/lib/pkgconfig install -m644 $(YDER_INCLUDE)/yder.h $(DESTDIR)/include install -m644 $(CONFIG_FILE) $(DESTDIR)/include -ldconfig static-install: static install libyder.a $(DESTDIR)/lib + install -m644 $(PKGCONFIG_FILE) $(DESTDIR)/lib/pkgconfig install -m644 $(YDER_INCLUDE)/yder.h $(DESTDIR)/include install -m644 $(CONFIG_FILE) $(DESTDIR)/include @@ -76,6 +105,7 @@ rm -f $(DESTDIR)/lib/$(OUTPUT).* rm -f $(DESTDIR)/include/yder.h rm -f $(DESTDIR)/include/yder-cfg.h + rm -f $(DESTDIR)/lib/pkgconfig/$(PKGCONFIG_FILE) debug: ADDITIONALFLAGS=-DDEBUG -g -O0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yder-1.4.4/src/yder.c new/yder-1.4.8/src/yder.c --- old/yder-1.4.4/src/yder.c 2018-10-27 20:34:43.000000000 +0200 +++ new/yder-1.4.8/src/yder.c 2019-09-04 17:41:06.000000000 +0200 @@ -212,16 +212,38 @@ } if (init_log_file != NULL) { - cur_log_file_path = init_log_file; + if (cur_log_file_path == NULL) { + cur_log_file_path = init_log_file; + } else { + // Logs have already been initialized, cancel + perror("Error - yder logs already initialized"); + return 0; + } } if (app_name != NULL) { - cur_app_name = o_strdup(app_name); + if (cur_app_name == NULL) { + cur_app_name = o_strdup(app_name); + } else { + // Logs have already been initialized, cancel + perror("Error - yder logs already initialized"); + return 0; + } + } + + if (init_mode == Y_LOG_MODE_FILE && !o_strlen(cur_log_file_path)) { + // Logs have already been initialized, cancel + perror("Error - log file path misssing"); + return 0; } if (cur_log_file_path != NULL) { if ((cur_log_file = fopen(cur_log_file_path, "a+")) == NULL) { + fprintf(stderr, "%s - ", cur_log_file_path); perror("Error opening log file"); + cur_log_file_path = NULL; + o_free(cur_app_name); + cur_app_name = NULL; return 0; } } @@ -236,11 +258,12 @@ if (cur_mode & Y_LOG_MODE_SYSLOG) { y_write_log_syslog(cur_app_name, level, message); } - #ifndef Y_DISABLE_JOURNALD +#endif + +#if !defined(_WIN32) && !defined(Y_DISABLE_JOURNALD) if (cur_mode & Y_LOG_MODE_JOURNALD) { y_write_log_journald(cur_app_name, level, message); } - #endif #endif if (cur_mode & Y_LOG_MODE_FILE) { y_write_log_file(cur_app_name, now, cur_log_file, level, message); @@ -266,18 +289,20 @@ */ int y_init_logs(const char * app, const unsigned long init_mode, const unsigned long init_level, const char * init_log_file, const char * message) { #ifdef _WIN32 - if (init_mode & Y_LOG_MODE_SYSLOG) { - perror("syslog mode not supported on your architecture"); - return 0; - } else if (init_mode & Y_LOG_MODE_JOURNALD) { - perror("journald mode not supported on your architecture"); - return 0; - } else { - return y_write_log(app, init_mode, init_level, init_log_file, NULL, NULL, Y_LOG_LEVEL_INFO, message); - } -#else - return y_write_log(app, init_mode, init_level, init_log_file, NULL, NULL, Y_LOG_LEVEL_INFO, message); + if (init_mode & Y_LOG_MODE_SYSLOG) { + perror("syslog mode not supported on your architecture"); + return 0; + } #endif + +#if defined(_WIN32) || defined(Y_DISABLE_JOURNALD) + if (init_mode & Y_LOG_MODE_JOURNALD) { + perror("journald mode not supported on your architecture"); + return 0; + } +#endif + + return y_write_log(app, init_mode, init_level, init_log_file, NULL, NULL, Y_LOG_LEVEL_INFO, message); } /** diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yder-1.4.4/test/Makefile new/yder-1.4.8/test/Makefile --- old/yder-1.4.4/test/Makefile 2018-10-27 20:34:43.000000000 +0200 +++ new/yder-1.4.8/test/Makefile 2019-09-04 17:41:06.000000000 +0200 @@ -20,10 +20,10 @@ # CC=gcc -CFLAGS=-Wall -D_REENTRANT -DDEBUG -g -O0 -I$(INCLUDE_LOCATION) +CFLAGS+=-Wall -D_REENTRANT -DDEBUG -g -O0 -I$(INCLUDE_LOCATION) $(CPPFLAGS) YDER_LOCATION=../src INCLUDE_LOCATION=../include -LIBS=-lc -lorcania -lyder -lcheck -lpthread -lm -lrt -lsubunit -L$(YDER_LOCATION) +LIBS=-lc -lorcania -lyder $(shell pkg-config --libs check) -L$(YDER_LOCATION) all: test @@ -37,6 +37,9 @@ $(CC) $(CFLAGS) yder_test.c -o yder_test $(LIBS) test_yder_test: libyder.so yder_test - -LD_LIBRARY_PATH=$(YDER_LOCATION):${LD_LIBRARY_PATH} ./yder_test + LD_LIBRARY_PATH=$(YDER_LOCATION):${LD_LIBRARY_PATH} ./yder_test test: test_yder_test + +memcheck: yder_test + LD_LIBRARY_PATH=$(YDER_LOCATION):${LD_LIBRARY_PATH} valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all ./yder_test 2>valgrind.txt diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yder-1.4.4/test/yder_test.c new/yder-1.4.8/test/yder_test.c --- old/yder-1.4.4/test/yder_test.c 2018-10-27 20:34:43.000000000 +0200 +++ new/yder-1.4.8/test/yder_test.c 2019-09-04 17:41:06.000000000 +0200 @@ -19,17 +19,47 @@ level = log_level; } -START_TEST(test_yder_init) +START_TEST(test_yder_init_console) { ck_assert_int_eq(y_init_logs("test_yder_console", Y_LOG_MODE_CONSOLE, Y_LOG_LEVEL_DEBUG, NULL, "first test"), 1); y_close_logs(); +} +END_TEST + +START_TEST(test_yder_init_file) +{ ck_assert_int_eq(y_init_logs("test_yder_file", Y_LOG_MODE_FILE, Y_LOG_LEVEL_DEBUG, "/tmp/test.log", "second test"), 1); y_close_logs(); +} +END_TEST + +START_TEST(test_yder_init_syslog) +{ +#ifndef _WIN32 ck_assert_int_eq(y_init_logs("test_yder_syslog", Y_LOG_MODE_SYSLOG, Y_LOG_LEVEL_DEBUG, NULL, "third test"), 1); y_close_logs(); +#else + ck_assert_int_eq(y_init_logs("test_yder_syslog", Y_LOG_MODE_SYSLOG, Y_LOG_LEVEL_DEBUG, NULL, "third test"), 0); +#endif +} +END_TEST + +START_TEST(test_yder_init_journald) +{ +#if !defined(_WIN32) && !defined(Y_DISABLE_JOURNALD) ck_assert_int_eq(y_init_logs("test_yder_journald", Y_LOG_MODE_JOURNALD, Y_LOG_LEVEL_DEBUG, NULL, "fourth test"), 1); y_close_logs(); +#else + ck_assert_int_eq(y_init_logs("test_yder_journald", Y_LOG_MODE_JOURNALD, Y_LOG_LEVEL_DEBUG, NULL, "fourth test"), 0); +#endif +} +END_TEST + +START_TEST(test_yder_init_error_file) +{ ck_assert_int_eq(y_init_logs("test_yder_file_fail", Y_LOG_MODE_FILE, Y_LOG_LEVEL_DEBUG, "/nope/nope", "second test"), 0); + ck_assert_int_eq(y_init_logs("test_yder_file_fail", Y_LOG_MODE_FILE, Y_LOG_LEVEL_DEBUG, "", "second test"), 0); + ck_assert_int_eq(y_init_logs("test_yder_file_fail", Y_LOG_MODE_FILE, Y_LOG_LEVEL_DEBUG, NULL, "second test"), 0); } END_TEST @@ -65,6 +95,32 @@ } END_TEST +START_TEST(test_yder_init_multiple_error) +{ + ck_assert_int_eq(y_init_logs("test_yder_console", Y_LOG_MODE_CONSOLE, Y_LOG_LEVEL_DEBUG, NULL, "first test"), 1); + ck_assert_int_eq(y_init_logs("test_yder_console", Y_LOG_MODE_CONSOLE, Y_LOG_LEVEL_DEBUG, NULL, "first test"), 0); + y_close_logs(); +} +END_TEST + +START_TEST(test_yder_init_multiple_ok) +{ + ck_assert_int_eq(y_init_logs("test_yder_console", Y_LOG_MODE_CONSOLE, Y_LOG_LEVEL_DEBUG, NULL, "first test"), 1); + ck_assert_int_eq(y_close_logs(), 1); + ck_assert_int_eq(y_init_logs("test_yder_console", Y_LOG_MODE_CONSOLE, Y_LOG_LEVEL_DEBUG, NULL, "first test"), 1); + ck_assert_int_eq(y_close_logs(), 1); +} +END_TEST + +START_TEST(test_yder_init_close_multiple) +{ + ck_assert_int_eq(y_close_logs(), 1); + ck_assert_int_eq(y_init_logs("test_yder_console", Y_LOG_MODE_CONSOLE, Y_LOG_LEVEL_DEBUG, NULL, "first test"), 1); + ck_assert_int_eq(y_close_logs(), 1); + ck_assert_int_eq(y_close_logs(), 1); +} +END_TEST + START_TEST(test_yder_level_debug) { ck_assert_int_eq(y_init_logs("test_yder_level_debug", Y_LOG_MODE_CALLBACK, Y_LOG_LEVEL_DEBUG, NULL, "test_yder_level_debug"), 1); @@ -172,7 +228,14 @@ s = suite_create("Yder tests functions"); tc_core = tcase_create("test_yder"); - tcase_add_test(tc_core, test_yder_init); + tcase_add_test(tc_core, test_yder_init_console); + tcase_add_test(tc_core, test_yder_init_file); + tcase_add_test(tc_core, test_yder_init_syslog); + tcase_add_test(tc_core, test_yder_init_journald); + tcase_add_test(tc_core, test_yder_init_error_file); + tcase_add_test(tc_core, test_yder_init_multiple_error); + tcase_add_test(tc_core, test_yder_init_multiple_ok); + tcase_add_test(tc_core, test_yder_init_close_multiple); tcase_add_test(tc_core, test_yder_callback); tcase_add_test(tc_core, test_yder_level_debug); tcase_add_test(tc_core, test_yder_level_info);
