Kimai_Logger::logfile PHP Method

logfile() public static method

Simple static method to log lines to the logfile.
Author: sl
public static logfile ( string $value )
$value string message
    public static function logfile($value)
    {
        if (self::$instance == null) {
            self::$instance = new Kimai_Logger();
        }
        $value = preg_replace('/\\n|\\s{2,}/i', '', $value);
        self::$instance->log($value);
    }

Usage Example

Exemplo n.º 1
0
/**
 * Execute an sql query in the database. The correct database connection
 * will be chosen and the query will be logged with the success status.
 *
 * As third parameter an alternative query can be passed, which should be
 * displayed instead of the executed query. This prevents leakage of
 * confidential information like password salts. The logfile will still
 * contain the executed query.
 *
 * @param $query query to execute as string
 * @param bool $errorProcessing true if it's an error when the query fails.
 * @param null $displayQuery
 */
function exec_query($query, $errorProcessing = true, $displayQuery = null)
{
    global $database, $kga, $errors, $executed_queries;
    $conn = $database->getConnectionHandler();
    $executed_queries++;
    $success = $conn->Query($query);
    Kimai_Logger::logfile($query);
    $err = $conn->Error();
    $query = htmlspecialchars($query);
    $displayQuery = htmlspecialchars($displayQuery);
    if ($success) {
        $level = 'green';
    } else {
        if ($errorProcessing) {
            $level = 'red';
            $errors++;
        } else {
            $level = 'orange';
            // something went wrong but it's not an error
        }
    }
    printLine($level, $displayQuery == null ? $query : $displayQuery, $err);
    if (!$success) {
        Kimai_Logger::logfile("An error has occured in query [{$query}]: " . $conn->Error());
    }
}
All Usage Examples Of Kimai_Logger::logfile