]>
Commit | Line | Data |
---|---|---|
b1218840 AJ |
1 | /* |
2 | * ----------------------------------------------------------------------------- | |
3 | * | |
4 | * Author: Markus Moeller (markus_moeller at compuserve.com) | |
5 | * | |
6 | * Copyright (C) 2007 Markus Moeller. All rights reserved. | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License as published by | |
10 | * the Free Software Foundation; either version 2 of the License, or | |
11 | * (at your option) any later version. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program; if not, write to the Free Software | |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. | |
21 | * | |
22 | * ----------------------------------------------------------------------------- | |
23 | */ | |
24 | ||
f7f3304a | 25 | #include "squid.h" |
b1218840 | 26 | |
1a22a39e | 27 | #if HAVE_LDAP |
b1218840 AJ |
28 | |
29 | #include "support.h" | |
074d6a40 | 30 | #include <ctime> |
b1218840 AJ |
31 | |
32 | const char * | |
33 | LogTime() | |
34 | { | |
b1218840 | 35 | static time_t last_t = 0; |
4ebcf1ce | 36 | struct timeval now; |
b1218840 AJ |
37 | static char buf[128]; |
38 | ||
39 | gettimeofday(&now, NULL); | |
40 | if (now.tv_sec != last_t) { | |
4ebcf1ce | 41 | struct tm *tm; |
27bfc2ae AJ |
42 | time_t tmp = now.tv_sec; |
43 | tm = localtime(&tmp); | |
2e881a6f A |
44 | strftime(buf, 127, "%Y/%m/%d %H:%M:%S", tm); |
45 | last_t = now.tv_sec; | |
b1218840 AJ |
46 | } |
47 | return buf; | |
48 | } | |
49 | /* default off */ | |
50 | int log_enabled = 0; | |
51 | ||
52 | #ifndef __GNUC__ | |
53 | /* under gcc a macro define in compat/debug.h is used instead */ | |
54 | ||
55 | void | |
56 | log(char *format,...) | |
57 | { | |
58 | if (!log_enabled) | |
2e881a6f | 59 | return; |
b1218840 AJ |
60 | va_list args; |
61 | va_start(args, format); | |
62 | vfprintf(stderr, format, args); | |
63 | va_end(args); | |
64 | } | |
65 | ||
66 | void | |
67 | error(char *format,...) | |
68 | { | |
69 | va_list args; | |
70 | va_start(args, format); | |
71 | vfprintf(stderr, format, args); | |
72 | va_end(args); | |
73 | } | |
74 | ||
75 | void | |
76 | warn(char *format,...) | |
77 | { | |
78 | va_list args; | |
79 | va_start(args, format); | |
80 | vfprintf(stderr, format, args); | |
81 | va_end(args); | |
82 | } | |
83 | ||
84 | #endif /* __GNUC__ */ | |
85 | #endif |