mirror of
https://github.com/KjellKod/g3log.git
synced 2025-04-16 06:56:41 +02:00
Cleanup, added headers where they were missing. Removed default option ON for unit test.
This commit is contained in:
parent
507ec52c04
commit
fe4862a96b
@ -164,7 +164,7 @@ ENDIF(MSVC)
|
|||||||
|
|
||||||
# 4. unit test for g2log
|
# 4. unit test for g2log
|
||||||
# remember to unzip gtest at g2log/3rdParty/gtest
|
# remember to unzip gtest at g2log/3rdParty/gtest
|
||||||
option (USE_G2LOG_UNIT_TEST "g2log unit tests" ON)
|
option (USE_G2LOG_UNIT_TEST "g2log unit tests" OFF)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
/*
|
/** ==========================================================================
|
||||||
* File: MessageBuilder.cpp
|
* 2013 by KjellKod.cc. This is PUBLIC DOMAIN to use at your own risk and comes
|
||||||
* Author: kjell
|
* with no warranties. This code is yours to share, use and modify with no
|
||||||
*
|
* strings attached and no restrictions or obligations.
|
||||||
* Created on October 26, 2013, 3:45 PM
|
* ============================================================================*/
|
||||||
*/
|
|
||||||
|
|
||||||
//#include "g2log.hpp"
|
|
||||||
#include "g2LogMessageBuilder.hpp"
|
#include "g2LogMessageBuilder.hpp"
|
||||||
#include "g2logmessage.hpp"
|
#include "g2logmessage.hpp"
|
||||||
#include "g2log.hpp"
|
#include "g2log.hpp"
|
||||||
@ -86,4 +84,4 @@ namespace g2 {
|
|||||||
fatalCall(_fatal_message);
|
fatalCall(_fatal_message);
|
||||||
|
|
||||||
}
|
}
|
||||||
} // g2
|
} // g2
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
/*
|
/** ==========================================================================
|
||||||
* File: MessageBuilder.hpp
|
* 2013 by KjellKod.cc. This is PUBLIC DOMAIN to use at your own risk and comes
|
||||||
* Author: kjell
|
* with no warranties. This code is yours to share, use and modify with no
|
||||||
*
|
* strings attached and no restrictions or obligations.
|
||||||
* Created on October 26, 2013, 3:45 PM
|
* ============================================================================*/
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -46,4 +45,4 @@ namespace g2 {
|
|||||||
LogMessagePtr _message;
|
LogMessagePtr _message;
|
||||||
std::ostringstream _stream;
|
std::ostringstream _stream;
|
||||||
};
|
};
|
||||||
} // g2
|
} // g2
|
||||||
|
@ -78,7 +78,7 @@ namespace g2 {
|
|||||||
std::ostringstream ss_entry;
|
std::ostringstream ss_entry;
|
||||||
// Day Month Date Time Year: is written as "%a %b %d %H:%M:%S %Y" and formatted output as : Wed Sep 19 08:28:16 2012
|
// Day Month Date Time Year: is written as "%a %b %d %H:%M:%S %Y" and formatted output as : Wed Sep 19 08:28:16 2012
|
||||||
ss_entry << "\t\tg2log created log at: " << g2::localtime_formatted(g2::systemtime_now(), "%a %b %d %H:%M:%S %Y") << "\n";
|
ss_entry << "\t\tg2log created log at: " << g2::localtime_formatted(g2::systemtime_now(), "%a %b %d %H:%M:%S %Y") << "\n";
|
||||||
ss_entry << "\t\tLOG format: [YYYY/MM/DD hh:mm:ss.uuu* LEVEL FILE:LINE] message\n\n"; // TODO: if(header)
|
ss_entry << "\t\tLOG format: [YYYY/MM/DD hh:mm:ss.uuu* LEVEL FILE:LINE] message\n\n";
|
||||||
return ss_entry.str();
|
return ss_entry.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
//
|
|
||||||
//
|
|
||||||
//#include <g2logmessageimpl.hpp>
|
|
||||||
//#include <g2time.hpp>
|
|
||||||
//#include <mutex>
|
|
||||||
//
|
|
||||||
//namespace {
|
|
||||||
// std::once_flag g_start_time_flag;
|
|
||||||
// g2::steady_time_point g_start_time;
|
|
||||||
//
|
|
||||||
// long microsecondsCounter() {
|
|
||||||
// std::call_once(g_start_time_flag, []() { g_start_time = std::chrono::steady_clock::now(); });
|
|
||||||
// g2::steady_time_point now = std::chrono::steady_clock::now();
|
|
||||||
// return std::chrono::duration_cast<std::chrono::microseconds>(now - g_start_time).count();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// std::string splitFileName(const std::string& str) {
|
|
||||||
// size_t found;
|
|
||||||
// found = str.find_last_of("(/\\");
|
|
||||||
// return str.substr(found + 1);
|
|
||||||
// }
|
|
||||||
//} // anonymous
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//namespace g2 {
|
|
||||||
// LogMessageImpl::LogMessageImpl(const std::string &file, const int line,
|
|
||||||
// const std::string& function, const LEVELS& level)
|
|
||||||
// : _timestamp(g2::systemtime_now())
|
|
||||||
// , _microseconds(microsecondsCounter())
|
|
||||||
// , _file(splitFileName(file)), _line(line), _function(function), _level(level) { }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// LogMessageImpl::LogMessageImpl(const std::string& fatalOsSignalCrashMessage)
|
|
||||||
// : LogMessageImpl({""}, 0, {""}, internal::FATAL_SIGNAL) {
|
|
||||||
// _stream << fatalOsSignalCrashMessage;
|
|
||||||
// }
|
|
||||||
//} // g2
|
|
||||||
//
|
|
||||||
//
|
|
@ -1,40 +0,0 @@
|
|||||||
//// -*- C++ -*-
|
|
||||||
///*
|
|
||||||
// * File: g2logmessageimpl.hpp
|
|
||||||
// * Author: kjell
|
|
||||||
// *
|
|
||||||
// * Created on October 27, 2013, 9:14 PM
|
|
||||||
// */
|
|
||||||
//
|
|
||||||
//#pragma once
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//#include <string>
|
|
||||||
//#include "g2loglevels.hpp"
|
|
||||||
//#include <ctime>
|
|
||||||
//#include <sstream>
|
|
||||||
//
|
|
||||||
//namespace g2 {
|
|
||||||
//struct LogMessageImpl {
|
|
||||||
//
|
|
||||||
// // LOG message constructor
|
|
||||||
// LogMessageImpl(const std::string &file, const int line,
|
|
||||||
// const std::string& function, const LEVELS& level);
|
|
||||||
//
|
|
||||||
// // Fatal OS-Signal constructor
|
|
||||||
// explicit LogMessageImpl(const std::string& fatalOsSignalCrashMessage);
|
|
||||||
//
|
|
||||||
// LogMessageImpl(const LogMessageImpl& copy) = default;
|
|
||||||
// ~LogMessageImpl() = default;
|
|
||||||
//
|
|
||||||
// const std::time_t _timestamp;
|
|
||||||
// const long _microseconds;
|
|
||||||
// const std::string _file;
|
|
||||||
// const int _line;
|
|
||||||
// const std::string _function;
|
|
||||||
// const LEVELS _level;
|
|
||||||
//
|
|
||||||
// std::string _expression; // only with content for CHECK(...) calls
|
|
||||||
// std::ostringstream _stream;
|
|
||||||
//};
|
|
||||||
//}
|
|
@ -1,9 +1,8 @@
|
|||||||
/*
|
/** ==========================================================================
|
||||||
* File: g2moveoncopy.hpp
|
* 2013 by KjellKod.cc. This is PUBLIC DOMAIN to use at your own risk and comes
|
||||||
* Author: kjell
|
* with no warranties. This code is yours to share, use and modify with no
|
||||||
*
|
* strings attached and no restrictions or obligations.
|
||||||
* Created on November 11, 2013, 11:33 PM
|
* ============================================================================*/
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
namespace g2 {
|
namespace g2 {
|
||||||
@ -36,4 +35,4 @@ namespace g2 {
|
|||||||
Moveable release() { return std::move(_move_only); }
|
Moveable release() { return std::move(_move_only); }
|
||||||
};
|
};
|
||||||
|
|
||||||
} // g2
|
} // g2
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
/*
|
/** ==========================================================================
|
||||||
* File: g2sink.ipp
|
* 2013 by KjellKod.cc. This is PUBLIC DOMAIN to use at your own risk and comes
|
||||||
* Author: kjell
|
* with no warranties. This code is yours to share, use and modify with no
|
||||||
*
|
* strings attached and no restrictions or obligations.
|
||||||
* Created on July 21, 2013, 11:27 AM
|
* ============================================================================*/
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef G2SINK_IPP
|
#ifndef G2SINK_IPP
|
||||||
#define G2SINK_IPP
|
#define G2SINK_IPP
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
/*
|
/** ==========================================================================
|
||||||
* File: g2sinkhandle.hpp
|
* 2013 by KjellKod.cc. This is PUBLIC DOMAIN to use at your own risk and comes
|
||||||
* Author: kjell
|
* with no warranties. This code is yours to share, use and modify with no
|
||||||
*
|
* strings attached and no restrictions or obligations.
|
||||||
* Created on July 21, 2013, 11:42 AM
|
* ============================================================================*/
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef G2SINKHANDLE_H
|
#ifndef G2SINKHANDLE_H
|
||||||
#define G2SINKHANDLE_H
|
#define G2SINKHANDLE_H
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
/*
|
/** ==========================================================================
|
||||||
* File: g2sinkwrapper.hpp
|
* 2013 by KjellKod.cc. This is PUBLIC DOMAIN to use at your own risk and comes
|
||||||
* Author: kjell
|
* with no warranties. This code is yours to share, use and modify with no
|
||||||
*
|
* strings attached and no restrictions or obligations.
|
||||||
* Created on July 21, 2013, 11:21 AM
|
* ============================================================================*/
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef G2SINKWRAPPER_HPP
|
#ifndef G2SINKWRAPPER_HPP
|
||||||
#define G2SINKWRAPPER_HPP
|
#define G2SINKWRAPPER_HPP
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
/** ==========================================================================
|
||||||
|
* 2013 by KjellKod.cc. This is PUBLIC DOMAIN to use at your own risk and comes
|
||||||
|
* with no warranties. This code is yours to share, use and modify with no
|
||||||
|
* strings attached and no restrictions or obligations.
|
||||||
|
* ============================================================================*/
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -245,7 +245,6 @@ TEST(LogTest, LOG_IF__FATAL) {
|
|||||||
TEST(LogTest, LOG_IF__FATAL__NO_THROW) {
|
TEST(LogTest, LOG_IF__FATAL__NO_THROW) {
|
||||||
RestoreFileLogger logger(log_directory);
|
RestoreFileLogger logger(log_directory);
|
||||||
LOG_IF(FATAL, (2 > 3)) << "This message%sshould NOT throw";
|
LOG_IF(FATAL, (2 > 3)) << "This message%sshould NOT throw";
|
||||||
logger.reset();
|
|
||||||
ASSERT_FALSE(mockFatalWasCalled());
|
ASSERT_FALSE(mockFatalWasCalled());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
/** ==========================================================================
|
||||||
|
* 2013 by KjellKod.cc. This is PUBLIC DOMAIN to use at your own risk and comes
|
||||||
|
* with no warranties. This code is yours to share, use and modify with no
|
||||||
|
* strings attached and no restrictions or obligations.
|
||||||
|
* ============================================================================*/
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
@ -69,7 +75,6 @@ TEST(ConceptSink, OneHundredSinks) {
|
|||||||
write2.append("Hello to 100 receivers :)");
|
write2.append("Hello to 100 receivers :)");
|
||||||
worker->save(message2);
|
worker->save(message2);
|
||||||
LOG(INFO) << "end message";
|
LOG(INFO) << "end message";
|
||||||
|
|
||||||
logger.reset();
|
logger.reset();
|
||||||
}
|
}
|
||||||
// at the curly brace above the ScopedLogger will go out of scope and all the
|
// at the curly brace above the ScopedLogger will go out of scope and all the
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
/** ==========================================================================
|
||||||
|
* 2013 by KjellKod.cc. This is PUBLIC DOMAIN to use at your own risk and comes
|
||||||
|
* with no warranties. This code is yours to share, use and modify with no
|
||||||
|
* strings attached and no restrictions or obligations.
|
||||||
|
* ============================================================================*/
|
||||||
|
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
/*
|
/** ==========================================================================
|
||||||
* File: test_helper__restore_logger.h
|
* 2013 by KjellKod.cc. This is PUBLIC DOMAIN to use at your own risk and comes
|
||||||
* Author: kjell
|
* with no warranties. This code is yours to share, use and modify with no
|
||||||
*
|
* strings attached and no restrictions or obligations.
|
||||||
* Created on July 13, 2013, 4:46 PM
|
* ============================================================================*/
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user