This file is indexed.

/usr/include/falcon/srv/logging_srv.h is in falconpl-dev 0.9.6.9-git20120606-2.

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
/*
   FALCON - The Falcon Programming Language.
   FILE: logging_srv.h

   Logging module -- module service classes
   -------------------------------------------------------------------
   Author: Giancarlo Niccolai
   Begin: Sat, 12 Sep 2009 16:42:41 +0200

   -------------------------------------------------------------------
   (C) Copyright 2009: the FALCON developers (see list in AUTHORS file)

   See LICENSE file for licensing details.
*/


#ifndef flc_logging_srv_H
#define flc_logging_srv_H

#include <falcon/setup.h>
#include <falcon/service.h>
#include <falcon/string.h>
#include <falcon/timestamp.h>
#include <falcon/mt.h>

namespace Falcon
{

#define LOGLEVEL_FATAL 0
#define LOGLEVEL_ERROR 1
#define LOGLEVEL_WARN  2
#define LOGLEVEL_INFO  3
#define LOGLEVEL_LOW   4
#define LOGLEVEL_DEBUG 5
#define LOGLEVEL_D1    6
#define LOGLEVEL_D2    7

#define LOGLEVEL_ALL   100

class LogArea;
class Stream;
class FileStream;

/** Abstract base class for logging channels. */
class LogChannel: public Runnable
{
   volatile int m_refCount;
   friend class LogArea;

   Mutex m_msg_mtx;
   Event m_message_incoming;
   SysThread* m_thread;

protected:

   TimeStamp m_ts;
   numeric m_startedAt;

protected:

   class LogMessage
   {
   public:
      String m_areaName;
      String m_modName;
      String m_caller;
      int m_level;
      String m_msg;
      uint32 m_code;
      LogMessage* m_next;

      LogMessage( const String& areaName, const String& modname, const String& caller, int level, const String& msg, uint32 code = 0 ):
         m_areaName( areaName ),
         m_modName( modname ),
         m_caller( caller ),
         m_level( level ),
         m_msg( msg ),
         m_code( code ),
         m_next(0)
         {}
   };

   virtual void pushFront( LogMessage* lm );
   virtual void pushBack( LogMessage* lm );

private:
   LogMessage* m_msg_head;
   LogMessage* m_msg_tail;
   bool m_terminate;
   bool m_bTsReady;

   void updateTS()
   {
      if( ! m_bTsReady )
      {
         m_bTsReady = true;
         m_ts.currentTime();
      }
   }

   void start();
   bool expandMessage( LogMessage* msg, const String& fmt, String& target );

protected:
   uint32 m_level;
   String m_format;

   virtual void stop();
   /** Override this to send a pre-formatted message to the output device */
   virtual void writeLogEntry( const String& entry, LogMessage* pOrigMsg ) = 0;
   virtual ~LogChannel();
public:

   LogChannel( uint32 l = LOGLEVEL_ALL );
   LogChannel( const String &format, uint32 l = LOGLEVEL_ALL );

   inline void level( uint32 l ) { m_level = l; }
   inline uint32 level() const { return m_level; }

   virtual void setFormat( const String& fmt );
   virtual void getFormat( String& fmt );

   virtual void incref();
   virtual void decref();

   virtual void log( LogArea* area, uint32 level, const String& msg, uint32 code = 0 );

   inline void log( uint32 level, const String& msg, uint32 code = 0 ) { log( "", "", level, msg, code ); }
   inline void log( const String& tgt, const String& source, uint32 level, const String& msg, uint32 code = 0 )
   {
      log( tgt, source, "", level, msg );
   }
   virtual void log( const String& tgt, const String& source, const String& function, uint32 level, const String& msg, uint32 code = 0 );
   virtual void* run();

};

/** Area for logging.
 *
 */
class LogArea: public BaseAlloc
{
   volatile int m_refCount;
   String m_name;

   virtual ~LogArea();

   class ChannelCarrier
   {
   public:
      ChannelCarrier* m_next;
      ChannelCarrier* m_prev;

      LogChannel* m_channel;

      ChannelCarrier( LogChannel* chn ):
         m_channel( chn )
      {}
   };

   ChannelCarrier* m_head_chan;
   mutable Mutex m_mtx_chan;

public:
   LogArea( const String& name ):
      m_refCount(1),
      m_name( name ),
      m_head_chan( 0 )
   {}

   virtual void log( uint32 level, const String& msg, uint32 code = 0 ) const
   {
      log( level, "", "", msg, code );
   }

   virtual void log( uint32 level, const String& source, const String& msg, uint32 code = 0 ) const
   {
      log( level, source, "", msg, code );
   }

   virtual void log( uint32 level, const String& source, const String& func, const String& msg, uint32 code = 0 ) const;

   virtual void incref();
   virtual void decref();

   virtual const String& name() const { return m_name; }

   virtual void addChannel( LogChannel* chn );
   virtual void removeChannel( LogChannel* chn );
   virtual int minlog() const;
};


class LogChannelStream: public LogChannel
{
protected:
   Stream* m_stream;
   bool m_bFlushAll;
   virtual void writeLogEntry( const String& entry, LogMessage* pOrigMsg );
   virtual ~LogChannelStream();

public:
   LogChannelStream( Stream* s, int level=LOGLEVEL_ALL );
   LogChannelStream( Stream* s, const String &fmt, int level=LOGLEVEL_ALL );


   inline bool flushAll() const { return m_bFlushAll; }
   inline void flushAll( bool b ) { m_bFlushAll = b; }
};


class LogChannelFiles: public LogChannel
{
private:
   void inner_rotate();
   TimeStamp m_opendate;


protected:
   FileStream* m_stream;
   bool m_bFlushAll;

   String m_path;
   int64 m_maxSize;
   int32 m_maxCount;
   bool m_bOverwrite;
   int32 m_maxDays;
   bool m_isOpen;


   virtual void expandPath( int32 number, String& path );
   virtual void writeLogEntry( const String& entry, LogMessage* pOrigMsg );
   virtual ~LogChannelFiles();

public:
   LogChannelFiles( const String& path, int level=LOGLEVEL_ALL );
   LogChannelFiles( const String& path, const String &fmt, int level=LOGLEVEL_ALL );

   /** Overloads the base log request opening the channel if necessary */
   virtual void log( const String& tgt, const String& source, const String& function, uint32 level, const String& msg, uint32 code = 0 );

   /** Opens the log. May throw an IoError. */
   virtual void open();

   /** Truncates the log. May throw an IoError. */
   virtual void reset();

   /** Perform a rollover. */
   virtual void rotate();

   inline LogChannelFiles& flushAll( bool b ) { m_bFlushAll = b; return *this;}
   inline LogChannelFiles& maxSize( int64 ms ) { m_maxSize = ms; return *this;}
   inline LogChannelFiles& maxCount( int32 mc ) { m_maxCount = mc; return *this;}
   inline LogChannelFiles& overwrite( bool ow ) { m_bOverwrite = ow; return *this;}
   inline LogChannelFiles& maxDays( int32 md ) { m_maxDays = md; return *this;}

   inline bool flushAll() const { return m_bFlushAll; }
   inline int64 maxSize() const { return m_maxSize; }
   inline int32 maxCount() const { return m_maxCount;}
   inline bool overwrite() const { return m_bOverwrite;}
   inline int32 maxDays() const { return m_maxDays;}
   inline const String& path() const { return m_path;}
};


/** Logging for Syslog (POSIX) or Event Logger (MS-Windows).  */
class LogChannelSyslog: public LogChannel
{
private:
   void* m_sysdata;

protected:
   String m_identity;
   uint32 m_facility;

   virtual void writeLogEntry( const String& entry, LogMessage* pOrigMsg );
   virtual void init();

   virtual ~LogChannelSyslog();

public:
   LogChannelSyslog( const String& identity, uint32 facility = 0, int level=LOGLEVEL_ALL );
   LogChannelSyslog( const String& identity, const String &fmt, uint32 facility = 0, int level=LOGLEVEL_ALL );
};


#define LOGSERVICE_NAME "LogService"

/** Publishes the Log system as "LogService".
 *
 */
class LogService: public Service
{
public:
   LogService();

   virtual LogArea* makeLogArea( const String& name ) const;
   virtual LogChannelStream* makeChnStream( Stream* s, int level=LOGLEVEL_ALL ) const;
   virtual LogChannelStream* makeChnStream( Stream* s, const String &fmt, int level=LOGLEVEL_ALL ) const;

   virtual LogChannelSyslog* makeChnSyslog( const String& identity, uint32 facility = 0, int level=LOGLEVEL_ALL ) const;
   virtual LogChannelSyslog* makeChnSyslog( const String& identity, const String &fmt, uint32 facility = 0, int level=LOGLEVEL_ALL ) const;

   virtual LogChannelFiles* makeChnlFiles( const String& path, int level=LOGLEVEL_ALL ) const;
   virtual LogChannelFiles* makeChnFiles( const String& path, const String &fmt, int level=LOGLEVEL_ALL ) const;

};

}

#endif

/* end of logging_srv.h */