PHP Classes

objectStatus 1.0: Monitor and log your objects' activities

Recommend this page to a friend!
  Info   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 719 This week: 1All time: 4,607 This week: 571Up
Version License Categories
objectstatus 1.0GNU General Publi...Logging
Description 

Author

objectStatus is a PHP class for observing and logging objects. It collects messages and can print them to the screen, write into a log file, or send them via email to any number of recipients. It can be used for development purposes or for monitoring running applications.

Please have a look at the xMySQL class (also in this repository) to see how it can be implemented.

Picture of Alexander Serbe
Name: Alexander Serbe <contact>
Classes: 3 packages by
Country: Germany Germany
Age: 50
All time rank: 76349 in Germany Germany
Week rank: 420 Up17 in Germany Germany Up

Details

<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>objectStatus 1.0</title> <style type="text/css"> <!-- body { font:11px verdana,arial,helvetica,sans-serif; color:#333; background-color: #ddd; padding-right:0px; padding-left:0px; padding-bottom:0px; margin:50px 0px; padding-top:0px; text-align:center; } h1 { font:900 italic 1.8em/1 verdana,arial,helvetica,sans-serif; color:#394198; } h2 { margin:2em 0px 0.25em; font:700 1.1em/1 verdana,arial,helvetica,sans-serif; color:#384198; } h3 { font-weight:800; font-size:1em; margin:3em 0px 0.35em; color: #394198; } p { margin:0px 0px 1em; line-height: 1.8; } td { font:11px verdana,arial,helvetica,sans-serif; color:#333; } UNKNOWN { margin-top:-1em; text-indent:2.7em; } ol { margin-top:0px; margin-bottom:1em; line-height:1.8; } ul { margin-top:0px; margin-bottom:1em; line-height:1.8; } UNKNOWN { margin-top:0em; } a { font-weight:600; color:#09c; text-decoration:none; } a:link { color:#394198; } a:visited { color:#515abb; } a:hover { background-color:#f0f0f0; } UNKNOWN { margin-top:0px; text-indent:0px; } .keyPoint { border-right:#666 1px dashed; padding-right:0px; border-top:#666 1px dashed; padding-left:0px; padding-bottom:0px; margin:0px 0px 1.5em; border-left:#666 1px dashed; padding-top:0px; border-bottom:#666 1px dashed; background-color:#fff; } .keyPoint P { margin:0.5em 1em; font: 1.63em/1.8 Georgia,"Times New Roman",Times,serif; } UNKNOWN { margin-top: -0.5em; } .markup { border-right:#999 1px dashed; padding-right:0.3em; border-top:#999 1px dashed; padding-left:0.3em; padding-bottom: 0.3em; font:1.1em/1.2 'courier new',monospace; border-left:#999 1px dashed; text-indent:0px; padding-top:0.3em; border-bottom:#999 1px dashed; } .markupNoBorder { font:1.1em/1.2 'courier new',monospace; text-indent:0px; } .comment { background-color:#f0f0f0; color:#808080; } #Content { border:4px ridge #ccc; padding-right:15px; padding-left:15px; padding-bottom:15px; margin:0px auto; width:700px; padding-top:15px; background-color:#ccc; text-align:left; } .small { font-size:0.8em; } .red { color:#b22222; } --> </style> </head> <body> <a name="top"></a> <div id="content"> <h1><img src="http://www.serbe.de/images/sig4.gif" align="right" border="0" />objectStatus 1.0</h1> <p class="small">Copyright &copy; 2003 by Alexander Serbe. All rights reserved.</p> <p>&nbsp;</p> <hr size="1" color="#000000" noshade /> <p align="center" class="small"><a href="#vh">Version History</a> | <a href="#var">Variables</a> | <a href="#mlist">Methods (overview)</a> | <a href="#ref">Function Reference</a> | <a href="#ex">Example</a> | <a href="#lic">License Agreement</a></p> <hr size="1" color="#000000" noshade /> <p><b>Version:</b> 1.0<br /> <b>Date:</b> 24 May 2003</p> <p><b>Author:</b> Alexander Serbe ( <a href="mailto:info@serbe.de">info@serbe.de</a> )<br /> <b>Contributor(s):</b></p> <p><b>Requirements:</b> PHP enabled webserver (PHP4+).</p> <p><b>License:</b> <a href="http://www.gnu.org/licenses/gpl.html" target="_blank">GNU General Public License</a><br /> <span class="small">(Please note the license terms at the end of this document)</span></p> <p>The main purpose of the objectStatus class is to give you a means to observe and log what the objects you're working with are doing. It can collect messages from various objects and either print them on the screen, write them into a log file or send them via email to one or several recipients.<br /> You can use this class for developing purposes only or for monitoring running applications as well.</p> <hr size="1" color="#000000" noshade /> <h2><a name="vh"></a>Version History</h2> <br /> <table border="0" cellpadding="3" cellspacing="0" width="100%"> <tr> <td valign="top" valign="top" width="80"><b>0.1</b></td> <td valign="top" valign="top" width="120">08 Apr 2003</td> <td>Draft (non-public)</td> </tr> <tr> <td valign="top" valign="top" width="80"><b>0.2</b></td> <td valign="top" valign="top" width="120">21 Apr 2003</td> <td>Draft, updated (non-public)<br /> sendStatus method added.</td> </tr> <tr> <td valign="top" valign="top" width="80"><b>1.0</b></td> <td valign="top" valign="top" width="120">24 May 2003</td> <td>Initial Release</td> </tr> <tr> <td align="right" colspan="3"><a href="#top">Back to Top</a></td> </tr> </table> <br /> <hr size="1" color="#000000" noshade /> <h2><a name="var"></a>Object Variables</h2> <br /> <table border="0" cellpadding="3" cellspacing="0" width="100%"> <tr> <td valign="top"><b>status</b></td> <td><i>Array</i>. Status messages.</td> </tr> <tr> <td align="right" colspan="2"><a href="#top">Back to Top</a></td> </tr> </table> <br /> <hr size="1" color="#000000" noshade /> <h2><a name="mlist"></a>Object Methods (Overview)</h2> <br /> <ul> <li><a href="#objectstatus">objectStatus</a> (public / constructor)<br /> Initializes a new objectStatus instance.</li> <li><a href="#sendstatus">sendStatus</a> (public)<br /> Sends the status messages via email to one or multiple recipients.</li> <li><a href=#statuslog">statusLog</a> (public)<br /> Writes the status messages stored in <i>$this->status</i> into a text file.</li> <li><a href="#statusmessage">statusMessage</a> (public)<br /> Adds a status message</li> <li><a href="#statusprintout">statusPrintout</a> (public)<br /> Returns the status messages either in a HTML table or as CSV file.</li> <li><a href="#statusreset">statusReset</a> (private)<br /> Resets the status array (<i>$this->status</i>).</li> </ul> <br /> <div align="right"><a href="#top">Back to Top</a></div> <hr size="1" color="#000000" noshade /> <h2><a name="ref"></a>Function Reference</h2> <br /> <table border="0" cellpadding="3" cellspacing="0"> <tr> <td colspan="2"><a name="objectstatus"></a><b>objectStatus</b> <span class="small">(added v0.1; last modified v0.2)</span></td> </tr> <tr> <td width="100"><u>Signature:</u></td> <td><i>void</i> <b>objectStatus (</b> <i>void</i> <b>)</b></td> </tr> <tr> <td width="100"><u>Access:</u></td> <td>Public / Constructor</td> </tr> <tr> <td valign="top" width="100"><u>Description:</u></td> <td>Initializes a new objectStatus instance. Returns <i>void</i>.</td> </tr> <tr> <td align="right" colspan="2"><a href="#mlist">Back to List</a> | <a href="#top">Back to Top</a></td> </tr> <tr> <td colspan="2"><hr size="1" color="#c0c0c0" noshade /></td> </tr> <tr> <td colspan="2"><a name="sendstatus"></a><b>sendStatus</b> <span class="small">(added v0.2)</span></td> </tr> <tr> <td width="100"><u>Signature:</u></td> <td><i>boolean</i> <b>sendStatus (</b> <i>string</i> recipient, <i>string</i> subject [, <i>string</i> cc [, <i>string</i> bcc]] <b>)</b></td> </tr> <tr> <td width="100"><u>Access:</u></td> <td>Public</td> </tr> <tr> <td valign="top" width="100"><u>Description:</u></td> <td>This method sends the status messages via email to one or various recipients.</td> </tr> <tr> <td align="right" colspan="2"><a href="#mlist">Back to List</a> | <a href="#top">Back to Top</a></td> </tr> <tr> <td colspan="2"><hr size="1" color="#c0c0c0" noshade /></td> </tr> <tr> <td colspan="2"><a name="statuslog"></a><b>statusLog</b> <span class="small">(added v0.1; last modified v0.2)</span></td> </tr> <tr> <td width="100"><u>Signature:</u></td> <td><i>boolean</i> <b>statusLog (</b> <i>string</i> file [, <i>integer</i> mode [, <i>integer</i> reset]] <b>)</b></td> </tr> <tr> <td width="100"><u>Access:</u></td> <td>Public</td> </tr> <tr> <td valign="top" width="100"><u>Description:</u></td> <td>Writes the status messages into a text file. It either replaces the existing contents of the file (mode <i>1</i>, default), or appends the messages to the file (mode <i>2</i>). The <i>reset</i> flag determines wether the status messages shall be deleted after writing them into the file (1) or not (0, default).</td> </tr> <tr> <td align="right" colspan="2"><a href="#mlist">Back to List</a> | <a href="#top">Back to Top</a></td> </tr> <tr> <td colspan="2"><hr size="1" color="#c0c0c0" noshade /></td> </tr> <tr> <td colspan="2"><a name="statusmessage"></a><b>statusMessage</b> <span class="small">(added v0.1; last modified v0.2)</span></td> </tr> <tr> <td width="100"><u>Signature:</u></td> <td><i>void</i> <b>statusMessage (</b> <i>string</i> object [, <i>string</i> method [, <i>string</i> message [, <i>integer</i> type [, <i>string</i> error_num]]]] <b>)</b></td> </tr> <tr> <td width="100"><u>Access:</u></td> <td>Public</td> </tr> <tr> <td valign="top" width="100"><u>Description:</u></td> <td>Adds a new status message to the array. <i>statusMessage</i> accepts three types of messages: <b>1</b> normal message, <b>2</b> error messgae, <b>3</b> warning/notice.</td> </tr> <tr> <td align="right" colspan="2"><a href="#mlist">Back to List</a> | <a href="#top">Back to Top</a></td> </tr> <tr> <td colspan="2"><hr size="1" color="#c0c0c0" noshade /></td> </tr> <tr> <td colspan="2"><a name="statusprintout"></a><b>statusPrintout</b> <span class="small">(added v0.1; last modified v0.2)</span></td> </tr> <tr> <td width="100"><u>Signature:</u></td> <td><i>string </i> <b>statusPrintout (</b> [<i>string</i> type [, <i>integer</i> reset [, <i>string</i> template]]] <b>)</b></td> </tr> <tr> <td width="100"><u>Access:</u></td> <td>Public</td> </tr> <tr> <td valign="top" width="100"><u>Description:</u></td> <td>Formats the status messages either as HTML table (type = <i>&quot;table&quot;</i>, default) or CSV list (type = <i>&quot;csv&quot;</i>). If you pass a <i>template</i>, statusPrintout tries to insert the status messages into it. The template should look something like this:<br /><br /> <div class="markup"> ...<br /> &lt;!-- rs:start --&gt;&lt;tr&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;b&gt;Time:&lt/b&gt;&lt;/td&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;!-- time --&gt;&lt;/td&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;b&gt;IP:&lt/b&gt;&lt;/td&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;!-- ip --&gt;&lt;/td&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;b&gt;Object:&lt/b&gt;&lt;/td&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;!-- object --&gt;&lt;/td&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;b&gt;Method:&lt/b&gt;&lt;/td&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;!-- method --&gt;&lt;/td&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;b&gt;Message:&lt/b&gt;&lt;/td&gt;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;!-- message --&gt;&lt;/td&gt;<br /> &lt;/tr&gt;&lt;!-- rs:end --&gt;<br /> ... </div> <br /> statusPrintout will copy the part between &lt;!-- rs:start --&gt; and &lt;!-- rs:end --&gt;, insert the values and repeat this for every entry in the status message array.</td> </tr> <tr> <td align="right" colspan="2"><a href="#mlist">Back to List</a> | <a href="#top">Back to Top</a></td> </tr> <tr> <td colspan="2"><hr size="1" color="#c0c0c0" noshade /></td> </tr> <tr> <td colspan="2"><a name="statusreset"></a><b>statusReset</b> <span class="small">(added v0.1; last modified v0.2)</span></td> </tr> <tr> <td width="100"><u>Signature:</u></td> <td><i>void</i> <b>statusMessage (</b> <i>void</i> <b>)</b></td> </tr> <tr> <td width="100"><u>Access:</u></td> <td>Private</td> </tr> <tr> <td valign="top" width="100"><u>Description:</u></td> <td>Resets the status array.</td> </tr> <tr> <td align="right" colspan="2"><a href="#mlist">Back to List</a> | <a href="#top">Back to Top</a></td> </tr> </table> <br /> <hr size="1" color="#000000" noshade /> <h2><a name="ex"></a>Example</h2> <br /> <p>Since the main purpose of the <i>objectStatus</i> class is to give you a means to observe what your objects &quot;are doing&quot;, the first step to using it is to include it to your classes.<br /> This can be done by adding a parameter to the constructor of your class, let's call it <i>$os</i>.</p> <p class="markupNoBorder">function someConstructor ( $someParameter, <b>$os=&quot;&quot;</b> )</p> <p>Make sure it's an optional parameter. After you did that, check if the passed value is an object and, if so, store it in an object variable (to keep it simple, we call it <i>$os</i> as well. Don't forget to initialize this variable using <i>var</i>).<br /> You may add the first status message as well...</p> <p class="markupNoBorder">function someConstructor ( $someParameter, $os=&quot;&quot; )<br /> {<br /> &nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;os = &quot;&quot;;<br /> &nbsp;&nbsp;&nbsp;&nbsp;...<br /> &nbsp;&nbsp;&nbsp;&nbsp;if ( is_object ( $os ) )<br /> &nbsp;&nbsp;&nbsp;&nbsp;{<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;os = $os;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;os-&gt;statusMessage (<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;someClass&quot;,<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;someMethod&quot;,<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;some message&quot;,<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br /> &nbsp;&nbsp;&nbsp;&nbsp;}<br /> &nbsp;&nbsp;&nbsp;&nbsp;...<br /> }</p> <p>After that you only have to check if <span class="markupNoBorder">$this-&gt;os</span> is set/has a value and, if so, add your messages...</p> <p class="markupNoBorder">( $this-&gt;os ) ? $this-&gt;os-&gt;statusMessage ( &quot;someClass&quot;, &quot;someMethod&quot;, &quot;someMessage&quot;, 1 ) : 0;</p> <p>That's it...<br /> <b>Note:</b> I tried to make this example as easy and comprehensible as possible. But since I have developed this thing, some aspects in this example may seem completely clear to me... but not to you. If you encounter any problems with this class, please don't hesitate <a href="mailto:info@serbe.de?subject=objectStatus">asking me</a>.</p> <p align="right" class="small"><a href="#top">Back to Top</a></p> <br /> <hr size="1" color="#000000" noshade /> <h2><a name="lic"></a>GNU General Public License</h2> <br /> <p>This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.<br /> This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.<br /> You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.</p> <p align="right" class="small"><a href="#top">Back to Top</a> | <a href="http://www.gnu.org/licenses/gpl.html#SEC1" target="_blank">more...</a></p> <hr size="1" color="#c0c0c0" noshade /> <p>Dieses Programm ist freie Software. Sie können es unter den Bedingungen der GNU General Public License, wie von der Free Software Foundation veröffentlicht, weitergeben und/oder modifizieren, entweder gemäß Version 2 der Lizenz oder (nach Ihrer Option) jeder späteren Version.<br /> Die Veröffentlichung dieses Programms erfolgt in der Hoffnung, daß es Ihnen von Nutzen sein wird, aber OHNE IRGENDEINE GARANTIE, sogar ohne die implizite Garantie der MARKTREIFE oder der VERWENDBARKEIT FÜR EINEN BESTIMMTEN ZWECK. Details finden Sie in der GNU General Public License.<br /> Sie sollten eine Kopie der GNU General Public License zusammen mit diesem Programm erhalten haben. Falls nicht, schreiben Sie an die Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.</p> <p align="right" class="small"><a href="#top">Back to Top</a> | <a href="http://www.gnu.de/gpl-ger.html" target="_blank">mehr...</a></p> <hr size="1" color="#c0c0c0" noshade /> <p>Ce programme est libre, vous pouvez le redistribuer et/ou le modifier selon les termes de la Licence Publique Générale GNU publiée par la Free Software Foundation (version 2 ou bien toute autre version ultérieure choisie par vous).<br /> Ce programme est distribué car potentiellement utile, mais SANS AUCUNE GARANTIE, ni explicite ni implicite, y compris les garanties de commercialisation ou d'adaptation dans un but spécifique. Reportez-vous à la Licence Publique Générale GNU pour plus de détails.<br /> Vous devez avoir reçu une copie de la Licence Publique Générale GNU en même temps que ce programme ; si ce n'est pas le cas, écrivez à la Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, États-Unis.</p> <p align="right" class="small"><a href="#top">Back to Top</a> | <a href="http://www.linux-france.org/prj/escritor/FR/GPL.htm#GPL-Adresse" target="_blank">plus...</a></p> <hr size="1" color="#000000" noshade /> <p align="center" class="small">Copyright &copy; 2003 by Alexander Serbe. All rights reserved.</p> </div> </body> </html>

  Files folder image Files  
File Role Description
Accessible without login Plain text file gpl.txt Lic. GNU General Public License
Accessible without login Plain text file gpl_de.txt Lic. GNU General Public License (German)
Accessible without login Plain text file gpl_fr.txt Lic. GNU General Public License (French)
Plain text file objectstatus.class.php Class Class file
Accessible without login Plain text file readme.html Doc. Description, function reference and example

 Version Control Unique User Downloads Download Rankings  
 0%
Total:719
This week:1
All time:4,607
This week:571Up