mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 07:00:17 -05:00
#4683 clang-format on all files in ApplicationCode
This commit is contained in:
1 parent
3a317504bb
commit
fe9e567825
2092 files changed
+117952
-111846
No files matched your search
@@ -1,17 +1,17 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017 Statoil ASA
|
||||
//
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -22,26 +22,24 @@
|
||||
#include <sstream>
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4668)
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4668 )
|
||||
// Define this one to tell windows.h to not define min() and max() as macros
|
||||
#if defined WIN32 && !defined NOMINMAX
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#pragma warning (pop)
|
||||
#pragma warning( pop )
|
||||
#else
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#endif
|
||||
|
||||
#include "QString"
|
||||
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RiaDefaultConsoleLogger : public RiaLogger
|
||||
@@ -49,33 +47,31 @@ class RiaDefaultConsoleLogger : public RiaLogger
|
||||
public:
|
||||
RiaDefaultConsoleLogger();
|
||||
|
||||
int level() const override;
|
||||
void setLevel(int logLevel) override;
|
||||
void error( const char* message) override;
|
||||
void warning(const char* message) override;
|
||||
void info( const char* message) override;
|
||||
void debug( const char* message) override;
|
||||
int level() const override;
|
||||
void setLevel( int logLevel ) override;
|
||||
void error( const char* message ) override;
|
||||
void warning( const char* message ) override;
|
||||
void info( const char* message ) override;
|
||||
void debug( const char* message ) override;
|
||||
|
||||
private:
|
||||
static void writeMessageToConsole(const char* prefix, const char* message);
|
||||
static void writeToConsole(const std::string& str);
|
||||
static void writeMessageToConsole( const char* prefix, const char* message );
|
||||
static void writeToConsole( const std::string& str );
|
||||
|
||||
private:
|
||||
int m_logLevel;
|
||||
int m_logLevel;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaDefaultConsoleLogger::RiaDefaultConsoleLogger()
|
||||
: m_logLevel(RI_LL_WARNING)
|
||||
: m_logLevel( RI_LL_WARNING )
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RiaDefaultConsoleLogger::level() const
|
||||
{
|
||||
@@ -83,59 +79,56 @@ int RiaDefaultConsoleLogger::level() const
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaDefaultConsoleLogger::setLevel(int logLevel)
|
||||
void RiaDefaultConsoleLogger::setLevel( int logLevel )
|
||||
{
|
||||
m_logLevel = logLevel;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaDefaultConsoleLogger::error(const char* message)
|
||||
void RiaDefaultConsoleLogger::error( const char* message )
|
||||
{
|
||||
writeMessageToConsole("ERROR: ", message);
|
||||
writeMessageToConsole( "ERROR: ", message );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaDefaultConsoleLogger::warning(const char* message)
|
||||
void RiaDefaultConsoleLogger::warning( const char* message )
|
||||
{
|
||||
writeMessageToConsole("warn: ", message);
|
||||
writeMessageToConsole( "warn: ", message );
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaDefaultConsoleLogger::info(const char* message)
|
||||
void RiaDefaultConsoleLogger::info( const char* message )
|
||||
{
|
||||
writeMessageToConsole("info: ", message);
|
||||
writeMessageToConsole( "info: ", message );
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaDefaultConsoleLogger::debug(const char* message)
|
||||
void RiaDefaultConsoleLogger::debug( const char* message )
|
||||
{
|
||||
writeMessageToConsole("debug: ", message);
|
||||
writeMessageToConsole( "debug: ", message );
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaDefaultConsoleLogger::writeMessageToConsole(const char* prefix, const char* message)
|
||||
void RiaDefaultConsoleLogger::writeMessageToConsole( const char* prefix, const char* message )
|
||||
{
|
||||
std::ostringstream oss;
|
||||
|
||||
// VF_ASSERT(prefix);
|
||||
// VF_ASSERT(prefix);
|
||||
oss << prefix;
|
||||
|
||||
if (message)
|
||||
if ( message )
|
||||
{
|
||||
oss << message << std::endl;
|
||||
}
|
||||
@@ -144,54 +137,52 @@ void RiaDefaultConsoleLogger::writeMessageToConsole(const char* prefix, const ch
|
||||
oss << "<no message>" << std::endl;
|
||||
}
|
||||
|
||||
writeToConsole(oss.str());
|
||||
writeToConsole( oss.str() );
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaDefaultConsoleLogger::writeToConsole(const std::string& str)
|
||||
void RiaDefaultConsoleLogger::writeToConsole( const std::string& str )
|
||||
{
|
||||
#ifdef WIN32
|
||||
AllocConsole();
|
||||
HANDLE hStdOutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
if (hStdOutputHandle)
|
||||
HANDLE hStdOutputHandle = GetStdHandle( STD_OUTPUT_HANDLE );
|
||||
if ( hStdOutputHandle )
|
||||
{
|
||||
DWORD stringLength = static_cast<DWORD>(str.length());
|
||||
DWORD stringLength = static_cast<DWORD>( str.length() );
|
||||
|
||||
unsigned long iDum = 0;
|
||||
WriteConsoleA(hStdOutputHandle, str.c_str(), stringLength, &iDum, nullptr);
|
||||
WriteConsoleA( hStdOutputHandle, str.c_str(), stringLength, &iDum, nullptr );
|
||||
}
|
||||
#else
|
||||
fputs(str.c_str(), stderr);
|
||||
fputs( str.c_str(), stderr );
|
||||
#endif
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
|
||||
RiaLogger* RiaLogging::sm_logger = new RiaDefaultConsoleLogger;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaLogger* RiaLogging::loggerInstance()
|
||||
{
|
||||
return sm_logger;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaLogging::setLoggerInstance(RiaLogger* loggerInstance)
|
||||
void RiaLogging::setLoggerInstance( RiaLogger* loggerInstance )
|
||||
{
|
||||
// Only delete if we're currently using our own default impl
|
||||
if (dynamic_cast<RiaDefaultConsoleLogger*>(sm_logger))
|
||||
if ( dynamic_cast<RiaDefaultConsoleLogger*>( sm_logger ) )
|
||||
{
|
||||
delete sm_logger;
|
||||
}
|
||||
@@ -199,9 +190,8 @@ void RiaLogging::setLoggerInstance(RiaLogger* loggerInstance)
|
||||
sm_logger = loggerInstance;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaLogging::deleteLoggerInstance()
|
||||
{
|
||||
@@ -210,50 +200,50 @@ void RiaLogging::deleteLoggerInstance()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaLogging::error(const QString& message)
|
||||
void RiaLogging::error( const QString& message )
|
||||
{
|
||||
if (sm_logger && sm_logger->level() >= RI_LL_ERROR)
|
||||
if ( sm_logger && sm_logger->level() >= RI_LL_ERROR )
|
||||
{
|
||||
#pragma omp critical(critical_section_logging)
|
||||
sm_logger->error(message.toLatin1().constData());
|
||||
#pragma omp critical( critical_section_logging )
|
||||
sm_logger->error( message.toLatin1().constData() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaLogging::warning(const QString& message)
|
||||
void RiaLogging::warning( const QString& message )
|
||||
{
|
||||
if (sm_logger && sm_logger->level() >= RI_LL_WARNING)
|
||||
if ( sm_logger && sm_logger->level() >= RI_LL_WARNING )
|
||||
{
|
||||
#pragma omp critical(critical_section_logging)
|
||||
sm_logger->warning(message.toLatin1().constData());
|
||||
#pragma omp critical( critical_section_logging )
|
||||
sm_logger->warning( message.toLatin1().constData() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaLogging::info(const QString& message)
|
||||
void RiaLogging::info( const QString& message )
|
||||
{
|
||||
if (sm_logger && sm_logger->level() >= RI_LL_INFO)
|
||||
if ( sm_logger && sm_logger->level() >= RI_LL_INFO )
|
||||
{
|
||||
#pragma omp critical(critical_section_logging)
|
||||
sm_logger->info(message.toLatin1().constData());
|
||||
#pragma omp critical( critical_section_logging )
|
||||
sm_logger->info( message.toLatin1().constData() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaLogging::debug(const QString& message)
|
||||
void RiaLogging::debug( const QString& message )
|
||||
{
|
||||
if (sm_logger && sm_logger->level() >= RI_LL_DEBUG)
|
||||
if ( sm_logger && sm_logger->level() >= RI_LL_DEBUG )
|
||||
{
|
||||
#pragma omp critical(critical_section_logging)
|
||||
sm_logger->debug(message.toLatin1().constData());
|
||||
#pragma omp critical( critical_section_logging )
|
||||
sm_logger->debug( message.toLatin1().constData() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,7 +251,7 @@ void RiaLogging::debug(const QString& message)
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuMessageLoggerBase::RiuMessageLoggerBase()
|
||||
: m_logLevel(RI_LL_WARNING)
|
||||
: m_logLevel( RI_LL_WARNING )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -276,7 +266,7 @@ int RiuMessageLoggerBase::level() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMessageLoggerBase::setLevel(int logLevel)
|
||||
void RiuMessageLoggerBase::setLevel( int logLevel )
|
||||
{
|
||||
m_logLevel = logLevel;
|
||||
}
|
||||
@@ -284,45 +274,45 @@ void RiuMessageLoggerBase::setLevel(int logLevel)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMessageLoggerBase::error(const char* message)
|
||||
void RiuMessageLoggerBase::error( const char* message )
|
||||
{
|
||||
writeMessageWithPrefixToLogger("ERROR: ", message);
|
||||
writeMessageWithPrefixToLogger( "ERROR: ", message );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMessageLoggerBase::warning(const char* message)
|
||||
void RiuMessageLoggerBase::warning( const char* message )
|
||||
{
|
||||
writeMessageWithPrefixToLogger("warning: ", message);
|
||||
writeMessageWithPrefixToLogger( "warning: ", message );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMessageLoggerBase::info(const char* message)
|
||||
void RiuMessageLoggerBase::info( const char* message )
|
||||
{
|
||||
writeMessageWithPrefixToLogger("info: ", message);
|
||||
writeMessageWithPrefixToLogger( "info: ", message );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMessageLoggerBase::debug(const char* message)
|
||||
void RiuMessageLoggerBase::debug( const char* message )
|
||||
{
|
||||
writeMessageWithPrefixToLogger("debug: ", message);
|
||||
writeMessageWithPrefixToLogger( "debug: ", message );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMessageLoggerBase::writeMessageWithPrefixToLogger(const char* prefix, const char* message)
|
||||
void RiuMessageLoggerBase::writeMessageWithPrefixToLogger( const char* prefix, const char* message )
|
||||
{
|
||||
std::ostringstream oss;
|
||||
|
||||
oss << prefix;
|
||||
|
||||
if (message)
|
||||
if ( message )
|
||||
{
|
||||
oss << message << std::endl;
|
||||
}
|
||||
@@ -331,13 +321,13 @@ void RiuMessageLoggerBase::writeMessageWithPrefixToLogger(const char* prefix, co
|
||||
oss << "<no message>" << std::endl;
|
||||
}
|
||||
|
||||
writeMessageToLogger(oss.str());
|
||||
writeMessageToLogger( oss.str() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaStdOutLogger::writeMessageToLogger(const std::string& str)
|
||||
void RiaStdOutLogger::writeMessageToLogger( const std::string& str )
|
||||
{
|
||||
std::cout << str;
|
||||
}
|
||||
Reference in new issue
Block a user