Contains the Log class which can be used to redirect output to an arbitrary destination.
More...
#include <boost/lexical_cast.hpp>
#include "ns.h"
Go to the source code of this file.
|
| Msg |
| Contains logging-related functions.
|
|
|
std::string | bytesToString (int64_t bytes) |
| Converts a byte count into a human-readable string. More...
|
|
size_t | currentRSS () |
| Returns the current resident memory size. More...
|
|
void | Msg::print (const std::string &message) |
| Sends the string to the assigned output. More...
|
|
FIELD3D_API void | Msg::print (Severity severity, const std::string &message) |
| Sends the string to the assigned output, prefixing the message with the severity. More...
|
|
FIELD3D_API void | Msg::setVerbosity (int level=1) |
| Set the verbosity level of console output: 0 = do not echo anything to the console; >=1 = echo all messages and warnings to the console. More...
|
|
Contains the Log class which can be used to redirect output to an arbitrary destination.
Definition in file Log.h.
◆ bytesToString()
std::string bytesToString |
( |
int64_t |
bytes | ) |
|
Converts a byte count into a human-readable string.
Definition at line 101 of file Log.cpp.
103 using std::stringstream;
107 ss.setf(std::ios::fixed, std:: ios::floatfield);
119 }
else if (bytes < (1024 * 1024)) {
121 ss << bytes /
static_cast<float>(1024) <<
" KB";
123 }
else if (bytes < (1024 * 1024 * 1024)) {
125 ss << bytes /
static_cast<float>(1024 * 1024) <<
" MB";
129 ss << bytes /
static_cast<float>(1024 * 1024 * 1024) <<
" GB";
◆ currentRSS()
Returns the current resident memory size.
- Warning
- Currently only supported on Linux platform. Returns 0 for others.
Only implemented for Linux at the moment.
Definition at line 136 of file Log.cpp.
145 ifstream stat_stream(
"/proc/self/stat", ios_base::in);
147 string pid, comm, state, ppid, pgrp, session, tty_nr;
148 string tpgid, flags, minflt, cminflt, majflt, cmajflt;
149 string utime, stime, cutime, cstime, priority, nice;
150 string O, itrealvalue, starttime;
155 stat_stream >> pid >> comm >> state >> ppid >> pgrp >> session >> tty_nr
156 >> tpgid >> flags >> minflt >> cminflt >> majflt >> cmajflt
157 >> utime >> stime >> cutime >> cstime >> priority >> nice
158 >> O >> itrealvalue >> starttime
164 long page_size = sysconf(_SC_PAGE_SIZE);
169 return rss * page_size;