mirror of
https://github.com/KjellKod/g3log.git
synced 2024-12-12 10:23:50 +01:00
Cosmetics: Corrected headers so that they look uniform. Added clarification in Readme about unpacking of gtest/glog for unit-test and performance tests
This commit is contained in:
parent
76bde84300
commit
6d5f1f46ca
3
README
3
README
@ -45,7 +45,8 @@ CONTENTS
|
||||
3rdParty -- gtest, glog.
|
||||
-----------------------
|
||||
Both are needed to compile the unit test and the logger comparison tests
|
||||
gtest is included by the CMake and you don't need to do anything with it.
|
||||
Gtest must be unpacked before used, but it IS included by the CMake and you don't need to do install or compile it in any other way than through the g2log cmake setup.
|
||||
|
||||
glog is not included and must be installed if you want to run the comparison tests
|
||||
|
||||
|
||||
|
@ -1,7 +1,13 @@
|
||||
# CMakeLists.txt cmake configuration for g2log test
|
||||
# g2log is a KjellKod Logger
|
||||
# 2011 @author Kjell Hedström, hedstrom@kjellkod.cc */
|
||||
#
|
||||
# / #==================================================================
|
||||
# 2010 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.
|
||||
* =====================================================================*/
|
||||
|
||||
# Below are details for compiling on Windows and Linux
|
||||
# by default only an example g2log binary is created
|
||||
|
@ -1,4 +1,5 @@
|
||||
/** 2010 by KjellKod.cc. This is PUBLIC DOMAIN to use at your own risk and comes
|
||||
/** ==========================================================================
|
||||
* 2010 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.
|
||||
* ============================================================================
|
||||
|
@ -1,6 +1,10 @@
|
||||
#ifndef CRASH_HANDLER_H_
|
||||
#define CRASH_HANDLER_H_
|
||||
|
||||
/** ==========================================================================
|
||||
* 2011 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 <string>
|
||||
#include <csignal>
|
||||
|
||||
|
@ -1,3 +1,9 @@
|
||||
/** ==========================================================================
|
||||
* 2011 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 "crashhandler.h"
|
||||
#include "g2log.h"
|
||||
|
||||
|
@ -1,3 +1,9 @@
|
||||
/** ==========================================================================
|
||||
* 2011 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 "crashhandler.h"
|
||||
#include "g2log.h"
|
||||
|
||||
|
@ -1,4 +1,9 @@
|
||||
/* *************************************************
|
||||
/** ==========================================================================
|
||||
* 2011 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.
|
||||
* ============================================================================
|
||||
*
|
||||
* Filename:g2log.cpp Framework for Logging and Design By Contract
|
||||
* Created: 2011 by Kjell Hedström
|
||||
*
|
||||
|
@ -1,4 +1,9 @@
|
||||
/* *************************************************
|
||||
/** ==========================================================================
|
||||
* 2011 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.
|
||||
* ============================================================================
|
||||
*
|
||||
* Filename:g2log.h Framework for Logging and Design By Contract
|
||||
* Created: 2011 by Kjell Hedström
|
||||
*
|
||||
|
@ -1,4 +1,8 @@
|
||||
/* *************************************************
|
||||
/** ==========================================================================
|
||||
* 2011 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.
|
||||
* ============================================================================
|
||||
* Filename:g2LogWorker.cpp Framework for Logging and Design By Contract
|
||||
* Created: 2011 by Kjell Hedström
|
||||
*
|
||||
|
@ -1,12 +1,17 @@
|
||||
#ifndef G2_LOG_WORKER_H_
|
||||
#define G2_LOG_WORKER_H_
|
||||
|
||||
/* *************************************************
|
||||
/** ==========================================================================
|
||||
* 2011 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.
|
||||
* ============================================================================
|
||||
* Filename:g2logworker.h Framework for Logging and Design By Contract
|
||||
* Created: 2011 by Kjell Hedström
|
||||
*
|
||||
* PUBLIC DOMAIN and Not copywrited. First published at KjellKod.cc
|
||||
* ********************************************* */
|
||||
|
||||
|
||||
#include <memory>
|
||||
#include "g2log.h"
|
||||
|
||||
|
@ -1,66 +0,0 @@
|
||||
/* *************************************************
|
||||
* Filename: main.cpp
|
||||
* Created: 2011 by Kjell Hedström
|
||||
*
|
||||
* PUBLIC DOMAIN and Not copy-writed
|
||||
* ********************************************* */
|
||||
|
||||
#include "g2logworker.h"
|
||||
#include "g2log.h"
|
||||
#include <iomanip>
|
||||
|
||||
namespace
|
||||
{
|
||||
#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__))
|
||||
const std::string path_to_log_file = "./";
|
||||
#else
|
||||
const std::string path_to_log_file = "/tmp/";
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
double pi_d = 3.1415926535897932384626433832795;
|
||||
float pi_f = 3.1415926535897932384626433832795f;
|
||||
|
||||
|
||||
g2LogWorker logger(argv[0], path_to_log_file);
|
||||
g2::initializeLogging(&logger);
|
||||
|
||||
LOGF(INFO, "Hi log %d", 123);
|
||||
LOG(INFO) << "Test SLOG INFO";
|
||||
LOG(DEBUG) << "Test SLOG DEBUG";
|
||||
LOG(INFO) << "one: " << 1;
|
||||
LOG(INFO) << "two: " << 2;
|
||||
LOG(INFO) << "one and two: " << 1 << " and " << 2;
|
||||
LOG(DEBUG) << "float 2.14: " << 1000/2.14f;
|
||||
LOG(DEBUG) << "pi double: " << pi_d;
|
||||
LOG(DEBUG) << "pi float: " << pi_f;
|
||||
LOG(DEBUG) << "pi float (width 10): " << std::setprecision(10) << pi_f;
|
||||
LOGF(INFO, "pi float printf:%f", pi_f);
|
||||
|
||||
//
|
||||
// START: LOG Entris that were in the article
|
||||
//
|
||||
//LOG(UNKNOWN_LEVEL) << "This log attempt will cause a compiler error";
|
||||
LOG(INFO) << "Simple to use with streaming syntax, easy as abc or " << 123;
|
||||
LOGF(WARNING, "Printf-style syntax is also %s", "available");
|
||||
LOG_IF(INFO, (1 < 2)) << "If true this text will be logged";
|
||||
LOGF_IF(INFO, (1<2), "if %d<%d : then this text will be logged", 1,2);
|
||||
LOG_IF(FATAL, (2>3)) << "This message should NOT throw";
|
||||
LOGF(DEBUG, "This API is popular with some %s", "programmers");
|
||||
LOGF_IF(DEBUG, (1<2), "If true, then this %s will be logged", "message");
|
||||
{
|
||||
const std::string logging = "logging";
|
||||
// OK --- this WILL get a compiler warning
|
||||
LOGF(DEBUG, "ILLEGAL PRINTF_SYNTAX EXAMPLE. WILL GENERATE compiler warning.\n\nbadly formatted message:[Printf-type %s is the number 1 for many %s]", logging.c_str());
|
||||
}
|
||||
|
||||
|
||||
std::cout << "\n\n***** Be ready this last example will 'abort' " << std::endl;
|
||||
std::cout << "***** please theck the logfile for all the LOGS and compare them to this example" << std::endl;
|
||||
std::cout << "***** this file is g2log/src/main.cpp. The log file is: " << logger.logFileName() << std::endl;
|
||||
std::cout << "************************************************************\n\n" << std::endl;
|
||||
CHECK(1<2) << "SHOULD NOT SEE THIS MESSAGE";
|
||||
CHECK(1>2) << "Test to see if contract works: onetwothree: " << 123 << ". This should be at the end of the log, and will exit this example";
|
||||
}
|
@ -1,9 +1,8 @@
|
||||
/* *************************************************
|
||||
* Filename: main.cpp
|
||||
* Created: 2011 by Kjell Hedström
|
||||
*
|
||||
* PUBLIC DOMAIN and Not copy-writed
|
||||
* ********************************************* */
|
||||
/** ==========================================================================
|
||||
* 2011 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 "g2logworker.h"
|
||||
#include "g2log.h"
|
||||
|
@ -1,9 +1,8 @@
|
||||
/* *************************************************
|
||||
// * Filename: g2log-main_mean.cpp
|
||||
// * Created: 2011 by Kjell Hedström
|
||||
// *
|
||||
// * PUBLIC DOMAIN and Not copy-writed
|
||||
// * ********************************************* */
|
||||
/** ==========================================================================
|
||||
* 2011 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.
|
||||
* ============================================================================*/
|
||||
|
||||
// through CMakeLists.txt #define of GOOGLE_GLOG_PERFORMANCE and G2LOG_PERFORMANCE
|
||||
#include "performance.h"
|
||||
|
@ -1,9 +1,8 @@
|
||||
/* *************************************************
|
||||
// * Filename: g2log-main_mean.cpp
|
||||
// * Created: 2011 by Kjell Hedström
|
||||
// *
|
||||
// * PUBLIC DOMAIN and Not copy-writed
|
||||
// * ********************************************* */
|
||||
/** ==========================================================================
|
||||
* 2011 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.
|
||||
* ============================================================================*/
|
||||
|
||||
// through CMakeLists.txt #define of GOOGLE_GLOG_PERFORMANCE and G2LOG_PERFORMANCE
|
||||
#include "performance.h"
|
||||
|
@ -1,8 +1,8 @@
|
||||
/* *************************************************
|
||||
* Filename: performance_io.cpp
|
||||
* Created: 2011 by Kjell Hedström
|
||||
*
|
||||
* PUBLIC DOMAIN and Not copy-writed
|
||||
/** ==========================================================================
|
||||
* 2011 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.
|
||||
* ============================================================================*/
|
||||
* ********************************************* */
|
||||
|
||||
#ifndef PERFORMANCE_G2_TEST_H_
|
||||
|
@ -1,9 +1,8 @@
|
||||
/* *************************************************
|
||||
* Filename: test_io.cpp
|
||||
* Created: 2011 by Kjell Hedström
|
||||
*
|
||||
* PUBLIC DOMAIN and Not copy-writed
|
||||
* ********************************************* */
|
||||
/** ==========================================================================
|
||||
* 2011 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 "g2log.h"
|
||||
|
@ -1,9 +1,8 @@
|
||||
/* *************************************************
|
||||
* Filename:test_main.cpp Framework for Logging and Design By Contract
|
||||
* Created: 2011 by Kjell Hedström
|
||||
*
|
||||
* PUBLIC DOMAIN and Not copywrited. First published at KjellKod.cc
|
||||
* ********************************************* */
|
||||
/** ==========================================================================
|
||||
* 2011 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 <iostream>
|
||||
|
Loading…
Reference in New Issue
Block a user