Class Log_sql

Description

The Log_sql class is a concrete implementation of the Log:: abstract class which sends messages to an SQL server. Each entry occupies a separate row in the database.

This implementation uses PHP's PEAR database abstraction layer.

CREATE TABLE log_table ( id INT NOT NULL, logtime TIMESTAMP NOT NULL, ident CHAR(16) NOT NULL, priority INT NOT NULL, message VARCHAR(200), PRIMARY KEY (id) );

  • example: example not found
  • since: Horde 1.3
  • since: Log 1.0
  • author: Jon Parise <jon@php.net>

Located in /maintenance/libraries/pear/Log/sql.php (line 36)

Log
   |
   --Log_sql
Variable Summary
 object $_db
 string $_dsn
 integer $_identLimit
 string $_sequence
 string $_table
Method Summary
 Log_sql Log_sql (string $name, [string $ident = ''], [array $conf = array()], [int $level = PEAR_LOG_DEBUG])
 boolean close ()
 boolean log (mixed $message, [string $priority = null])
 boolean open ()
 void setIdent (string $ident)
Variables
object $_db = null (line 50)

Object holding the database handle.

  • access: private
string $_dsn = '' (line 43)

Array containing the dsn information.

  • access: private
boolean $_existingConnection = false (line 57)

Flag indicating that we're using an existing database connection.

  • access: private
integer $_identLimit = 16 (line 79)

Maximum length of the $ident string. This corresponds to the size of the 'ident' column in the SQL table.

  • access: private
string $_sequence = 'log_id' (line 71)

String holding the name of the ID sequence.

  • access: private
string $_table = 'log_table' (line 64)

String holding the database table to use.

  • access: private

Inherited Variables

Inherited from Log

Log::$_id
Log::$_ident
Log::$_listeners
Log::$_mask
Log::$_opened
Log::$_priority
Methods
Constructor Log_sql (line 91)

Constructs a new sql logging object.

  • access: public
Log_sql Log_sql (string $name, [string $ident = ''], [array $conf = array()], [int $level = PEAR_LOG_DEBUG])
  • string $name: The target SQL table.
  • string $ident: The identification field.
  • array $conf: The connection configuration array.
  • int $level: Log messages up to and including this level.
close (line 149)

Closes the connection to the database if it is still open and we were the ones that opened it. It is the caller's responsible to close an existing connection that was passed to us via $conf['db'].

  • return: True on success, false on failure.
  • access: public
boolean close ()

Redefinition of:
Log::close()
Abstract implementation of the close() method.
log (line 187)

Inserts $message to the currently open database. Calls open(), if necessary. Also passes the message along to any Log_observer instances that are observing this Log.

  • return: True on success or false on failure.
  • access: public
boolean log (mixed $message, [string $priority = null])
  • mixed $message: String or object containing the message to log.
  • string $priority: The priority of the message. Valid values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT, PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING, PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG.

Redefinition of:
Log::log()
Abstract implementation of the log() method.
open (line 128)

Opens a connection to the database, if it has not already been opened. This is implicitly called by log(), if necessary.

  • return: True on success, false on failure.
  • access: public
boolean open ()

Redefinition of:
Log::open()
Abstract implementation of the open() method.
setIdent (line 169)

Sets this Log instance's identification string. Note that this SQL-specific implementation will limit the length of the $ident string to sixteen (16) characters.

  • since: Log 1.8.5
  • access: public
void setIdent (string $ident)
  • string $ident: The new identification string.

Redefinition of:
Log::setIdent()
Sets this Log instance's identification string.

Inherited Methods

Inherited From Log

 Log::alert()
 Log::attach()
 Log::close()
 Log::crit()
 Log::debug()
 Log::detach()
 Log::emerg()
 Log::err()
 Log::factory()
 Log::flush()
 Log::getIdent()
 Log::getMask()
 Log::getPriority()
 Log::info()
 Log::isComposite()
 Log::log()
 Log::MASK()
 Log::notice()
 Log::open()
 Log::priorityToString()
 Log::setIdent()
 Log::setMask()
 Log::setPriority()
 Log::singleton()
 Log::UPTO()
 Log::warning()
 Log::_announce()
 Log::_extractMessage()
 Log::_isMasked()

Documentation generated on Thu, 20 Jan 2005 17:10:58 +0000 by phpDocumentor 1.3.0RC3