MCPcopy Create free account
hub / github.com/OpenVR-Advanced-Settings/OpenVR-AdvancedSettings / setUpLogging

Function setUpLogging

src/utils/setup.cpp:300–355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

298} // namespace manifest
299
300void setUpLogging()
301{
302 el::Loggers::addFlag( el::LoggingFlag::DisableApplicationAbortOnFatalLog );
303
304 el::Configurations conf;
305 conf.setToDefault();
306
307 using el::ConfigurationType;
308 using el::Level;
309
310 conf.set( Level::Global,
311 ConfigurationType::Format,
312 "[%level] %datetime{%Y-%M-%d %H:%m:%s}: %msg" );
313 constexpr auto logFileName = "AdvancedSettings.log";
314 conf.set( Level::Global, ConfigurationType::Filename, logFileName );
315
316 constexpr auto confEnabled = "true";
317 conf.set( Level::Global, ConfigurationType::Enabled, confEnabled );
318 conf.set( Level::Global, ConfigurationType::ToFile, confEnabled );
319 conf.set( Level::Global, ConfigurationType::ToStandardOutput, confEnabled );
320
321 constexpr auto TwoMegabytesInBytes = "2097152";
322 conf.set(
323 Level::Global, ConfigurationType::MaxLogFileSize, TwoMegabytesInBytes );
324
325 constexpr auto confDisabled = "false";
326 conf.set( Level::Trace, ConfigurationType::Enabled, confDisabled );
327
328 if constexpr ( debugLoggingEnabled )
329 {
330 conf.set( Level::Debug, ConfigurationType::Enabled, confEnabled );
331 }
332 else
333 {
334 conf.set( Level::Debug, ConfigurationType::Enabled, confDisabled );
335 }
336
337 const auto appDataLocation
338 = std::string( "/" ) + application_strings::applicationOrganizationName
339 + "/";
340 const auto logFilePath
341 = QDir( QString::fromStdString( *paths::settingsDirectory() )
342 + appDataLocation.c_str() )
343 .absoluteFilePath( logFileName );
344 conf.set( el::Level::Global,
345 el::ConfigurationType::Filename,
346 QDir::toNativeSeparators( logFilePath ).toStdString() );
347
348 conf.setRemainingToDefault();
349
350 el::Loggers::reconfigureAllLoggers( conf );
351
352 LOG( INFO ) << "Application started (Version "
353 << application_strings::applicationVersionString << ")";
354 LOG( INFO ) << "Log File: " << logFilePath;
355}

Callers 1

mainFunction · 0.85

Calls 5

addFlagFunction · 0.85
settingsDirectoryFunction · 0.85
setToDefaultMethod · 0.80
setMethod · 0.80
setRemainingToDefaultMethod · 0.80

Tested by

no test coverage detected