Skip to content

Commit

Permalink
refs #135 @1h back to normal.
Browse files Browse the repository at this point in the history
- set_name is virtual again
- logger::sink::write is virtual again too
  • Loading branch information
HerbertKoelman committed Jul 6, 2019
1 parent 224a4b4 commit d5b0fd8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
16 changes: 10 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cmake_minimum_required(VERSION 3.11)
project(
cpp-logger
VERSION 2.2.7
DESCRIPTION "Simple C++ logger (${GIT_LOG})")
DESCRIPTION "Simple C++ logger")

option(GCOV "Activate GCOV options")

Expand Down Expand Up @@ -35,18 +35,21 @@ find_package(SonarCloud PATHS cmake)
#
if( CMAKE_BUILD_TYPE MATCHES Release )
if( GIT_LOG )
add_definitions( -DCPP_LOGGER_VERSION="${PROJECT_VERSION} - ${GIT_LOG}")
set(CPP_LOGGER_VERSION "${PROJECT_VERSION} - ${GIT_LOG}")
else()
add_definitions( -DCPP_LOGGER_VERSION="${PROJECT_VERSION}")
set(CPP_LOGGER_VERSION "${PROJECT_VERSION}")
endif()
else()
if( GIT_LOG )
add_definitions( -DCPP_LOGGER_VERSION="${PROJECT_VERSION}-${GIT_LOG}-SNAPSHOT")
set(CPP_LOGGER_VERSION "${PROJECT_VERSION}-${GIT_LOG}-SNAPSHOT")
else()
add_definitions( -DCPP_LOGGER_VERSION="${PROJECT_VERSION}-SNAPSHOT")
set(CPP_LOGGER_VERSION "${PROJECT_VERSION}-SNAPSHOT")
endif()
endif()

message(STATUS "Building ${PROJECT_NAME} version ${CPP_LOGGER_VERSION}")
add_definitions( -DCPP_LOGGER_VERSION="${CPP_LOGGER_VERSION}")

# targets --------------------------------------------------
#
# project's public headers
Expand Down Expand Up @@ -92,9 +95,10 @@ endif()
#
find_package(Doxygen REQUIRED dot OPTIONAL_COMPONENTS mscgen dia)
if (Doxygen_FOUND)
set(DOXYGEN_PROJECT_NUMBER ${CPP_LOGGER_VERSION})
set(DOXYGEN_EXAMPLE_PATH tests)
set(DOXYGEN_EXTRACT_ALL yes)
set(DOXYGEN_PROJECT_BRIEF ${PROJECT_DESCRUPTION})
set(DOXYGEN_PROJECT_BRIEF ${PROJECT_DESCRIPTION})
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE "${CMAKE_SOURCE_DIR}/README.md")
doxygen_add_docs(doxygen README.md src include COMMENT "generate on-line documentation")
endif()
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## cpp-logger

[![Build Status](https://travis-ci.com/HerbertKoelman/cpp-logger.svg?branch=master)](https://travis-ci.com/HerbertKoelman/cpp-logger) [![codecov](https://codecov.io/gh/HerbertKoelman/cpp-logger/branch/master/graph/badge.svg)](https://codecov.io/gh/HerbertKoelman/cpp-logger) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=HerbertKoelman_cpp-logger&metric=alert_status)](https://sonarcloud.io/dashboard?id=HerbertKoelman_cpp-logger)
[![Build Status](https://travis-ci.com/HerbertKoelman/cpp-logger.svg?branch=master)](https://travis-ci.com/HerbertKoelman/cpp-logger) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=HerbertKoelman_cpp-logger&metric=alert_status)](https://sonarcloud.io/dashboard?id=HerbertKoelman_cpp-logger)
[![codecov](https://codecov.io/gh/HerbertKoelman/cpp-logger/branch/master/graph/badge.svg)](https://codecov.io/gh/HerbertKoelman/cpp-logger)

### What it does

Expand Down
12 changes: 6 additions & 6 deletions include/logger/sinks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ namespace logger {
* @param pname program name
* @param level initial log level (defaults to logger::log_level::info)
*/
explicit sink(const std::string &name = "default", const std::string &pname = "prog", log_level level = log_levels::info);
explicit sink(const std::string &name, const std::string &pname = "prog", log_level level = log_levels::info);

/** @return display name for a given log level
*/
Expand All @@ -118,7 +118,7 @@ namespace logger {
*
* @param name subset name.
*/
void set_name (const std::string &name);
virtual void set_name (const std::string &name);

private:
#if __cplusplus >= 201703L
Expand Down Expand Up @@ -175,15 +175,15 @@ namespace logger {
* This sink writes messages in FILE.
*
*/
void write(log_level level, const char *fmt, ...) ;
void write(log_level level, const char *fmt, ...) override ;

protected:

/** Set sybsystem name and reset fixed part of the output pattern.
*
* @param name sink name
*/
void set_name(const std::string &name) ;
void set_name(const std::string &name) override ;

/** fill the buffer with the current date and time information
*/
Expand All @@ -195,7 +195,7 @@ namespace logger {
pid_t _pid; //!< process ID
std::string _lag; //!< date time lag (i.e. +02:00)
std::string _hostname; //!< hostname (this will be displayed by log messages)
std::string _pattern; //!< message pattern (layout)
std::string _pattern; //!< message pattern (layout)
};

/** stdout sink.
Expand Down Expand Up @@ -301,7 +301,7 @@ namespace logger {

protected:

void set_name(const std::string &name) ;
void set_name(const std::string &name) override ;

private:
std::string _pattern; //!< message pattern (layout)
Expand Down

0 comments on commit d5b0fd8

Please sign in to comment.