journal

virtual class journal

virtual Provides logging functions to store transactions to a log or a CSV file.

Summary
journalvirtual Provides logging functions to store transactions to a log or a CSV file.
Properties
log_fdThe file descriptor for the log.
csv_fdThe file descriptor for the CSV file.
Functions
logstatic Stores a transaction to the file specified by the log_fd using the format shown in the Example below.
csvstatic Stores a transaction to the file specified by the csv_fd using the CSV (comma separated value) format shown in the Example below.

Properties

log_fd

static integer log_fd

The file descriptor for the log.  It is user’s responsibility to open the file before calling log.

csv_fd

static integer csv_fd

The file descriptor for the CSV file.  It is user’s responsibility to open the file before calling csv.

Functions

log

static function void log(string desc,  
string from_unit =  "journal",
string to_unit =  from_unit)

static Stores a transaction to the file specified by the log_fd using the format shown in the Example below.  It is user’s responsibility to open the log file before calling this function.

Arguments

descThe description of a transaction.
from_unitoptional The name of the unit the transaction comes from.  The default name is “journal”.
to_unitoptional The name of the unit the transaction goes to.  The default name is the value of from_unit.

Example

journal::log_fd = $fopen( "journal.log", "w" );
journal::log( "request", "master", "slave" );
#100;
journal::log( "response", "slave", "master" );

/* journal.log */
// master->slave: @0 request
// slave->master: @100 response

csv

static function void csv(string desc,  
string from_unit =  "journal",
string to_unit =  from_unit)

static Stores a transaction to the file specified by the csv_fd using the CSV (comma separated value) format shown in the Example below.  It is user’s responsibility to open the CSV file before calling this function.

Arguments

descThe description of a transaction.
from_unitoptional The name of the unit the transaction comes from.  The default name is “journal”.
to_unitoptional The name of the unit the transaction goes to.  The default name is the value of from_unit.

Example

journal::csv_fd = $fopen( "journal.csv", "w" );
journal::csv( "request", "master", "slave" );
#100;
journal::csv( "response", "slave", "master" );

/* journal.csv */
// "master","slave","@0 request"
// "slave","master","@100 response"
virtual class journal
virtual Provides logging functions to store transactions to a log or a CSV file.
static integer log_fd
The file descriptor for the log.
static integer csv_fd
The file descriptor for the CSV file.
static function void log(string desc,  
string from_unit =  "journal",
string to_unit =  from_unit)
static Stores a transaction to the file specified by the log_fd using the format shown in the Example below.
static function void csv(string desc,  
string from_unit =  "journal",
string to_unit =  from_unit)
static Stores a transaction to the file specified by the csv_fd using the CSV (comma separated value) format shown in the Example below.