ArcGIS Procedural Runtime  3.2.10650
List of all members | Public Member Functions | Protected Member Functions
prtx::LogFormatter Class Reference

#include <Log.h>

Public Member Functions

LogFormatterlog (uint32_t const *array, size_t count)
 
 LogFormatter (prt::LogLevel l)
 
 LogFormatter (prt::LogLevel l, const std::string &s)
 
 LogFormatter (prt::LogLevel l, const std::wstring &s)
 
 LogFormatter (prt::LogLevel l, const std::string &s, const std::string &p)
 
 LogFormatter (prt::LogLevel l, const char *s, const char *p=0)
 
 LogFormatter (prt::LogLevel l, const std::wstring &s, const std::wstring &p)
 
 LogFormatter (prt::LogLevel l, const std::wstring &s, const std::string &p)
 
 LogFormatter (prt::LogLevel l, const wchar_t *s, const wchar_t *p=0)
 
 LogFormatter (prt::LogLevel l, const std::exception &e)
 
 LogFormatter (prt::LogLevel l, const std::string &s, const std::exception &e)
 
 LogFormatter (const LogFormatter &)=delete
 
 LogFormatter (LogFormatter &&)=delete
 
LogFormatteroperator% (float x)
 
LogFormatteroperator% (double x)
 
LogFormatteroperator% (long int x)
 
LogFormatteroperator% (std::size_t x)
 
LogFormatteroperator% (uint8_t x)
 
LogFormatteroperator% (uint16_t x)
 
LogFormatteroperator% (uint32_t x)
 
LogFormatteroperator% (uint64_t x)
 
LogFormatteroperator% (int8_t x)
 
LogFormatteroperator% (int16_t x)
 
LogFormatteroperator% (int32_t x)
 
LogFormatteroperator% (int64_t x)
 
LogFormatteroperator% (const char *x)
 
LogFormatteroperator% (const std::string &x)
 
LogFormatteroperator% (const StringVector &x)
 
LogFormatteroperator% (const wchar_t *x)
 
LogFormatteroperator% (const std::wstring &x)
 
LogFormatteroperator% (const WStringVector &x)
 
LogFormatteroperator% (const prt::Status &x)
 
LogFormatteroperator% (const prt::LogLevel &x)
 
LogFormatteroperator% (const URIPtr &x)
 
LogFormatteroperator% (const BoundingBox &x)
 
LogFormatteroperator% (const DoubleVector &x)
 
LogFormatteroperator% (const ReportsPtr &r)
 
LogFormatteroperator% (const std::vector< uint32_t > &v)
 
LogFormatteroperator= (const LogFormatter &)=delete
 
LogFormatteroperator= (LogFormatter &&)=delete
 

Protected Member Functions

std::wstring getMessage () const
 

Detailed Description

LogFormatter is a log message formatter with support for both char and wchar_t arguments. Internally, it uses boost::format syntax to format the log message with "%1%, %2%, ..." syntax. See http://www.boost.org/doc/libs/1_66_0/libs/format/doc/format.html#examples for details.

Each log message has an associated log level. The message will be logged if its level is equal or greater than the globally set log level (see prt::init()).

The logging is triggered when the LogFormatter instance is destroyed, i.e. is going out of scope.

It is recommended to use LogFormatter through these convenience macros (char / wchar_t version):

Important: In order to output log messages to the console or into a log file, a log handler must be added with prt::addLogHandler(). There are two default log handlers for your convenience: prt::ConsoleLogHandler (uses std::wlog/wcout with UTF-16) and prt::FileLogHandler (UTF-8).

A typical use case:

// at initialization time
prt::LogHandler* lh = prt::ConsoleLogHandler::create(prt::LogHandler::ALL, prt::LogHandler::ALL_COUNT); // must be destroyed!
int myInt = 6;
std::string myString = "hello";
log_info("my log message: %1%, %2%") % myInt % myString
// above code produces this log line:
// [timestamp] [info] my log message: 6, hello

Constructor & Destructor Documentation

◆ LogFormatter() [1/5]

prtx::LogFormatter::LogFormatter ( prt::LogLevel  l)
explicit

Generates a log message with the implicit formatting string "%1%". Useful to just log a single string, e.g.

log_info() % myString 

◆ LogFormatter() [2/5]

prtx::LogFormatter::LogFormatter ( prt::LogLevel  l,
const std::string &  s 
)

Generates a log message with the formatting string s. This is the most commonly used constructor.

◆ LogFormatter() [3/5]

prtx::LogFormatter::LogFormatter ( prt::LogLevel  l,
const std::string &  s,
const std::string &  p 
)

Generates a log message with the formatting string s and an optional prefix p. Useful for marking log messages from a submodule or class.

◆ LogFormatter() [4/5]

prtx::LogFormatter::LogFormatter ( prt::LogLevel  l,
const std::exception &  e 
)

Convenience constructor to directly log an exception message.

◆ LogFormatter() [5/5]

prtx::LogFormatter::LogFormatter ( prt::LogLevel  l,
const std::string &  s,
const std::exception &  e 
)

Convenience constructor to log an exception message with a prefix string s.


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