AutoPas  3.0.0
Loading...
Searching...
No Matches
Public Types | Static Public Member Functions | List of all members
autopas::Logger Class Reference

Logger class to provide interface to basic functions of the logger. More...

#include <Logger.h>

Public Types

using LogLevel = spdlog::level::level_enum
 Typealias for log levels.
 

Static Public Member Functions

static std::shared_ptr< spdlog::logger > get ()
 Get the pointer to the spdlog logger.
 
static void create (std::ostream &logOutputStream=std::cout)
 Explicitly initialize/reset the logger to write to an output stream.
 
static void create (const std::string &filename)
 Explicitly initialize/reset the logger to write to a file.
 
static void unregister ()
 Removes the logger from the registry.
 

Detailed Description

Logger class to provide interface to basic functions of the logger.

It manages the lifecycle safely using lazy initialization.

Member Function Documentation

◆ create() [1/2]

static void autopas::Logger::create ( const std::string &  filename)
inlinestatic

Explicitly initialize/reset the logger to write to a file.

Parameters
filenamePath to the log file.

◆ create() [2/2]

static void autopas::Logger::create ( std::ostream &  logOutputStream = std::cout)
inlinestatic

Explicitly initialize/reset the logger to write to an output stream.

Parameters
logOutputStreamStream to write to (default std::cout)

◆ get()

static std::shared_ptr< spdlog::logger > autopas::Logger::get ( )
inlinestatic

Get the pointer to the spdlog logger.

If the logger does not exist yet (e.g., during static initialization), this function will automatically create a default one (std::cout). This guarantees that Logger::get() never returns nullptr.

Returns
Shared pointer to the logger.

◆ unregister()

static void autopas::Logger::unregister ( )
inlinestatic

Removes the logger from the registry.

Usually not needed unless you want to silence leak detectors at the very end of main().


The documentation for this class was generated from the following file: