Skip to content

Commit 6a58107

Browse files
Merge branch '125-fix-sonar-issues' into develop
2 parents cdb0516 + 95a342a commit 6a58107

File tree

12 files changed

+18
-36
lines changed

12 files changed

+18
-36
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
2.3.0
2+
- Remove extern "C" (#127)
3+
- Remove commented out code (#126)
4+
- make logger::logger rule zero compliant (#123)
25
- write more logger::sink tests (#124)
36
- fixed a bug in ./tests/CMakeLists.txt that prevented exception_tests to be run (#121)
47
- activate soanrcloud checks (#120)

cmake/SonarCloudConfig.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ if ( SONAR )
4848
message(SEND_ERROR "Failed to find the program [sonar_scanner], make sure sonar tools are installed.")
4949
endif()
5050

51-
else()
52-
message(WARNING "SONAR cloud build is turned off, use -DSONAR=yes to turn in ON")
51+
#else()
52+
# message(WARNING "SONAR cloud build is turned off, use -DSONAR=yes to turn in ON")
5353
endif()
5454

include/logger/cpp-logger.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace logger {
1717

1818
/** @return the library's current version
1919
*/
20-
extern "C" const char *cpp_logger_version();
20+
const char *cpp_logger_version();
2121

2222
/** @} */
2323
}

include/logger/facilities.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ namespace logger {
6565
// intentional...
6666
}
6767

68-
// virtual ~facility() ;
69-
7068
private:
7169
const facility_code _code;
7270
const char *_keyword;

include/logger/logger.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,9 @@ namespace logger {
190190
*/
191191
logger( const std::string &name, sink *sink);
192192

193-
/** dispose of logger's ressources
194-
*/
195-
virtual ~logger();
196-
197193
private:
198194

199-
sink *_sink; //!< logger delegate to a sink the actual magic to write log messages
195+
std::unique_ptr<sink> _sink; //!< logger delegate to a sink the actual magic to write log messages
200196

201197
std::string _name; //!< logger's name
202198
}; // logger

include/logger/registry.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ namespace logger {
147147
template<class T, typename... Args> logger_ptr get( const std::string &name, const Args&... args){
148148
std::lock_guard<std::mutex> lck(_mutex);
149149

150-
// printf("DEBUG logger::registry.get(%s, %d);\n", name.c_str(), _level);
150+
# ifdef DEBUG
151+
printf("DEBUG logger::registry.get(%s, %d);\n", name.c_str(), _level);
152+
# endif
151153

152154
logger_ptr logger;
153155
auto search = _loggers.find(name);
@@ -178,7 +180,6 @@ namespace logger {
178180
};
179181

180182
~registry() = default;
181-
// ~registry() { std::cout << "DEBUG delete registry..." << std::endl ; };
182183

183184
private:
184185

include/logger/sinks.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,6 @@ namespace logger {
170170
*/
171171
explicit file_sink(FILE *file);
172172

173-
// virtual ~file_sink() ;
174-
175173
/** \copydoc sink::write()
176174
*
177175
* This sink writes messages in FILE.
@@ -293,7 +291,7 @@ namespace logger {
293291
*/
294292
explicit syslog_sink();
295293

296-
~syslog_sink() = default ; //override ;
294+
~syslog_sink() = default ;
297295

298296
/** \copydoc sink::write
299297
*

src/cpp-logger.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace logger {
1515

16-
extern "C" const char *cpp_logger_version(){
16+
const char *cpp_logger_version(){
1717

1818
#ifndef CPP_LOGGER_VERSION
1919
return "missing CPP_LOGGER_VERSION define. Re-run configure" ;

src/file_sink.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ namespace logger {
5050
_lag = buffer;
5151
};
5252

53-
// TODO remove this
54-
// file_sink::~file_sink() {
55-
// //fflush(_file_descriptor);
56-
// };
57-
5853
void file_sink::set_name(const std::string &name) {
5954
sink::set_name(name);
6055

@@ -85,7 +80,7 @@ namespace logger {
8580

8681
// new character vector
8782
// vsnprintf returns the needed characters to store the output
88-
// not possible with XL C/C++ std::vector<char> buf(1+std::vsnprintf(NULL, 0, fmt, args1));
83+
//NOSONAR not possible with XL C/C++ std::vector<char> buf(1+std::vsnprintf(NULL, 0, fmt, args1));
8984

9085
// this call only returns the actual number of bytes needed to store the message.
9186
// It doesn't count the needed end-of-string

src/logger.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,8 @@ namespace logger {
1414
// constructors & destructors -------------------------------------
1515
//
1616

17-
logger::logger(const std::string &name, sink *sink) : _sink(NULL), _name (name) {
18-
_sink = sink;
19-
}
20-
21-
logger::~logger() {
22-
// printf("DEBUG %s destructor (%s,%d).\n", __FUNCTION__, __FILE__, __LINE__);
23-
if (_sink != NULL) {
24-
delete _sink;
25-
}
17+
logger::logger(const std::string &name, sink *sink) : _name (name) {
18+
_sink.reset(sink);
2619
}
2720

2821
std::string logger::ecid() {

0 commit comments

Comments
 (0)