linc 0.7
Linc is a general-purpose programming language inspired by C
Loading...
Searching...
No Matches
linc::Logger Class Referencefinal

Input/Output utility static class. More...

#include <Logger.hpp>

Public Types

enum class  Type : char { Info , Warning , Error , Debug }
 Enumeration used when logging.
 

Static Public Member Functions

static std::string logTypeToString (Type type)
 Convert logging type enumerator to string (used for printing).
 
static std::string format (std::string_view str, const std::vector< Printable > &_args)
 String formatting utility method, similar to std::format.
 
template<typename... Args>
static std::string format (std::string_view str, Args... args)
 String formatting utility method, similar to std::format.
 
static void println ()
 Print single new-line character.
 
template<typename... Args>
static void print (std::string_view str, Args... args)
 Format a string and print it to stdout.
 
static std::string read (std::string_view prompt="")
 Read string from stdin until return key entered.
 
template<typename... Args>
static void append (std::string &output_string, const std::string &str, Args... args)
 Format a string and append it to the output string.
 
template<typename... Args>
static void println (const std::string &str, Args... args)
 Format a string, append new-line, then print it to stdout.
 
template<typename... Args>
static void println ()
 Prints a new-line character to stdout.
 
template<typename... Args>
static void log (Type type, const std::string &str, Args... args)
 Log a formatted message to stdout, according to its type.
 

Detailed Description

Input/Output utility static class.

Member Function Documentation

◆ append()

template<typename... Args>
static void linc::Logger::append ( std::string & output_string,
const std::string & str,
Args... args )
inlinestatic

Format a string and append it to the output string.

Parameters
output_stringThe output string.
strThe string to be formatted.
...argsThe variadic argument list to format with.

◆ format() [1/2]

template<typename... Args>
static std::string linc::Logger::format ( std::string_view str,
Args... args )
inlinestatic

String formatting utility method, similar to std::format.

Parameters
strThe string to be formatted.
...argsThe variadic argument list to format with.
Returns
The resulting string.

◆ format() [2/2]

std::string linc::Logger::format ( std::string_view str,
const std::vector< Printable > & _args )
static

String formatting utility method, similar to std::format.

Parameters
strThe string to be formatted.
argsThe list of arguments to format with.
Returns
The resulting string.

◆ log()

template<typename... Args>
static void linc::Logger::log ( Type type,
const std::string & str,
Args... args )
inlinestatic

Log a formatted message to stdout, according to its type.

Parameters
typeThe type of message to log (e.g. warning, error).
strThe string to be formatted.
...argsThe variadic argument list to format with.

◆ logTypeToString()

std::string linc::Logger::logTypeToString ( Type type)
static

Convert logging type enumerator to string (used for printing).

Parameters
typeThe enumerator to convert.
Returns
The resulting string.

◆ print()

template<typename... Args>
static void linc::Logger::print ( std::string_view str,
Args... args )
inlinestatic

Format a string and print it to stdout.

Parameters
strThe string to be formatted.
...argsThe variadic argument list to format with.

◆ println() [1/2]

template<typename... Args>
static void linc::Logger::println ( )
inlinestatic

Prints a new-line character to stdout.

Template Parameters
...ArgsPlaceholder template argument (required for function overload).

◆ println() [2/2]

template<typename... Args>
static void linc::Logger::println ( const std::string & str,
Args... args )
inlinestatic

Format a string, append new-line, then print it to stdout.

Parameters
strThe string to be formatted.
...argsThe variadic argument list to format with.

◆ read()

std::string linc::Logger::read ( std::string_view prompt = "")
static

Read string from stdin until return key entered.

Returns
The resulting string, as read from stdin.

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