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