/[dtapublic]/to_be_filed/webprojs/php_libraries/php_library/macntr01/slog_syslog.inc
ViewVC logotype

Contents of /to_be_filed/webprojs/php_libraries/php_library/macntr01/slog_syslog.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 35 - (show annotations) (download)
Sat Oct 8 23:35:33 2016 UTC (8 years, 2 months ago) by dashley
File size: 3599 byte(s)
Initial commit.
1 <?php
2 //------------------------------------------------------------------------
3 //Marshall Aviation Center FBO Management Software
4 //Copyright (C)2005 David T. Ashley
5 //
6 //This program is free software; you can redistribute it and/or
7 //modify it under the terms of the GNU General Public License
8 //as published by the Free Software Foundation; either version 2
9 //of the License, or (at your option) any later version.
10 //
11 //This program is distributed in the hope that it will be useful,
12 //but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 //GNU General Public License for more details.
15 //
16 //You should have received a copy of the GNU General Public License
17 //along with this program; if not, write to the Free Software
18 //Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 //
20 //The author (David T. Ashley) may be contacted by e-mail at dta@e3ft.com
21 //and by postal mail at P.O. Box 918, Marshall MI 49068.
22 //------------------------------------------------------------------------
23 //Logging functions.
24 //
25 //These are written to the Apache error log.
26 //------------------------------------------------------------------------
27 //Defines the character membership for things that can be placed into
28 //system logs.
29 //
30 function slog_char_membership($c)
31 {
32 if (strstr(" ,.;:+-*/0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", $c))
33 return(1);
34 else
35 return(0);
36 }
37
38 //------------------------------------------------------------------------
39 //Forces a string into the set of characters allowed for logging.
40 //
41 function slog_logstring_member_force($s_in)
42 {
43 $len = strlen($s_in);
44
45 //Let's not allow anything in longer than 1023 characters, as this is very likely
46 //to break logging.
47 if ($len > 1023)
48 {
49 $s_in = substr($s_in, 0, 1023);
50 $len = strlen($s_in);
51 }
52
53 $s_out = "";
54 for ($i=0; $i<$len; $i++)
55 {
56 $c = substr($s_in, $i, 1);
57 if (slog_char_membership($c))
58 {
59 $s_out = $s_out . $c;
60 }
61 else
62 {
63 //Use an underscore as a filler.
64 $s_out = $s_out . "_";
65 }
66 }
67
68 return($s_out);
69 }
70
71 //------------------------------------------------------------------------
72 //Date/time format used for logging. This function returns
73 //the canonical date/time string.
74 //
75 function slog_datetime_string()
76 {
77 $s = date("D m/d/y H:i:s");
78 return($s);
79 }
80
81 //------------------------------------------------------------------------
82 //Errors (something very wrong).
83 //
84 function slog_error($msg)
85 {
86 $logged_msg = "[ERR_, ". slog_datetime_string() . "] " . slog_logstring_member_force($msg);
87 error_log($logged_msg);
88 }
89
90 //------------------------------------------------------------------------
91 //Warnings (something odd and/or potentially dangerous).
92 //
93 function slog_warn($msg)
94 {
95 $logged_msg = "[WARN, ". slog_datetime_string() . "] " . slog_logstring_member_force($msg);
96 error_log($logged_msg);
97 }
98
99 //------------------------------------------------------------------------
100 //Informational entries (routine occurrences where there might be some
101 //benefit of tracking it later.
102 //
103 function slog_info($msg)
104 {
105 $logged_msg = "[INFO, ". slog_datetime_string() . "] " . slog_logstring_member_force($msg);
106 error_log($logged_msg);
107 }
108
109 //------------------------------------------------------------------------
110 ?>

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25