Cadabra
Computer algebra system for field theory problems
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Public Member Functions | Protected Attributes | List of all members
snoop::Snoop Class Reference

Description

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...
 
Snoopoperator() (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 >
Snoopoperator<< (const T &obj)
 Generic operator to log an object to the log message being constructed. More...
 
Snoopoperator<< (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_
 
SnoopImplimpl
 
friend SnoopImpl
 

Constructor & Destructor Documentation

Snoop::Snoop ( )
Snoop::~Snoop ( )

Member Function Documentation

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.

template<class T >
Snoop& snoop::Snoop::operator<< ( const T &  obj)
inline

Generic operator to log an object to the log message being constructed.

Snoop & Snoop::operator<< ( const Flush f)

Flush the log entry to disk/server.

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.

Member Data Documentation

SnoopImpl* snoop::Snoop::impl
protected
std::ostringstream snoop::Snoop::out_
protected
friend snoop::Snoop::SnoopImpl
protected
bool snoop::Snoop::sync_immediately_
protected

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