This file is indexed.

/usr/include/cc++/applog.h is in libcommoncpp2-dev 1.8.1-6.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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
// Copyright (C) 2005-2010 Angelo Naselli, Penta Engineering s.r.l.
//
// 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.
//
// 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 applog.h
 * @short Application logging facilities abstraction.
 **/


#ifndef ___APPLOG_H___
#define ___APPLOG_H___

#ifndef CCXX_SLOG_H_
#include <cc++/slog.h>
#endif

#include <cc++/exception.h>

#include <string>
#include <sstream>
#include <iostream>
#include <map>

#ifdef  CCXX_NAMESPACES
using namespace std;

namespace ost
{
#endif
/**
 * Produces a dump of a buffer in a hexdump way with its
 * code Ascii translation and relative buffer address.
 *
 * For instance:
 * 0000000 - 77 98 21 49 0e 00 05 00 40 1c 01 1c 2f 00 00 00 w.!I....@.../...
 *
 */
class __EXPORT HEXdump
{
  protected:
    /**
     * output string
     */
    std::string _str;

  public:
    // max_len: max number of bytes to be printed. 0 prints all.
    /**
     * HEXdump constructor.
     *
     * @param buffer    buffer to be "hexdumped"
     * @param buff_len  buffer length
     * @param max_len   max number of bytes to be "hexdumped". Usefull to
     *                  truncate output. mas_len=0 does prints all.
     */
    HEXdump(const unsigned char *buffer, int buff_len, int max_len = 200);

    /**
     * HEXdump destructor.
     */
    virtual ~HEXdump() { _str = string();}

    /**
     * const char* cast provided for conveneince.
     */

    const char * c_str() const
    {
      return _str.c_str();
    }

    /**
     * string cast provided for conveneince.
     */
    std::string str()
    {
      return _str;
    }

    /**
    * operator <<
    * @param hd hexdump.
    * @return application logger stream
    */
    friend std::ostream& operator<< (std::ostream& out, const HEXdump &hd)
    {
      out << hd.c_str();
      return out;
    }

};

#ifdef  CCXX_EXCEPTIONS
/**
 * Applog exception, used for memory problems at the moment
 *
 */
class __EXPORT AppLogException : public ost::Exception
{
  public:
    /**
     * Constructor.
     * @param what_arg exception string
     */
    AppLogException(const std::string &what_arg) : ost::Exception(what_arg) {};

};
#endif

class AppLogPrivate;

/**
 * Application logger is a class that implements a logger that can be used
 * by applications to save log file somewhere on the system.
 *
 * It uses ost::slog to write to syslog and std::clog to write to standard
 * output.
 *
 * It provides either a stream oriented logger or a old printf style one.
 *
 * It can be used to log directly on a file or in a spooler like way. Latter
 * uses a ost::ThreadQueue to implement a thread safe access to logger.
 *
 * It provides a global stream variable called ost::alog.
 *
 * It provides an AppLog::Ident class that represents a module name for
 * instance that can be used to tag logs. Logging levels are the same
 * defined into ost::Slog:
 * Slog::levelEmergency
 * Slog::levelAlert
 * Slog::levelCritical
 * Slog::levelError
 * Slog::levelWarning
 * Slog::levelNotice
 * Slog::levelInfo
 * Slog::levelDebugfrom.
 *
 * Example of usage: alog << mod_name << debug << "Hello world!" << std::endl;
 */
class __EXPORT AppLog : protected streambuf, public ostream
{
  protected:
    // d pointer
    AppLogPrivate *d;
    void writeLog(bool endOfLine = true);
    static map<string, Slog::Level> *assoc;

  public:
    /**
     * Ident class that represents module name.
     */
    class __EXPORT Ident
    {
      private:
        std::string _ident;
      public:

        /**
         * Constructor.
         */
        Ident() {};

        /**
         * Desctructor.
         */
        ~Ident() {};

        /**
         * Copy constructor.
         */
        Ident(Ident& id) {_ident = id._ident;}

        /**
         * const char* constructor, provided for convenience.
         */
        Ident(const char *str) : _ident(str) {};

        /**
         * std::string cast.
         */
        std::string& str() {return _ident;}

        /**
         * Assignment operator (string).
         */
        Ident& operator= (std::string &st) {_ident = st; return *this;}

        /**
         * Assignment operator (const char[]), provided for convenience.
         */
        Ident& operator= (const char str[]) {_ident = str; return *this;}

        /**
         * const char* cast provided for conveneince.
         */
        const char* c_str() {return _ident.c_str();}
    };

#ifndef WIN32
    /**
     * Constructor for a customized logger.
     * @param logFileName log file name.
     * @param logDirectly true to write directly to file, false to use
     *                    a spooler like logger.
     * @param usePipe     true to use pipe instead of file, false otherwise
     */
    AppLog(const char* logFileName = NULL, bool logDirectly = false , bool usePipe = false);
#else
    /**
    * Constructor for a customized logger.
    * @param logFileName log file name.
    * @param logDirectly true to write directly to file, false to use
    *                    a spooler like logger.
    */
    AppLog(const char* logFileName = NULL, bool logDirectly = false);
#endif
    /**
     * Destructor
     */
    virtual ~AppLog();

    /**
     * Subscribes the current thread to logger, it reserves thread safe
     * buffer for it.
     */
    void subscribe();

    /**
     * Unsubscribes the current thread from logger.
     */
    void unsubscribe();

#ifndef WIN32
    /**
     * Allows to set up ost::alog parameters.
     * @param FileName log file name.
     * @param logDirectly true to write directly to file, false to use
     *                    a spooler like logger.
     * @param usePipe     true to use pipe instead of file, false otherwise
     */
    void logFileName(const char* FileName, bool logDirectly = false, bool usePipe = false);
#else
    /**
     * Allows to set up ost::alog parameters.
     * @param FileName log file name.
     * @param logDirectly true to write directly to file, false to use
     *                    a spooler like logger.
     */
    void logFileName(const char* FileName, bool logDirectly = false);
#endif
    /**
     * if logDirectly is set it closes the file.
     */
    void close(void);

    /**
     * Sets the log level.
     * @param enable log level.
     */
    void level(Slog::Level enable);

    /**
     * Enables clog output.
     * @param en true to enable clog output.
     */
    void clogEnable(bool en = true);

    /**
     * Enables slog output for error level messages.
     * @param en true to enable slog output.
     */
    void slogEnable(bool en = true);

    /**
     * Sets the level for that ident.
     * @param ident ident (module name for instance).
     * @param level level
     */
    void identLevel(const char *ident, Slog::Level level);

    /**
     * Opens the file if not already and sets ident
     * @param ident module name for instance.
     */
    void open(const char *ident);

    /**
     * stream overflow() overload.
     * @param c character to be managed
     * @return c
     */
    virtual int overflow(int c);

    /**
     * stream sync() overload
     */
    virtual int sync();

#ifdef HAVE_SNPRINTF

    /**
     * emerg level printf style method, provided for convenience.
     * @param format printf format
     */
    void emerg(const char *format, ...);

    /**
     * alert level printf style method, provided for convenience.
     * @param format printf format
     */
    void alert(const char *format, ...);

    /**
     * critical level printf style method, provided for convenience.
     * @param format printf format
     */
    void critical(const char *format, ...);

    /**
     * error level printf style method, provided for convenience.
     * @param format printf format
     */
    void error(const char *format, ...);

    /**
     * warn level printf style method, provided for convenience.
     * @param format printf format
     */
    void warn(const char *format, ...);

    /**
     * notice level printf style method, provided for convenience.
     * @param format printf format
     */
    void notice(const char *format, ...);

    /**
     * info level printf style method, provided for convenience.
     * @param format printf format
     */
    void info(const char *format, ...);

    /**
     * debug level printf style method, provided for convenience.
     * @param format printf format
     */
    void debug(const char *format, ...);
#endif

    /**
     * operator to change ident and log level
     * @param ident ident (module name for instance)
     * @param level new log level
     * @return application logger stream
     */
    AppLog &operator()(const char *ident, Slog::Level level = Slog::levelError);

    /**
     * operator to change ident
     * @param ident ident (module name for instance)
     * @return application logger stream
     */
    inline AppLog& operator()(Ident &ident)
    {
      open(ident.c_str());
      return *this;
    }

    /**
     * operator to change logging level
     * @param level new log level
     * @return application logger stream
     */
    AppLog &operator()(Slog::Level level);

    /**
     * manipulator operator, to change print levels.
     * @param (* pfManipulator)(AppLog &)
     * @return application logger stream
     */
    AppLog& operator<< (AppLog& (*pfManipulator)(AppLog&));

    /**
     * manipulator operator, to use ostream manipulators (i.e. std::endl,...)
     * @param (* pfManipulator)(AppLog &)
     * @return application logger stream
     */
    AppLog& operator<< (ostream& (*pfManipulator)(ostream&));

    friend  ostream& operator << (ostream &out, AppLog & al)
    {
      return al;
    }

    /**
     * operator <<
     * @param ident module name for instance.
     * @return application logger stream
     */
    inline AppLog& operator<< (Ident &ident)
    {
      open(ident.c_str());
      return *this;
    }


    /**
     * warn level
     * @return application logger stream
     */
    inline AppLog &warn(void)
    {return operator()(Slog::levelWarning);}

    /**
     * error level
     * @return application logger stream
     */
    AppLog &error(void)
    { return operator()(Slog::levelError);}

    /**
     * debug level
     * @return application logger stream
     */
    inline AppLog &debug(void)
    {return operator()(Slog::levelDebug);}

    /**
     * emerg level
     * @return application logger stream
     */
    inline AppLog &emerg(void)
    {return operator()(Slog::levelEmergency);}

    /**
     * alert level
     * @return application logger stream
     */
    inline AppLog &alert(void)
    {return operator()(Slog::levelAlert);}

    /**
     * critical level
     * @return application logger stream
     */
    inline AppLog &critical(void)
    {return operator()(Slog::levelCritical);}

    /**
     * notice level
     * @return application logger stream
     */
    inline AppLog &notice(void)
    {return operator()(Slog::levelNotice);}

    /**
     * info level
     * @return application logger stream
     */
    inline AppLog &info(void)
    {return operator()(Slog::levelInfo);}

    /**
     * Translates level from string to Slog::Level, useful for
     * configuration files for instance.
     * Valid level names are:
     * "emerg" for Slog::levelEmergency
     * "alert" for Slog::levelAlert
     * "critical" for Slog::levelCritical
     * "error" for Slog::levelError
     * "warn" for Slog::levelWarning
     * "notice" for Slog::levelNotice
     * "info" for Slog::levelInfo
     * "debug" for Slog::levelDebug
     * @param name Slog Level name
     * @return Slog level value
     */
    static Slog::Level levelTranslate(string name)
    {
      map<string, Slog::Level>::iterator  it = assoc->find(name);

      return (it != assoc->end()) ? it->second : Slog::levelEmergency;
    }

};

/**
 * Manipulator for debug level
 * @param sl application logger stream
 * @return application logger stream
 */
__EXPORT inline AppLog &debug(AppLog& sl)
{return sl.operator()(Slog::levelDebug);}

/**
 * Manipulator for warn level
 * @param sl application logger stream
 * @return application logger stream
 */
__EXPORT inline AppLog &warn(AppLog& sl)
{return sl.operator()(Slog::levelWarning);}

/**
 * Manipulator for error level
 * @param sl application logger stream
 * @return application logger stream
 */
__EXPORT inline AppLog &error(AppLog& sl)
{ return sl.operator()(Slog::levelError);}

/**
 * Manipulator for emerg level
 * @param sl application logger stream
 * @return application logger stream
 */
__EXPORT inline AppLog &emerg(AppLog& sl)
{return sl.operator()(Slog::levelEmergency);}

/**
 * Manipulator for alert level
 * @param sl application logger stream
 * @return application logger stream
 */
__EXPORT inline AppLog &alert(AppLog& sl)
{return sl.operator()(Slog::levelAlert);}

/**
 * Manipulator for critical level
 * @param sl application logger stream
 * @return application logger stream
 */
__EXPORT inline AppLog &critical(AppLog& sl)
{return sl.operator()(Slog::levelCritical);}

/**
  * Manipulator for notice level
  * @param sl application logger stream
  * @return application logger stream
  */
__EXPORT inline AppLog &notice(AppLog& sl)
{return sl.operator()(Slog::levelNotice);}

/**
 * Manipulator for info level
 * @param sl application logger stream
 * @return application logger stream
 */
__EXPORT inline AppLog &info(AppLog& sl)
{return sl.operator()(Slog::levelInfo);}

/**
 * alog global log stream definition
 */
__EXPORT extern AppLog alog;

#ifdef CCXX_NAMESPACES
} //namespace
#endif

#endif //___APPLOG_H___