Location: PHPKode > projects > Neobill > NeoBill0.5.6/solidworks/log.php
<?php
/**
 * log.php
 *
 * This file contains functions related to the SolidState logging facility
 *
 * @package SolidWorks
 * @author John Diamond <hide@address.com>
 * @copyright John Diamond <hide@address.com>
 * @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
 */

require BASE_PATH . "DBO/LogDBO.class.php";

/**
 * Log Message
 *
 * Writes a new log entry
 *
 * @param string $type Type of log entry (notice, warning, error, critical, or security)
 * @param string $module Where (in the code) this message is coming from
 * @param string $message Log message
 */
function log_message( $type, $module, $message ) {
	// Construct a LogDBO
	$logdbo = new LogDBO();
	$logdbo->setType( $type );
	$logdbo->setModule( $module );
	$logdbo->setText( $message );
	$logdbo->setUsername( !empty( $_SESSION['client']['userdbo'] ) ?
			$_SESSION['client']['userdbo']->getUsername() : null );
	$logdbo->setRemoteIP( ip2long( $_SERVER['REMOTE_ADDR'] ) );
	$logdbo->setDate( DBConnection::format_datetime( time() ) );

	// Write the log message
	add_LogDBO( $logdbo );
}

/**
 * Log Notice
 *
 * Writes a new log entry of type "Notice"
 *
 * @param string $module Where (in the code) this message is coming from
 * @param string $message Log message
 */
function log_notice( $module, $message ) {
	log_message( "notice", $module, $message );
}

/**
 * Log Warning
 *
 * Writes a new log entry of type "warning"
 *
 * @param string $module Where (in the code) this message is coming from
 * @param string $message Log message
 */
function log_warning( $module, $message ) {
	log_message( "warning", $module, $message );
}

/**
 * Log Error
 *
 * Writes a new log entry of type "Error"
 *
 * @param string $module Where (in the code) this message is coming from
 * @param string $message Log message
 */
function log_error( $module, $message ) {
	log_message( "error", $module, $message );
}

/**
 * Log Critical
 *
 * Writes a new log entry of type "Critical"
 *
 * @param string $module Where (in the code) this message is coming from
 * @param string $message Log message
 */
function log_critical( $module, $message ) {
	log_message( "critical", $module, $message );
}

/**
 * Log Security
 *
 * Writes a new log entry of type "Security"
 *
 * @param string $module Where (in the code) this message is coming from
 * @param string $message Log message
 */
function log_security( $module, $message ) {
	log_message( "security", $module, $message );
}

/**
 * Fatal Error
 *
 * Log the message as "critical" and bring the program to a halt
 *
 * @param string $module Where (in the code) this message is coming from
 * @param string $message Log message
 */
function fatal_error( $module, $message ) {
	echo $message;
	log_critical( $module, $message );
	exit();
}
?>
Return current item: Neobill