~oh-dev/openhealth/phit-tools

« back to all changes in this revision

Viewing changes to ihris-suite/lib/i2ce/tools/apache_tail.php

  • Committer: litlfred at ibiblio
  • Date: 2009-10-23 12:59:28 UTC
  • Revision ID: litlfred@ibiblio.org-20091023125928-u5lkafz0urm9t8eq
updated ihris-suite to 4.0.1-prerelease -- not debugged

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
}
53
53
 
54
54
 
 
55
$blue = "\033[34m";
 
56
$black = "\033[0m";
 
57
$red = "\033[31m";
 
58
$green = "\033[32m";
 
59
 
 
60
 
55
61
function processText($text) {
56
 
    $blue = "\033[34m";
57
 
    $black = "\033[0m";
58
 
    $red = "\033[31m";
59
 
    $green = "\033[32m";
 
62
    global $blue;
 
63
    global $black;
 
64
    global $red;
 
65
    global $green;
 
66
    $color = $blue;
60
67
    if (preg_match('/^\s*(.*)\s*(\\n)?,?\s*Error Type=([0-9]*),?\s*(.*)\s*$/',$text,$matches)) {
61
68
        $t_text =$matches[1] . ' ' . $matches[4];
62
69
        $type = (int)$matches[3];
63
70
        switch($type) {
64
71
        case E_USER_WARNING:
65
 
            $blue = $green;
 
72
            $color = $green;
66
73
            break;
67
74
        case E_USER_ERROR;
68
 
            $blue = $red;
 
75
            $color = $red;
69
76
            break;
70
77
        default;         
71
78
        break;
75
82
    }
76
83
    $t_text = str_replace('\t',"\t",$t_text);
77
84
    if (preg_match('/^(.*?)\s*(I2CE:.*php\:\d+\\)):\s*(.*)\s*(\\\\n)?\s,?\s*referer\s*(.*)\s*$/',$t_text,$matches)) {
78
 
        $matches[3] = str_replace('\n',"\n\t",$matches[3]);
79
 
        $matches[3] = preg_replace('/\s*$/m','',$matches[3]);
80
 
        return  $matches[1] . "\n\tRefered by " . $matches[5] . "\n\t" . $matches[2] . "\n\t" . $blue. $matches[3] .  "\n" . $black;
 
85
        $matches[2] = str_replace('\n',"\n\t      ",$matches[2]);
 
86
        $matches[3] = str_replace('\n',"\n\t",$matches[3]);
 
87
        $matches[3] = preg_replace('/\s*$/m','',$matches[3]);
 
88
        return  $matches[1] . "\n\tRefered by " . $matches[5] . "\n\t" . $matches[2] . "\n\t" . $color. $matches[3] .  "\n" . $black;
 
89
    } else if (preg_match('/^(.*?)\s*(I2CE:.*?__autoload):\s*(.*)\s*,?\s*referer:?\s*(.*)\s*$/',$t_text,$matches)) {
 
90
        $matches[2] = str_replace('\n',"\n\t      ",$matches[2]);
 
91
        $matches[3] = str_replace('\n',"\n\t",$matches[3]);
 
92
        $matches[3] = preg_replace('/\s*$/m','',$matches[3]);
 
93
        return  $matches[1] . "\n\tRefered by " . $matches[4] .  "\n\t" . $matches[2] . "()\n\t" . $color. $matches[3]. "\n" . $black;
81
94
    } else if (preg_match('/^(.*?)\s*(I2CE:.*?__call):\s*(.*)\s*,?\s*referer:?\s*(.*)\s*$/',$t_text,$matches)) {
 
95
        $matches[2] = str_replace('\n',"\n\t      ",$matches[2]);
82
96
        $matches[3] = str_replace('\n',"\n\t",$matches[3]);
83
97
        $matches[3] = preg_replace('/\s*$/m','',$matches[3]);
84
 
        return  $matches[1] . "\n\tRefered by " . $matches[4] .  "\n\t" . $matches[2] . "()\n\t" . $blue. $matches[3]. "\n" . $black;
 
98
        return  $matches[1] . "\n\tRefered by " . $matches[4] .  "\n\t" . $matches[2] . "()\n\t" . $color. $matches[3]. "\n" . $black;
85
99
    } else if (preg_match('/^(.*?)\s*(I2CE:.*?__call):\s*(.*)\s*$/',$t_text,$matches)) {
 
100
        $matches[2] = str_replace('\n',"\n\t      ",$matches[2]);
86
101
        $matches[3] = str_replace('\n',"\n\t",$matches[3]);
87
102
        $matches[3] = preg_replace('/\s*$/m','',$matches[3]);
88
 
        return  $matches[1] . "\n\t" .  $matches[2] . "()\n\t" . $blue. $matches[3]. "\n" . $black;
 
103
        return  $matches[1] . "\n\t" .  $matches[2] . "()\n\t" . $color. $matches[3]. "\n" . $black;
89
104
    } else if (preg_match('/^(.*?)\s*(I2CE:.*php\:\d+\\)):\s*(.*)\s*(\\\\n)?\s*$/',$t_text,$matches)) {
 
105
        $matches[2] = str_replace('\n',"\n\t      ",$matches[2]);
90
106
        $matches[3] = str_replace('\n',"\n\t",$matches[3]);
91
107
        $matches[3] = preg_replace('/\s*$/m','',$matches[3]);
92
 
        return $matches[1]  ."\n\t" .  $matches[2] . "\n\t" . $blue . $matches[3] . "\n". $black;
 
108
        return $matches[1]  ."\n\t" .  $matches[2] . "\n\t" . $color . $matches[3] . "\n". $black;
93
109
    } else if (preg_match('/^(.*\[client\s\d+\.\d+\.\d+\.\d+\])\s*\\(:\\):\s*(.*)\s*(\\\\n)?\s*,?\s*referer:?\s*(.*)\s*$/',$t_text,$matches)) {
94
 
        $matches[2] = str_replace('\n',"\n\t",$matches[2]);
 
110
        $matches[2] = str_replace('\n',"\n\t      ",$matches[2]);
95
111
        $matches[2] = preg_replace('/\s*$/m','',$matches[2]);
96
 
        return $matches[1] . "\n\tRefered by " . $matches[4] . "\n\t" . $blue. $matches[2] . "\n" . $black;
 
112
        return $matches[1] . "\n\tRefered by " . $matches[4] . "\n\t" . $color. $matches[2] . "\n" . $black;
97
113
    } else if (preg_match('/^(.*?)\s*(I2CE:.*)\s*\\(:\\):\s*(.*)\s*([Cc]alled.*php)\s*(\\\\n)?\s*(.*)\s*,?\s*referer:?\s*(.*)\s*$/',$t_text,$matches)) {
 
114
        $matches[2] = str_replace('\n',"\n\t      ",$matches[2]);
98
115
        $matches[6] = str_replace('\n',"\n\t",$matches[6]);
99
116
        $matches[6] = preg_replace('/\s*$/m','',$matches[6]);
100
117
        return $matches[1]  . "\n\tRefered by " . $matches[7] ."\n\t" . $matches[4] .
101
 
            "\n\t" . $matches[2] .  $blue."\n\t" . $matches[3] . "\n\t" . $matches[6] . "\n" . $black; 
 
118
            "\n\t" . $matches[2] .  $color."\n\t" . $matches[3] . "\n\t" . $matches[6] . "\n" . $black; 
102
119
    } else if (preg_match('/^(.*?)\s*(I2CE:.*)\s*\\(:\\):\s*(.*)\s*([Cc]alled.*php)\s*(\\\\n)?\s*(.*)\s*$/',$t_text,$matches)) {
 
120
        $matches[2] = str_replace('\n',"\n\t      ",$matches[2]);
103
121
        $matches[6] = str_replace('\n',"\n\t",$matches[6]);
104
122
        $matches[6] = preg_replace('/\s*$/m','',$matches[6]);
105
123
        return $matches[1]  . "\n\t" . $matches[4] . 
106
 
            "\n\t" . $matches[2] .$blue. "\n\t" . $matches[3] . "\n\t" . $matches[6] . "\n" . $black; 
 
124
            "\n\t" . $matches[2] .$color. "\n\t" . $matches[3] . "\n\t" . $matches[6] . "\n" . $black; 
 
125
    } else if (preg_match('/^(.*?)\s*(I2CE:\s*.*?):\s*(.*)\s*,?\s*referer:?\s*(.*)\s*$/',$t_text,$matches)) {
 
126
        $matches[2] = str_replace('\n',"\n\t      ",$matches[2]);
 
127
        $matches[3] = str_replace('\n',"\n\t",$matches[3]);
 
128
        $matches[3] = preg_replace('/\s*$/m','',$matches[3]);
 
129
        return $matches[1]  . "\n\tRefered by " . $matches[4] ."\n\t" . $matches[2] .
 
130
            "\n\t$color" . $matches[3] .   "$black\n";
 
131
    } else if (preg_match('/^(.*?)\s*(I2CE: :Fatal Error:)\s*(.*)\s*$/',$t_text,$matches)) {
 
132
        $matches[3] = str_replace('\n',"\n\t      ",$matches[3]);
 
133
        $matches[3] = rtrim(str_replace('\n',"\n\t",$matches[3]));
 
134
        return $matches[1] . "\n" . $red . "************FATAL ERROR************:\n" . $matches[3] . "\n************FATAL ERROR************" . $black . "\n";
107
135
    } else if (preg_match('/Segmentation fault/',$t_text) || preg_match('/glibc detected/',$t_text)) {
108
 
        return $red . $t_text . $black;
 
136
        return $red . "\n" . $t_text . $black . "\n";
109
137
    } else { 
110
138
        return $text; 
111
139
    }