Squid Web Cache v8/master
Loading...
Searching...
No Matches
support_log.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2026 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
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 along
27 * with this program; if not, see <https://www.gnu.org/licenses/>.
28 *
29 * -----------------------------------------------------------------------------
30 */
31
32#include "squid.h"
33
34#if HAVE_LDAP
35
36#include "support.h"
37#include <ctime>
38
39const char *
40LogTime()
41{
42 static time_t last_t = 0;
43 struct timeval now;
44 static char buf[128];
45
46 gettimeofday(&now, nullptr);
47 if (now.tv_sec != last_t) {
48 struct tm *tm;
49 time_t tmp = now.tv_sec;
50 tm = localtime(&tmp);
51 strftime(buf, 127, "%Y/%m/%d %H:%M:%S", tm);
52 last_t = now.tv_sec;
53 }
54 return buf;
55}
56/* default off */
57int log_enabled = 0;
58
59#ifndef __GNUC__
60/* under gcc a macro define in compat/debug.h is used instead */
61
62void
63log(char *format,...)
64{
65 if (!log_enabled)
66 return;
67 va_list args;
68 va_start(args, format);
69 vfprintf(stderr, format, args);
70 va_end(args);
71}
72
73void
74error(char *format,...)
75{
76 va_list args;
77 va_start(args, format);
78 vfprintf(stderr, format, args);
79 va_end(args);
80}
81
82void
83warn(char *format,...)
84{
85 va_list args;
86 va_start(args, format);
87 vfprintf(stderr, format, args);
88 va_end(args);
89}
90
91#endif /* __GNUC__ */
92#endif
93
void log(char *format,...)
void error(char *format,...)
void warn(char *format,...)
int log_enabled
const char * LogTime(void)