]> git.ipfire.org Git - thirdparty/squid.git/blob - helpers/external_acl/kerberos_ldap_group/support_log.cc
merge from trunk
[thirdparty/squid.git] / helpers / external_acl / kerberos_ldap_group / support_log.cc
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
25 #include "squid.h"
26
27 #ifdef HAVE_LDAP
28
29 #include "support.h"
30 #include <ctime>
31
32 const char *
33 LogTime()
34 {
35 static time_t last_t = 0;
36 struct timeval now;
37 static char buf[128];
38
39 gettimeofday(&now, NULL);
40 if (now.tv_sec != last_t) {
41 struct tm *tm;
42 time_t tmp = now.tv_sec;
43 tm = localtime(&tmp);
44 strftime(buf, 127, "%Y/%m/%d %H:%M:%S", tm);
45 last_t = now.tv_sec;
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)
59 return;
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