Actions

API15

JLog/getInstance

From Joomla! Documentation

< API15:JLog
Revision as of 17:20, 22 March 2010 by Doxiki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

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

[Edit Descripton]

Description:JLog/getInstance

Syntax

& 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

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];
}

[Edit See Also] SeeAlso:JLog/getInstance

Examples

<CodeExamplesForm />