source: Dev/trunk/src/client/dojox/form/tests/cLOG.php.disabled

Last change on this file was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 1.1 KB
Line 
1<?php
2//
3//      summary
4//              Creates/Opens files for logging data
5//              Useful for logging iinformation on a remote server
6//              when you don't have access to log files
7//              Also helpful for XHRs - since the page doesn't change
8//              to the PHP location which normally shows log data
9//              or errors.
10//
11//
12 class cLOG {
13        var $logfile;
14        var $boolTimestamp;
15        function cLOG($filename, $boolTimestamp){
16                $this->boolTimestamp = $boolTimestamp;
17                $this->logfile = $filename;
18        }
19        function write($txt){
20                if($this->boolTimestamp){
21                        $dt = date("y.m.d G.i.s");
22                        $txt = "[". $dt ."]: ".$txt;
23                }
24                $fh = fopen($this->logfile, "a");
25                if(is_array($txt)){
26                        //$txt = "::::::::".$txt;
27                        $ar = $txt;
28                        $txt = "Array:::::\n";
29                        foreach($ar as $key => $value){
30                                $txt += $key."=".$value."\n";
31                        }
32                }
33                fwrite($fh, $txt."\n");
34                fclose($fh);
35        }
36        function clear(){
37                $fh = fopen($this->logfile, "w");
38                fwrite($fh, "");
39                fclose($fh);
40        }
41        function newline(){
42                $fh = fopen($this->logfile, "a");
43                fwrite($fh, "\n\n");
44                fclose($fh);
45        }
46        function printr($ar){
47                $txt = "";
48                foreach ($ar as $nm => $val) {
49                        $txt .= "    ".$nm ." = " . $val . "\n";
50                }
51                $this->write($txt);
52        }
53}
54?>
Note: See TracBrowser for help on using the repository browser.