postlog

Driver for storing log data into PostgreSQL database. More...

Driver for storing log data into PostgreSQL database.

The postlog driver is for storing log data into given tables of given PostgreSQL database.

Compile-time dependencies
  • libpqxx
Provides
  • log : can be used to turn logging on/off
  • (optional) list of devices to provide (see "Configuration file options" below)
Requires
  • list of devices to subscribe (see "Configuration file options" below) (can be empty only if there are provided interfaces for logging commands)
Configuration requests
  • PLAYER_LOG_REQ_SET_WRITE_STATE
  • PLAYER_LOG_REQ_GET_STATE
Configuration file options
  • tables (string tuple)
    • Default: empty tuple
    • Names of tables in the database, data (or commands) obtained from each subscribed/provided device will be written into given table; these names are also used as key names for distinguishing devices in 'Requires' and 'Provides' lists.
  • init_state (integer)
    • Default: 1
    • Initial write state (1 - ON, 0 - OFF).
    • Write state can be changed by PLAYER_LOG_REQ_SET_WRITE_STATE request.
  • wait_for_all
    • Default: 0
    • If set to non-zero, this driver will be waiting for complete set of data and commands, it means that data (and commands) will be stored right after receiving them from all provided and subscribed interfaces; data or commands from one interface received more frequently will be dropped.
    • Devices that send many subtypes of data to one subscribed interface may make confusions here.
  • dbname (string)
    • Default: "postlog"
    • The name of the Postgresql database to connect to.
  • host (string)
    • Default: "127.0.0.1"
    • The name of the database host.
  • user (string)
    • Default: "postgres"
    • The name of the database user.
  • port (string)
    • Default: "5432"
    • The port of the database.
  • password (string)
    • Default: ""
    • The password for the database user.
  • sequence (string)
    • Default: "postlog_seq"
    • Sequence name for primary keys (see "database prerequisites").
Database prerequisites

Before using this driver, you need to have database created in your PostgreSQL server. You can create it using UNIX shell by typing such command:

createdb postlog

('postlog' is example database name; depending on database server policies, you may be asked for database user password after entering this; if you do not have database user account, ask database administrator to create one for you).

Then you can enter database shell by typing such command:

psql postlog

Now you can enter SQL commands. First you need to create incremental sequence that will be used as primary key ('postlog_seq' is example sequence name):

CREATE SEQUENCE postlog_seq START 1 INCREMENT 1 MINVALUE 1;

Then you have to create table for each subscribed (or provided) device. Although record structure for each table depends on interface type, first fields are common for each table:

id INT4 PRIMARY KEY, index INT2 NOT NULL, unixtime BIGINT NOT NULL, hdrtime DOUBLE PRECISION NOT NULL, globaltime DOUBLE PRECISION NOT NULL, subtype VARCHAR(50) NOT NULL

Additionally, you can add PostgreSQL date and time fields that will be filled automatically:

date DATE DEFAULT CURRENT_DATE NOT NULL, time TIME(4) DEFAULT CURRENT_TIME(4)

Time from four different sources (system clock, data header, Player global clock, SQL server clock) will give you whole image of this infrastructure time dependencies.

Currently supported interfaces are:

Example
driver
(
  name "postlog"
  tables ["table1" "table2"]
  requires ["table1::6665:position2d:0"]
  provides ["log:0" "table2:::position2d:10"]
  wait_for_all 1
  alwayson 1
)
driver
(
  name "cmdsplitter"
  provides ["position2d:0"]
  devices 2
  requires ["1::6665:position2d:0" "0:::position2d:10"]
)

This is not a threaded driver, it is good idea to keep it in separate Player instance.

Author
Paul Osmialowski

Last updated 12 September 2005 21:38:45