API16

API16:JLog/getInstance

From Joomla! Documentation

Description

Returns the global log object, only creating it if it doesn't already exist.


<! removed transcluded page call, red link never existed >

Syntax

static getInstance($file= 'error.php', $options=null, $path=null)
Parameter Name Default Value Description
$file 'error.php'
$options null
$path null

Returns

object The object.

Defined in

libraries/joomla/error/log.php

Importing

jimport( 'joomla.error.log' );

Source Body

static function getInstance($file = 'error.php', $options = null, $path = null)
{
        static $instances;

        // Set default path if not set
        if (!$path)
        {
                $config = &JFactory::getConfig();
                $path = $config->getValue('config.log_path');
        }

        jimport('joomla.filesystem.path');
        $path = JPath :: clean($path . DS . $file);
        $sig = md5($path);

        if (!isset ($instances)) {
                $instances = array ();
        }

        if (empty ($instances[$sig])) {
                $instances[$sig] = new JLog($path, $options);
        }

        return $instances[$sig];
}


<! removed transcluded page call, red link never existed >

Examples

Code Examples