Форматирование кода

This commit is contained in:
Andrei Astafev 2019-10-21 20:35:50 +03:00
parent 671f0f3ec4
commit 18ecd62eb7
7 changed files with 57 additions and 57 deletions

View File

@ -63,16 +63,16 @@ Paths::Paths()
{ {
m_prefixDirectory = "/opt/" + QCoreApplication::organizationName().toLower() + m_prefixDirectory = "/opt/" + QCoreApplication::organizationName().toLower() +
"/" + QCoreApplication::applicationName().toLower(); "/" + QCoreApplication::applicationName().toLower();
m_binaryDirectory = m_prefixDirectory.absolutePath() + "/bin"; m_binaryDirectory = m_prefixDirectory.absolutePath() + "/bin";
m_configDirectory = m_prefixDirectory.absolutePath() + "/etc"; m_configDirectory = m_prefixDirectory.absolutePath() + "/etc";
m_cacheDirectory = m_prefixDirectory.absolutePath() + "/var"; m_cacheDirectory = m_prefixDirectory.absolutePath() + "/var";
m_tempDirectory = QString::fromLocal8Bit( qgetenv( qPrintable( "TMPDIR" ) ) ); m_tempDirectory = QString::fromLocal8Bit( qgetenv( qPrintable( "TMPDIR" ) ) );
m_dataDirectory = m_prefixDirectory.absolutePath() + "/share"; m_dataDirectory = m_prefixDirectory.absolutePath() + "/share";
m_homeDirectory = QString::fromLocal8Bit( qgetenv( qPrintable( "HOME" ) ) ); m_homeDirectory = QString::fromLocal8Bit( qgetenv( qPrintable( "HOME" ) ) );
m_executableFileName = QCoreApplication::applicationName().toLower(); m_executableFileName = QCoreApplication::applicationName().toLower();
m_configFileName = m_executableFileName + ".conf"; m_configFileName = m_executableFileName + ".conf";
m_executableFilePath = m_binaryDirectory.absolutePath() + "/" + m_executableFileName; m_executableFilePath = m_binaryDirectory.absolutePath() + "/" + m_executableFileName;
m_configFilePath = m_binaryDirectory.absolutePath() + "/" + m_configFileName; m_configFilePath = m_binaryDirectory.absolutePath() + "/" + m_configFileName;
if ( m_tempDirectory.absolutePath().isEmpty() || ( m_tempDirectory.path() == "." ) ) if ( m_tempDirectory.absolutePath().isEmpty() || ( m_tempDirectory.path() == "." ) )
@ -159,17 +159,17 @@ bool Paths::updatePaths()
whereami::whereami_path_t executablePath = whereami::getExecutablePath(); whereami::whereami_path_t executablePath = whereami::getExecutablePath();
m_executableFileName = QString::fromStdString( executablePath.basename() ); m_executableFileName = QString::fromStdString( executablePath.basename() );
m_binaryDirectory = QString::fromStdString( executablePath.dirname() ); m_binaryDirectory = QString::fromStdString( executablePath.dirname() );
m_executableFilePath = QFile( m_binaryDirectory.absolutePath() + "/" + m_executableFileName ); m_executableFilePath = QFile( m_binaryDirectory.absolutePath() + "/" + m_executableFileName );
if ( m_binaryDirectory.absolutePath().endsWith( "/bin" ) ) if ( m_binaryDirectory.absolutePath().endsWith( "/bin" ) )
{ {
m_prefixDirectory = m_binaryDirectory.absolutePath().remove( QRegExp( "/bin$" ) ); m_prefixDirectory = m_binaryDirectory.absolutePath().remove( QRegExp( "/bin$" ) );
m_configDirectory = m_prefixDirectory.absolutePath() + "/etc"; m_configDirectory = m_prefixDirectory.absolutePath() + "/etc";
m_cacheDirectory = m_prefixDirectory.absolutePath() + "/var"; m_cacheDirectory = m_prefixDirectory.absolutePath() + "/var";
m_dataDirectory = m_prefixDirectory.absolutePath() + "/share"; m_dataDirectory = m_prefixDirectory.absolutePath() + "/share";
m_configFilePath = QFile( m_configDirectory.absolutePath() + "/" + m_configFilePath = QFile( m_configDirectory.absolutePath() + "/" +
QCoreApplication::applicationName() + ".conf" ); QCoreApplication::applicationName() + ".conf" );
} }
if ( m_prefixDirectory.absolutePath().startsWith( "/opt" ) || if ( m_prefixDirectory.absolutePath().startsWith( "/opt" ) ||

View File

@ -11,15 +11,15 @@ namespace filesystem {
class Paths class Paths
{ {
QDir m_prefixDirectory; QDir m_prefixDirectory;
QDir m_binaryDirectory; QDir m_binaryDirectory;
QDir m_configDirectory; QDir m_configDirectory;
QDir m_cacheDirectory; QDir m_cacheDirectory;
QDir m_tempDirectory; QDir m_tempDirectory;
QDir m_dataDirectory; QDir m_dataDirectory;
QDir m_homeDirectory; QDir m_homeDirectory;
QString m_executableFileName; QString m_executableFileName;
QString m_configFileName; QString m_configFileName;
QFileInfo m_executableFilePath; QFileInfo m_executableFilePath;
QFileInfo m_configFilePath; QFileInfo m_configFilePath;

View File

@ -51,7 +51,7 @@ int getExecutablePath( char* out, int capacity, int* dirname_length )
{ {
char buffer[PATH_MAX]; char buffer[PATH_MAX];
char* resolved = nullptr; char* resolved = nullptr;
int length = -1; int length = -1;
for (;; ) for (;; )
{ {
@ -234,16 +234,16 @@ whereami_path_t::operator const whereami_string_t&() const
#endif // if defined( WHEREAMI_CXX11 ) #endif // if defined( WHEREAMI_CXX11 )
#if defined( WHEREAMI_CXX11 ) #if defined( WHEREAMI_CXX11 )
whereami_path_t::whereami_path_t( whereami_string_t&& path, int dirname_length ) noexcept whereami_path_t::whereami_path_t( whereami_string_t&& path, int dirname_length ) noexcept :
: m_path( std::move( path ) ), m_path ( std::move( path ) ),
m_dirnameLength( dirname_length ) m_dirnameLength( dirname_length )
{ {
} }
#else #else
whereami_path_t::whereami_path_t( whereami_string_t& path, int dirname_length ) whereami_path_t::whereami_path_t( whereami_string_t& path, int dirname_length ) :
: m_path( path ), m_path ( path ),
m_dirnameLength( dirname_length ) m_dirnameLength( dirname_length )
{ {
} }

View File

@ -103,7 +103,7 @@ private:
#endif #endif
whereami_string_t m_path; whereami_string_t m_path;
int m_dirnameLength; int m_dirnameLength;
}; // class whereami_path_t }; // class whereami_path_t
/** /**

View File

@ -9,21 +9,21 @@ Logger default_logger( "default" );
Logger::Logger( std::string name ) : Logger::Logger( std::string name ) :
m_logger( nullptr ), m_logger ( nullptr ),
m_name( std::move( name ) ), m_name ( std::move( name ) ),
m_outputPattern( "[%H:%M:%S %z] [%n] [%^---%L---%$] %v" ), m_outputPattern ( "[%H:%M:%S %z] [%n] [%^---%L---%$] %v" ),
m_baseFileName( "default" ), m_baseFileName ( "default" ),
m_maxRotatingFileSize( rotatingFileSize ), m_maxRotatingFileSize ( rotatingFileSize ),
m_maxRotatingFilesCount( 3 ), m_maxRotatingFilesCount( 3 ),
m_outputLevel( spdlog::level::trace ), m_outputLevel ( spdlog::level::trace ),
m_flushLevel( spdlog::level::warn ), m_flushLevel ( spdlog::level::warn ),
m_nullSink( nullptr ), m_nullSink ( nullptr ),
m_stdoutSink( nullptr ), m_stdoutSink ( nullptr ),
m_stderrSink( nullptr ), m_stderrSink ( nullptr ),
m_syslogSink( nullptr ), m_syslogSink ( nullptr ),
m_basicFileSink( nullptr ), m_basicFileSink ( nullptr ),
m_rotatingFileSink( nullptr ), m_rotatingFileSink ( nullptr ),
m_dailyFileSink( nullptr ) m_dailyFileSink ( nullptr )
{ {
m_logger = std::make_shared< spdlog::logger >( m_name, nullptr ); m_logger = std::make_shared< spdlog::logger >( m_name, nullptr );
m_logger->sinks().clear(); m_logger->sinks().clear();
@ -235,7 +235,7 @@ void Logger::enableDailyFileSink()
{ {
if ( m_dailyFileSink == nullptr ) if ( m_dailyFileSink == nullptr )
{ {
const int rotationHour = 23; const int rotationHour = 23;
const int rotationMinute = 59; const int rotationMinute = 59;
m_dailyFileSink = std::make_shared< spdlog::sinks::daily_file_sink_st >( m_baseFileName, rotationHour, rotationMinute ); m_dailyFileSink = std::make_shared< spdlog::sinks::daily_file_sink_st >( m_baseFileName, rotationHour, rotationMinute );
m_logger->sinks().push_back( m_dailyFileSink ); m_logger->sinks().push_back( m_dailyFileSink );

View File

@ -16,21 +16,21 @@ const size_t rotatingFileSize = 256 * 1024;
class Logger class Logger
{ {
std::shared_ptr< spdlog::logger > m_logger; std::shared_ptr< spdlog::logger > m_logger;
std::string m_name; std::string m_name;
std::string m_outputPattern; std::string m_outputPattern;
std::string m_baseFileName; std::string m_baseFileName;
std::size_t m_maxRotatingFileSize; std::size_t m_maxRotatingFileSize;
std::size_t m_maxRotatingFilesCount; std::size_t m_maxRotatingFilesCount;
spdlog::level::level_enum m_outputLevel; spdlog::level::level_enum m_outputLevel;
spdlog::level::level_enum m_flushLevel; spdlog::level::level_enum m_flushLevel;
std::shared_ptr< spdlog::sinks::null_sink_st > m_nullSink; std::shared_ptr< spdlog::sinks::null_sink_st > m_nullSink;
std::shared_ptr< spdlog::sinks::ansicolor_stdout_sink_st > m_stdoutSink; std::shared_ptr< spdlog::sinks::ansicolor_stdout_sink_st > m_stdoutSink;
std::shared_ptr< spdlog::sinks::ansicolor_stderr_sink_st > m_stderrSink; std::shared_ptr< spdlog::sinks::ansicolor_stderr_sink_st > m_stderrSink;
std::shared_ptr< spdlog::sinks::syslog_sink_st > m_syslogSink; std::shared_ptr< spdlog::sinks::syslog_sink_st > m_syslogSink;
std::shared_ptr< spdlog::sinks::basic_file_sink_st > m_basicFileSink; std::shared_ptr< spdlog::sinks::basic_file_sink_st > m_basicFileSink;
std::shared_ptr< spdlog::sinks::rotating_file_sink_st > m_rotatingFileSink; std::shared_ptr< spdlog::sinks::rotating_file_sink_st > m_rotatingFileSink;
std::shared_ptr< spdlog::sinks::daily_file_sink_st > m_dailyFileSink; std::shared_ptr< spdlog::sinks::daily_file_sink_st > m_dailyFileSink;
public: public:
Logger( std::string name ); Logger( std::string name );

View File

@ -37,7 +37,7 @@ void spdlog_qt_message_handler( QtMsgType type, const QMessageLogContext& contex
QCoreApplication::exit( 1 ); QCoreApplication::exit( 1 );
break; break;
} }
} // messageHandler } // messageHandler
} // namespace log } // namespace log