pwn++  0.1.4
A (toy) Windows & Linux pwn library to play with modern C++.
Log.hpp File Reference

Logging header: Wide string support on linux is at best flaky, so only Windows version gets both string and wide string support. Linux gets only regular string support. More...

#include <format>
#include <source_location>
#include <sstream>
#include <string_view>
#include "Common.hpp"

Go to the source code of this file.

Macros

#define PWN_COLOR_RESET   ""
 
#define PWN_COLOR_BOLD   ""
 
#define PWN_COLOR_UNDERLINE   ""
 
#define PWN_COLOR_FG_BLACK   ""
 
#define PWN_COLOR_FG_RED   ""
 
#define PWN_COLOR_FG_GREEN   ""
 
#define PWN_COLOR_FG_YELLOW   ""
 
#define PWN_COLOR_FG_BLUE   ""
 
#define PWN_COLOR_FG_MAGENTA   ""
 
#define PWN_COLOR_FG_CYAN   ""
 
#define PWN_COLOR_FG_WHITE   ""
 
#define PWN_LOG_STRINGS_DEBUG   "[ DEBUG ] "
 
#define PWN_LOG_STRINGS_INFO   "[ INFO ] "
 
#define PWN_LOG_STRINGS_SUCCESS   "[ SUCCESS ] "
 
#define PWN_LOG_STRINGS_WARN   "[ WARN ] "
 
#define PWN_LOG_STRINGS_ERROR   "[ ERROR ] "
 
#define PWN_LOG_STRINGS_CRITICAL   "[ CRITICAL ] "
 
#define dbg(...)   Log::Log(Log::LogLevel::Debug, std::source_location::current(), ##__VA_ARGS__)
 
#define info(...)   Log::Log(Log::LogLevel::Info, std::source_location::current(), ##__VA_ARGS__)
 
#define ok(...)   Log::Log(Log::LogLevel::Success, std::source_location::current(), ##__VA_ARGS__)
 
#define warn(...)   Log::Log(Log::LogLevel::Warning, std::source_location::current(), ##__VA_ARGS__)
 
#define err(...)   Log::Log(Log::LogLevel::Error, std::source_location::current(), ##__VA_ARGS__)
 

Enumerations

enum class  pwn::Log::LogLevel : u8 {
  Debug , Info , Success , Warning ,
  Error , Critical
}
 Define the logging level. More...
 

Functions

void pwn::Log::Log (const LogLevel level, std::source_location const &location, std::ostringstream &msg)
 Print an output string stream as a log message. More...
 
template<typename... Args>
void pwn::Log::Log (const LogLevel level, std::source_location const &location, std::string_view const &fmt, Args &&... args)
 Generic logging function with prefix and arguments, for strings Note: prefer using the macros dbg, info, ok, warn and err More...
 
void pwn::Log::Log (const LogLevel level, std::source_location const &location, std::wostringstream &msg)
 
template<typename... Args>
void pwn::Log::Log (const LogLevel level, std::source_location const &location, std::wstring_view const &fmt, Args &&... args)
 Generic logging function with prefix and arguments, for wide strings Note: prefer using the macros dbg, info, ok, warn and err More...
 

Detailed Description

Logging header: Wide string support on linux is at best flaky, so only Windows version gets both string and wide string support. Linux gets only regular string support.

Macro Definition Documentation

◆ dbg

#define dbg (   ...)    Log::Log(Log::LogLevel::Debug, std::source_location::current(), ##__VA_ARGS__)

Convenience logging macros

Enumeration Type Documentation

◆ LogLevel

enum pwn::Log::LogLevel : u8
strong

Define the logging level.

Enumerator
Debug 

Debug logging level

Info 

Info logging level

Success 

Success logging level

Warning 

Warning logging level

Error 

Error logging level

Critical 

Critical logging level

Function Documentation

◆ Log() [1/4]

void pwn::Log::Log ( const LogLevel  level,
std::source_location const &  location,
std::ostringstream &  msg 
)

Print an output string stream as a log message.

Parameters
level
location
msg

◆ Log() [2/4]

template<typename... Args>
void pwn::Log::Log ( const LogLevel  level,
std::source_location const &  location,
std::string_view const &  fmt,
Args &&...  args 
)

Generic logging function with prefix and arguments, for strings Note: prefer using the macros dbg, info, ok, warn and err

Parameters
[in]level
[in]location
[in]fmt
[in]args

◆ Log() [3/4]

void pwn::Log::Log ( const LogLevel  level,
std::source_location const &  location,
std::wostringstream &  msg 
)
Parameters
level
location
msg

◆ Log() [4/4]

template<typename... Args>
void pwn::Log::Log ( const LogLevel  level,
std::source_location const &  location,
std::wstring_view const &  fmt,
Args &&...  args 
)

Generic logging function with prefix and arguments, for wide strings Note: prefer using the macros dbg, info, ok, warn and err

Parameters
[in]level
[in]location
[in]fmt
[in]args