ArkScript
A small, lisp-inspired, functional scripting language
Ark::internal::Logger Class Reference

#include <Logger.hpp>

Collaboration diagram for Ark::internal::Logger:
[legend]

Classes

struct  MessageAndLocation
 

Public Member Functions

 Logger (std::string name, unsigned debug_level)
 Construct a new Logger object.
 
unsigned debugLevel () const
 
bool shouldInfo () const
 
bool shouldDebug () const
 
bool shouldTrace () const
 
template<typename... Args>
void info (const char *fmt, Args &&... args)
 Write an info level log using fmtlib.
 
template<typename... Args>
void warn (const char *fmt, Args &&... args)
 Write a warn level log using fmtlib.
 
template<typename... Args>
void debug (const Logger::MessageAndLocation &data, Args &&... args)
 Write a debug level log using fmtlib.
 
void traceStart (std::string &&trace_name)
 
void traceEnd ()
 
template<typename... Args>
void trace (const char *fmt, Args &&... args)
 Write a trace level log using fmtlib.
 
void configureOutputStream (std::ostream *os)
 Set a custom output stream to use for warnings. This will disable colors.
 
bool colorize () const noexcept
 Check if logs can be colorized.
 

Private Attributes

unsigned m_debug
 
std::string m_name
 
fmt::color m_pass_color
 
std::unordered_map< std::string, std::chrono::time_point< std::chrono::high_resolution_clock > > m_trace_starts
 
std::vector< std::string > m_active_traces
 
std::ostream * m_stream
 

Detailed Description

Definition at line 27 of file Logger.hpp.

Constructor & Destructor Documentation

◆ Logger()

Ark::internal::Logger::Logger ( std::string name,
unsigned debug_level )

Construct a new Logger object.

Parameters
namethe pass name, used for logging
debug_leveldebug level

Definition at line 29 of file Logger.cpp.

References Ark::internal::colors, m_name, and m_pass_color.

Member Function Documentation

◆ colorize()

bool Ark::internal::Logger::colorize ( ) const
inlinenoexcept

Check if logs can be colorized.

Returns
true if logs can be colorized

Definition at line 157 of file Logger.hpp.

Referenced by Ark::internal::ASTLowerer::warning().

◆ configureOutputStream()

void Ark::internal::Logger::configureOutputStream ( std::ostream * os)
inline

Set a custom output stream to use for warnings. This will disable colors.

Parameters
osoutput stream

Definition at line 147 of file Logger.hpp.

Referenced by Ark::internal::Pass::configureLogger(), and Ark::Welder::redirectLogsTo().

◆ debug()

template<typename... Args>
void Ark::internal::Logger::debug ( const Logger::MessageAndLocation & data,
Args &&... args )
inline

◆ debugLevel()

unsigned Ark::internal::Logger::debugLevel ( ) const
inlinenodiscard

Definition at line 50 of file Logger.hpp.

◆ info()

template<typename... Args>
void Ark::internal::Logger::info ( const char * fmt,
Args &&... args )
inline

Write an info level log using fmtlib.

Template Parameters
Args
Parameters
fmtformat string
args

Definition at line 63 of file Logger.hpp.

Referenced by Ark::Welder::saveBytecodeToFile().

◆ shouldDebug()

bool Ark::internal::Logger::shouldDebug ( ) const
inlinenodiscard

Definition at line 53 of file Logger.hpp.

◆ shouldInfo()

bool Ark::internal::Logger::shouldInfo ( ) const
inlinenodiscard

Definition at line 52 of file Logger.hpp.

◆ shouldTrace()

◆ trace()

template<typename... Args>
void Ark::internal::Logger::trace ( const char * fmt,
Args &&... args )
inline

Write a trace level log using fmtlib.

Template Parameters
Args
Parameters
fmtformat string
args

Definition at line 132 of file Logger.hpp.

Referenced by Ark::internal::MacroProcessor::process(), Ark::internal::NameResolutionPass::process(), and Ark::internal::Optimizer::process().

◆ traceEnd()

◆ traceStart()

◆ warn()

template<typename... Args>
void Ark::internal::Logger::warn ( const char * fmt,
Args &&... args )
inline

Write a warn level log using fmtlib.

Template Parameters
Args
Parameters
fmtformat string
args

Definition at line 80 of file Logger.hpp.

Referenced by Ark::internal::Optimizer::pruneUnusedGlobalVariables(), Formatter::warnIfCommentsWereRemoved(), and Ark::internal::ASTLowerer::warning().

Member Data Documentation

◆ m_active_traces

std::vector<std::string> Ark::internal::Logger::m_active_traces
private

Definition at line 167 of file Logger.hpp.

◆ m_debug

unsigned Ark::internal::Logger::m_debug
private

Definition at line 163 of file Logger.hpp.

◆ m_name

std::string Ark::internal::Logger::m_name
private

Definition at line 164 of file Logger.hpp.

Referenced by Logger().

◆ m_pass_color

fmt::color Ark::internal::Logger::m_pass_color
private

Definition at line 165 of file Logger.hpp.

Referenced by Logger().

◆ m_stream

std::ostream* Ark::internal::Logger::m_stream
private

Definition at line 168 of file Logger.hpp.

◆ m_trace_starts

std::unordered_map<std::string, std::chrono::time_point<std::chrono::high_resolution_clock> > Ark::internal::Logger::m_trace_starts
private

Definition at line 166 of file Logger.hpp.


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