cvs: peardoc /en/core log.xml
| From: | Jon Parise | Date: | Mon, 14 Jan 2002 06:55:47 +0000 |
| Subject: | cvs: peardoc /en/core log.xml | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-1930@lists.php.net to get a copy of this message | ||
jon Mon Jan 14 01:55:47 2002 EDT
Modified files:
/peardoc/en/core log.xml
Log:
Further improving the Log:: documentation.
Index: peardoc/en/core/log.xml
diff -u peardoc/en/core/log.xml:1.2 peardoc/en/core/log.xml:1.3
--- peardoc/en/core/log.xml:1.2 Sun Jan 13 09:51:47 2002
+++ peardoc/en/core/log.xml Mon Jan 14 01:55:46 2002
@@ -1,5 +1,5 @@
<?xml encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<reference id="core.log">
<title>Logging functions</title>
@@ -12,38 +12,38 @@
<refentry id="core.log.container">
<refnamediv>
<refname>Logging container</refname>
- <refpurpose> <classname>Log</classname> support different types of data
- container.</refpurpose>
+ <refpurpose><classname>Log</classname> supports different types of data
+ containers.</refpurpose>
</refnamediv>
<refsect1 id="core.log.container.file">
<title>'file' - Log_file</title>
<para>
- Stores data in an arbitrary file on a local disk. Local means
- reachable through filesystem functions.
+ Stores data in an arbitrary file on a local file system (local refers to
+ any file accessible using PHP's filesystem functions).
</para>
</refsect1>
<refsect1 id="core.log.container.mcal">
<title>'mcal' - Log_mcal</title>
<para>
- Stores data in an calendar application. This requires an installed
- <command>libmcal</command> and <command>MCal</command>-PHP-Extension
+ Stores data in a calendar application. This requires the
+ <command>libmcal</command> and <command>mcal</command> PHP extensions.
</para>
</refsect1>
<refsect1 id="core.log.container.sql">
<title>'sql' - Log_sql</title>
<para>
- Stores data in a database using <link linkend="core.db">PEAR::DB</link>
+ Stores data in a database using <link linkend="core.db">PEAR::DB</link>
</para>
</refsect1>
<refsect1 id="core.log.container.syslog">
- <title>'sql' - Log_sql</title>
+ <title>'sql' - Log_syslog</title>
<para>
- Stores data in the <command>syslog</command> on Unix-based systems or
- in the <command>Event Log</command> on Windows NT/2000.
+ Stores data using <command>syslog</command> on Unix-based systems or
+ in the <command>Event Log</command> on Windows NT/2000/XP.
</para>
</refsect1>
</refentry>
@@ -51,53 +51,71 @@
<refentry id="core.log.init">
<refnamediv>
<refname>Initialization</refname>
- <refpurpose>Creating a log object</refpurpose>
+ <refpurpose>Creating a <classname>Log</classname> object</refpurpose>
</refnamediv>
<refsect1>
<title></title>
<para>
- There are three possibilities to get a
- <classname>Log</classname>-object. Either you create a
- <classname>Log_*</classname>-object directly or you use the
- <link linkend="core.log.log.singelton"><function>&singelton
- </function>
- </link> or
- <link
linkend="core.log.log.factory"><function>factory</function></link>
- function of <classname>Log</classname>
+ There are three possible methods to create a <classname>Log</classname>
+ object. You can create a <classname>Log_</classname> object directly
+ or call either the <link linkend="core.log.log.singleton"><function>
+ &singleton</function></link> or the
+ <link
linkend="core.log.log.factory"><function>factory</function>
+ </link> method of the <classname>Log</classname> class.
</para>
<example>
- <title>init examples</title>
+ <title>Initialization examples</title>
<programlisting role="php">
<![CDATA[
// direct initialization of the 'file' container
-$log = new Log_file( "log.txt", "identity text") ;
+$log = new Log_file('log.txt', 'identity text');
// initialization of the 'file' container through factory()
-$log = Log::factory( "file", "log.txt", "identity text") ;
+$log = Log::factory('file', 'log.txt', 'identity text');
// initialization of the 'file' container through singelton()
-$log = &Log::singelton( "file", "log.txt", "identity text") ;
+$log = &Log::singelton('file', 'log.txt', 'identity text');
]]>
</programlisting>
</example>
<para>
- The direct initialization should be easy to understand, like that the
- initialization is probably assertion needy with the help of the
- <function>factory</function> and <function>singelton</function>
methods.
- This both are so called "software design patterns", don't care about
- the (maybe) strange kind of creating an object. The
- <parameter>$log</parameter> variable contains a regular log container
- instance during successful execution.
- </para>
- <para>
- <function>Singelton</function> brings some advantages opposite
- the direct initialization with itself. This function provides a
- abstraction from the used data container. Further this function checks
- whether an appropriate object was already created. Is this the case the
- reference of the existing instance is returned, instead of producing a
- new. In a large application, this avoids having more then one instance
- for the same container with maybe mutual locking.
- </para>
+ Directly initializing an instance of the <classname>Log</classname> is
+ probably the easiest method to understand.
+ </para>
+ <para>
+ The second two approaches make use of software engineering design
+ patterns (the "factory" and "singleton" metaphors).
+ </para>
+ <para>
+ Specifically, calling the <function>factory</function> method will
+ create a new instance of one of the <classname>Log_</classname>
+ subclasses. The type of subclass that is returned is specified by the
+ first parameter (<parameter>log_type</parameter>) passed to the
+ <function>factory</function> method. This approach effectively hides
+ the subclasses while still allowing the programmer to request a
+ concrete instance of a certain subclass. This is useful in cases where
+ the subclass type needs to be chosen at runtime.
+ </para>
+ <para>
+ The <function>factory</function> method must always be called using
+ PHP's static method notation - <literal>Log::factory</literal>.
+ </para>
+ <para>
+ The <function>singleton</function> method is identical to the
+ <function>factory</function> method except that it guarantees that
+ only a single instance of the requested <classname>Log_</classname>
+ subclass exists. The <function>singleton</function> method bases each
+ instance's uniqueness on the parameters used in the instance's
+ creation. In other words, only one instance with a given set of
+ creation parameters will ever be returned by the
+ <function>singleton</function> method. The second invocation will
+ simply return a reference to the existing instance.
+ </para>
+ <para>
+ The <function>singleton</function> method must also be called
+ statically. In addition, it requires PHP's reference notation -
+ <literal>&Log::singleton</literal>.
+ </para>
</refsect1>
</refentry>