35 namespace boost {
namespace asio {
namespace ip {
template<
class T>
class basic_endpoint;
class tcp; } } }
54 extern std::function<void(std::string const&, char const*)>
g_logPost;
63 std::type_info
const*
m_ch;
64 static const int c_null = -1;
68 template <
class Channel>
82 VerbosityHolder(
int _temporaryValue,
bool _force =
false): oldLogVerbosity(g_logVerbosity) {
if (g_logVerbosity >= 0 || _force) g_logVerbosity = _temporaryValue; }
87 #define ETH_THREAD_CONTEXT(name) for (std::pair<dev::ThreadContext, bool> __eth_thread_context(name, true); p.second; p.second = false) 95 static void push(std::string
const& _n);
97 static std::string join(std::string
const& _prior);
130 struct LogChannel {
static const char*
name();
static const int verbosity = 1;
static const bool debug =
true; };
149 LogOutputStreamBase(
char const* _id, std::type_info
const* _info,
unsigned _v,
bool _autospacing);
156 case LogTag::Error: m_sstr <<
EthRedBold;
break;
161 m_logTag = LogTag::None;
179 template <
class T>
void append(std::vector<T>
const& _t)
183 for (
auto const& i: _t)
185 m_sstr << (n++ ?
EthWhite ", " EthReset :
"");
190 template <
class T>
void append(std::set<T>
const& _t)
194 for (
auto const& i: _t)
196 m_sstr << (n++ ?
EthYellow ", " EthReset :
"");
201 template <
class T,
class U>
void append(std::map<T, U>
const& _t)
205 for (
auto const& i: _t)
207 m_sstr << (n++ ?
EthLime ", " EthReset :
"");
209 m_sstr << (n++ ?
EthLime ": " EthReset :
"");
214 template <
class T>
void append(std::unordered_set<T>
const& _t)
218 for (
auto const& i: _t)
220 m_sstr << (n++ ?
EthYellow ", " EthReset :
"");
225 template <
class T,
class U>
void append(std::unordered_map<T, U>
const& _t)
229 for (
auto const& i: _t)
231 m_sstr << (n++ ?
EthLime ", " EthReset :
"");
233 m_sstr << (n++ ?
EthLime ": " EthReset :
"");
238 template <
class T,
class U>
void append(std::pair<T, U>
const& _t)
252 bool m_autospacing =
false;
253 unsigned m_verbosity = 0;
259 template <
class Id,
bool _AutoSpacing = true>
270 LogOutputStream&
operator<<(std::string
const& _t) {
if (Id::verbosity <= g_logVerbosity) {
if (_AutoSpacing && m_sstr.str().size() && m_sstr.str().back() !=
' ') m_sstr <<
" "; comment(_t); }
return *
this; }
275 template <
class T>
LogOutputStream&
operator<<(
T const& _t) {
if (Id::verbosity <= g_logVerbosity) {
if (_AutoSpacing && m_sstr.str().size() && m_sstr.str().back() !=
' ') m_sstr <<
" "; append(_t); }
return *
this; }
281 #define DEV_STATEMENT_IF(COND) for (bool i_eth_if_ = (COND); i_eth_if_; i_eth_if_ = false) 282 #define DEV_STATEMENT_SKIP() while ( false) 288 #define clog(X) nlog(X) 289 #define cslog(X) nslog(X) 292 #define clog(X) DEV_STATEMENT_IF(!(X::debug)) dev::LogOutputStream<X, true>() 293 #define cslog(X) DEV_STATEMENT_IF(!(X::debug)) dev::LogOutputStream<X, false>() 295 #define clog(X) dev::LogOutputStream<X, true>() 296 #define cslog(X) dev::LogOutputStream<X, false>() 302 #define cdebug clog(dev::DebugChannel) 303 #define cnote clog(dev::NoteChannel) 304 #define cwarn clog(dev::WarnChannel) 305 #define ctrace clog(dev::TraceChannel) 308 #define ndebug DEV_STATEMENT_SKIP() dev::NullOutputStream() 309 #define nlog(X) DEV_STATEMENT_SKIP() dev::NullOutputStream() 310 #define nslog(X) DEV_STATEMENT_SKIP() dev::NullOutputStream() LogOutputStream()
Construct a new object.
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
std::string toHex(T const &_data, int _w=2, HexPrefix _prefix=HexPrefix::DontAdd)
void append(std::string const &_t)
std::type_info const * m_ch
void simpleDebugOut(std::string const &, char const *)
A simple log-output function that prints log messages to stdout.
void append(std::pair< T, U > const &_t)
boost::multiprecision::number< boost::multiprecision::cpp_int_backend<>> bigint
~LogOutputStream()
Destructor. Posts the accrued log entry to the g_logPost function.
LogOutputStream & operator<<(T const &_t)
Shift arbitrary data to the log. Spaces will be added between items as required.
EXPORT void debug(uint64_t a, uint64_t b, uint64_t c, uint64_t d, char z)
std::string toString(string32 const &_s)
Make normal string from fixed-length string.
ThreadContext(std::string const &_info)
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 160, 160, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u160
void append(bigint const &_t)
void append(std::unordered_set< T > const &_t)
void append(u160 const &_t)
std::stringstream m_sstr
The accrued log entry.
VerbosityHolder(int _temporaryValue, bool _force=false)
void append(unsigned int _t)
void append(std::map< T, U > const &_t)
std::function< void(std::string const &, char const *)> g_logPost
The current method that the logging system uses to output the log messages. Defaults to simpleDebugOu...
void append(bytes const &_t)
LogOutputStream & operator<<(std::string const &_t)
void setThreadName(std::string const &_n)
Set the current thread's log name.
void append(h512 const &_t)
std::vector< byte > bytes
void append(bytesConstRef _t)
Fixed-size raw-byte array container type, with an API optimised for storing hashes.
std::string getThreadName()
Set the current thread's log name.
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
void append(std::unordered_map< T, U > const &_t)
void append(h160 const &_t)
Temporary changes system's verbosity for specific function.
void append(FixedHash< N > const &_t)
void append(unsigned long _t)
int g_logVerbosity
The logging system's current verbosity.
void append(std::vector< T > const &_t)
NullOutputStream & operator<<(T const &)
The null output stream. Used when logging is disabled.
LogOutputStream & operator<<(LogTag _t)
void append(std::set< T > const &_t)
void append(h256 const &_t)
void append(u256 const &_t)
std::string abridged() const
The default logging channels.
void comment(std::string const &_t)
Logging class, iostream-like, that can be shifted to.