This file is indexed.

/usr/include/commoncpp/slog.h is in libucommon-dev 6.0.7-1.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
// Copyright (C) 1999-2005 Open Source Telecom Corporation.
// Copyright (C) 2006-2010 David Sugar, Tycho Softworks.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// As a special exception, you may use this file as part of a free software
// library without restriction.  Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License.  This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
//
// This exception applies only to the code released under the name GNU
// Common C++.  If you copy code from other releases into a copy of GNU
// Common C++, as the General Public License permits, the exception does
// not apply to the code that you add in this way.  To avoid misleading
// anyone as to the status of such modified files, you must delete
// this exception notice from them.
//
// If you write modifications of your own for GNU Common C++, it is your choice
// whether to permit this exception to apply to your modifications.
// If you do not wish that, delete this exception notice.
//

/**
 * @file commoncpp/slog.h
 * @short System logging facilities abstraction.
 **/

#ifndef COMMONCPP_SLOG_H_
#define COMMONCPP_SLOG_H_

#include <cstdio>

#ifndef COMMONCPP_CONFIG_H_
#include <commoncpp/config.h>
#endif

#ifndef COMMONCPP_STRING_H_
#include <commoncpp/string.h>
#endif

#ifndef COMMONCPP_THREAD_H_
#include <commoncpp/thread.h>
#endif

NAMESPACE_COMMONCPP

/**
 * The slog class is used to stream messages to the system's logging facility (syslogd).
 * A default <code>slog</code> object is used to avoid confusion with the native syslog
 * facility and to imply a logical relationship to the C++ <code>clog()</code>.
 *
 * The key difference is that the <code>slog</code> object sends it's output to the
 * system logging daemon (typically syslogd) rather than through stderr.
 * <code>slog</code> can be streamed with the <code><<</code> operator just
 * like <code>clog</code>; a default slog object is pre-initialized, and you stream
 * character data to it.
 *
 * The <code>slog</code> allows one to specify logging levels and other properties through the <code>()</code> operators.
 * Hence, once can do:
 *
 * <code><pre>
 * slog("mydaemon", SLOG_DAEMON, SLOG_EMERGENCY) << I just died << endl; </pre></code>
 *
 * or things like:
 *
 * <code><pre>
 * slog("mydaemon", SLOG_DAEMON);
 * slog(SLOG_INFO) << "daemon initalized" << endl; </pre></code>
 *
 * The intent is to be as common-place and as convenient to use as the stderr based clog facility
 * found in C++, and this is especially useful for C++ daemons.
 *
 * The <code>std::flush</code> manipulator doesn't work.  Either the
 * <code>std::endl</code> or <code>std::ends</code> manipulators
 * must be used to cause the output to be sent to the daemon.
 *
 * When this class is used on a system that doesn't have the syslog headers
 * (i.e. a non-posix win32 box), the output goes to the a file with the same name
 * as the syslog identifier string with '.log' appended to it.  If the identifier string ends in
 * '.exe', the '.exe' is removed before the '.log' is appened. (e.g. the identifier foo.exe will
 * generate a log file named foo.log)
 *
 * @author David Sugar <dyfet@ostel.com>
 * <br>Minor docs & hacks by Jon Little <littlej@arlut.utexas.edu>
 *
 * @short system logging facility class.
 */
class __EXPORT Slog : protected std::streambuf, public std::ostream
{
public:
    typedef enum Class {
        classSecurity,
        classAudit,
        classDaemon,
        classUser,
        classDefault,
        classLocal0,
        classLocal1,
        classLocal2,
        classLocal3,
        classLocal4,
        classLocal5,
        classLocal6,
        classLocal7
    } Class;

    typedef enum Level {
        levelEmergency = 1,
        levelAlert,
        levelCritical,
        levelError,
        levelWarning,
        levelNotice,
        levelInfo,
        levelDebug
    } Level;

private:
    pthread_mutex_t lock;
    FILE *syslog;
    int priority;
    Level  _level;
    bool _enable;
    bool _clogEnable;

protected:
    /**
     * This is the streambuf function that actually outputs the data
     * to the device.  Since all output should be done with the standard
     * ostream operators, this function should never be called directly.
     */
    int overflow(int c);

public:
    /**
     * Default (and only) constructor.  The default log level is set to
     * SLOG_DEBUG.  There is no default log facility set.  One should be
     * set before attempting any output.  This is done by the <code>open()</code> or the
     * <code>operator()(const char*, Class, Level)</code>
     * functions.
     */
    Slog(void);

    virtual ~Slog(void);

    void close(void);

    /**
     * (re)opens the output stream.
     * @param ident The identifier portion of the message sent to the syslog daemon.
     * @param grp The log facility the message is sent to
     */
    void open(const char *ident, Class grp = classUser);

    /**
     * Sets the log identifier, level, and class to use for subsequent output
     * @param ident The identifier portion of the message
     * @param grp The log facility the message is sent to
     * @param level The log level of the message
     */
    Slog &operator()(const char *ident, Class grp = classUser,
             Level level = levelError);

    /**
     * Changes the log level and class to use for subsequent output
     * @param level The log level of the message
     * @param grp The log facility the message is sent to
     */
    Slog &operator()(Level level, Class grp = classDefault);

    /**
     * Does nothing except return *this.
     */
    Slog &operator()(void);

    /**
     * Print a formatted syslog string.
     *
     * @param format string.
     */
    void error(const char *format, ...);

    /**
     * Print a formatted syslog string.
     *
     * @param format string.
     */
    void warn(const char *format, ...);

    /**
     * Print a formatted syslog string.
     *
     * @param format string.
     */
    void debug(const char *format, ...);

    /**
     * Print a formatted syslog string.
     *
     * @param format string.
     */
    void emerg(const char *format, ...);

    /**
     * Print a formatted syslog string.
     *
     * @param format string.
     */
    void alert(const char *format, ...);

    /**
     * Print a formatted syslog string.
     *
     * @param format string.
     */
    void critical(const char *format, ...);

    /**
     * Print a formatted syslog string.
     *
     * @param format string.
     */
    void notice(const char *format, ...);

    /**
     * Print a formatted syslog string.
     *
     * @param format string.
     */
    void info(const char *format, ...);

    /**
     * Sets the logging level.
     * @param enable is the logging level to use for further output
     */
    inline void level(Level enable)
        {_level = enable;};

    /**
     * Enables or disables the echoing of the messages to clog in addition
     * to the syslog daemon.  This is enabled by the default class constructor.
     * @param f true to enable, false to disable clog output
     */
    inline void clogEnable(bool f=true)
        {_clogEnable = f;};

    inline Slog &warn(void)
        {return operator()(Slog::levelWarning);};

    inline Slog &error(void)
        {return operator()(Slog::levelError);};

    inline Slog &debug(void)
        {return operator()(Slog::levelDebug);};

    inline Slog &emerg(void)
        {return operator()(Slog::levelEmergency);};

    inline Slog &alert(void)
        {return operator()(Slog::levelAlert);};

    inline Slog &critical(void)
        {return operator()(Slog::levelCritical);};

    inline Slog &notice(void)
        {return operator()(Slog::levelNotice);};

    inline Slog &info(void)
        {return operator()(Slog::levelInfo);};

};

extern __EXPORT Slog    slog;

END_NAMESPACE

#endif