Cadabra
Computer algebra system for field theory problems
|
Logging class with functionality to send log information to a remote server using a websocket connection.
#include <Snoop.hh>
Classes | |
class | AppEntry |
C++ representation of an run entry. More... | |
class | LogEntry |
C++ representation of a log entry. More... | |
Public Member Functions | |
Snoop () | |
~Snoop () | |
void | init (const std::string &app_name, const std::string &app_version, std::string server="", std::string local_log_file="") |
Initialise the logging stream. More... | |
std::string | get_user_uuid (const std::string &app_name) |
Get a string which uniquely identifies the current user. More... | |
Snoop & | operator() (const std::string &type, std::string fl="", int loc=-1, std::string method="") |
Operator to initialise a logging entry with the type of the log message as well as (optionally) the file, line number and method. More... | |
template<class T > | |
Snoop & | operator<< (const T &obj) |
Generic operator to log an object to the log message being constructed. More... | |
Snoop & | operator<< (const Flush &) |
Flush the log entry to disk/server. More... | |
void | set_sync_immediately (bool) |
Set to sync with server after every log line. More... | |
void | sync_with_server (bool from_wsthread=false) |
Ensure that the local database is synchronised with the server (this sends multiple app or log entries in one websocket message). More... | |
void | sync_runs_with_server (bool from_wsthread=false) |
As above, but only for run entries. More... | |
void | sync_logs_with_server (bool from_wsthread=false) |
As above, but only for log entries. More... | |
Protected Attributes | |
std::ostringstream | out_ |
bool | sync_immediately_ |
SnoopImpl * | impl |
friend | SnoopImpl |
Snoop::Snoop | ( | ) |
Snoop::~Snoop | ( | ) |
std::string Snoop::get_user_uuid | ( | const std::string & | app_name | ) |
Get a string which uniquely identifies the current user.
This is stored in ~/.config/snoop/appname.conf, and in the 'user_id' field in each LogEntry. Note that this is different from the 'uuid' field, which will change from one run to the next.
void Snoop::init | ( | const std::string & | app_name, |
const std::string & | app_version, | ||
std::string | server = "" , |
||
std::string | local_log_file = "" |
||
) |
Initialise the logging stream.
Should be called once at program startup, but can be called multiple times without causing problems.
Snoop & Snoop::operator() | ( | const std::string & | type, |
std::string | fl = "" , |
||
int | loc = -1 , |
||
std::string | method = "" |
||
) |
Operator to initialise a logging entry with the type of the log message as well as (optionally) the file, line number and method.
|
inline |
Generic operator to log an object to the log message being constructed.
void Snoop::set_sync_immediately | ( | bool | s | ) |
Set to sync with server after every log line.
void Snoop::sync_logs_with_server | ( | bool | from_wsthread = false | ) |
As above, but only for log entries.
void Snoop::sync_runs_with_server | ( | bool | from_wsthread = false | ) |
As above, but only for run entries.
void Snoop::sync_with_server | ( | bool | from_wsthread = false | ) |
Ensure that the local database is synchronised with the server (this sends multiple app or log entries in one websocket message).
Leave the bool argument at its default argument under all normal circumstances.
|
protected |
|
protected |
|
protected |
|
protected |