This file is indexed.

/usr/include/gnuradio/logger.h is in gnuradio-dev 3.7.10.1-2+b3.

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
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
/* -*- c++ -*- */
/*
 * Copyright 2012-2013 Free Software Foundation, Inc.
 *
 * This file is part of GNU Radio
 *
 * GNU Radio 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 3, or (at your option)
 * any later version.
 *
 * GNU Radio 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 GNU Radio; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street,
 * Boston, MA 02110-1301, USA.
 */

/*******************************************************************************
* Author: Mark Plett
* Description:
*   The gr::logger module wraps the log4cpp library for logging in gnuradio
*******************************************************************************/

#ifndef INCLUDED_GR_LOGGER_H
#define INCLUDED_GR_LOGGER_H

/*!
* \ingroup logging
* \brief GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
*
*/

#ifndef ENABLE_GR_LOG
#define ENABLE_GR_LOG
#endif
#ifndef HAVE_LOG4CPP
#define HAVE_LOG4CPP
#endif

#ifdef _MSC_VER
typedef unsigned short mode_t;
#else
#include <sys/types.h>
#endif

#include <gnuradio/api.h>
#include <assert.h>
#include <iostream>
#include <time.h>
#include <boost/filesystem.hpp>
#include <boost/thread.hpp>
#include <boost/format.hpp>
#include <pmt/pmt.h>

#ifdef ENABLE_GR_LOG

// We have three configurations... first logging to stdout/stderr
#ifndef HAVE_LOG4CPP

namespace gr {
  //#warning GR logging Enabled and using std::cout
  typedef std::string logger_ptr;
} /* namespace gr */

#define GR_LOG_DECLARE_LOGPTR(logger)
#define GR_LOG_ASSIGN_LOGPTR(logger,name)
#define GR_CONFIG_LOGGER(config)
#define GR_CONFIG_AND_WATCH_LOGGER(config,period)
#define GR_LOG_GETLOGGER(logger, name)
#define GR_SET_LEVEL(name, level)
#define GR_LOG_SET_LEVEL(logger, level)
#define GR_GET_LEVEL(name, level)
#define GR_LOG_GET_LEVEL(logger, level)
#define GR_ADD_APPENDER(name,appender)
#define GR_LOG_ADD_APPENDER(logger,appender)
#define GR_SET_APPENDER(name,appender)
#define GR_LOG_SET_APPENDER(logger,appender)
#define GR_ADD_CONSOLE_APPENDER(logger,target,pattern)
#define GR_LOG_ADD_CONSOLE_APPENDER(logger,target,pattern)
#define GR_SET_CONSOLE_APPENDER(logger,target,pattern)
#define GR_LOG_SET_CONSOLE_APPENDER(logger,target,pattern)
#define GR_ADD_FILE_APPENDER(name,filename,append,pattern)
#define GR_LOG_ADD_FILE_APPENDER(logger,filename,append,pattern)
#define GR_SET_FILE_APPENDER(name,filename,append,pattern)
#define GR_LOG_SET_FILE_APPENDER(logger,filename,append,pattern)
#define GR_ADD_ROLLINGFILE_APPENDER(name,filename,filesize,bkup_index,append,mode,pattern)
#define GR_LOG_ADD_ROLLINGFILE_APPENDER(logger,filename,filesize,bkup_index,append,mode,pattern)
#define GR_GET_LOGGER_NAMES(names)
#define GR_RESET_CONFIGURATION()
#define GR_DEBUG(name, msg) std::cout<<"DEBUG: "<<msg<<std::endl
#define GR_INFO(name, msg) std::cout<<"INFO: "<<msg<<std::endl
#define GR_NOTICE(name, msg) std::cout<<"NOTICE: "<<msg<<std::endl
#define GR_WARN(name, msg) std::cerr<<"WARN: "<<msg<<std::endl
#define GR_ERROR(name, msg) std::cerr<<"ERROR: "<<msg<<std::endl
#define GR_ALERT(name, msg) std::cerr<<"ERROR: "<<msg<<std::endl
#define GR_CRIT(name, msg) std::cerr<<"ERROR: "<<msg<<std::endl
#define GR_FATAL(name, msg) std::cerr<<"FATAL: "<<msg<<std::endl
#define GR_EMERG(name, msg) std::cerr<<"EMERG: "<<msg<<std::endl
#define GR_ERRORIF(name, cond, msg) {if((cond)) std::cerr<<"ERROR: "<<msg<<std::endl;}
#define GR_ASSERT(name, cond, msg) {if(!(cond)) std::cerr<<"FATAL: "<<msg<<std::endl; assert(cond);}
#define GR_LOG_DEBUG(logger, msg) std::cout<<"DEBUG: "<<msg<<std::endl
#define GR_LOG_INFO(logger, msg) std::cout<<"INFO: "<<msg<<std::endl
#define GR_LOG_NOTICE(logger, msg) std::cout<<"NOTICE: "<<msg<<std::endl
#define GR_LOG_WARN(logger, msg) std::cerr<<"WARN: "<<msg<<std::endl
#define GR_LOG_ERROR(logger, msg) std::cerr<<"ERROR: "<<msg<<std::endl
#define GR_LOG_ALERT(logger, msg) std::cerr<<"ALERT: "<<msg<<std::endl
#define GR_LOG_CRIT(logger, msg) std::cerr<<"CRIT: "<<msg<<std::endl
#define GR_LOG_FATAL(logger, msg) std::cerr<<"FATAL: "<<msg<<std::endl
#define GR_LOG_EMERG(logger, msg) std::cerr<<"EMERG: "<<msg<<std::endl
#define GR_LOG_ERRORIF(logger, cond, msg) {             \
    if((cond)) std::cerr<<"ERROR: "<<msg<<std::endl;}
#define GR_LOG_ASSERT(logger, cond, msg) {                              \
    if(!(cond)) {std::cerr<<"FATAL: "<<msg<<std::endl; assert(cond);};}


#else /* HAVE_LOG4CPP */

// Second configuration...logging to log4cpp
#include <log4cpp/Category.hh>
#include <log4cpp/PropertyConfigurator.hh>
#include <log4cpp/FileAppender.hh>
#include <log4cpp/RollingFileAppender.hh>
#include <log4cpp/OstreamAppender.hh>
#include <log4cpp/PatternLayout.hh>

namespace gr {

  /*!
   * \brief GR_LOG macros
   * \ingroup logging
   *
   * These macros wrap the standard LOG4CPP_LEVEL macros.  The availablie macros
   * are:
   *  LOG_DEBUG
   *  LOG_INFO
   *  LOG_WARN
   *  LOG_TRACE
   *  LOG_ERROR
   *  LOG_ALERT
   *  LOG_CRIT
   *  LOG_FATAL
   *  LOG_EMERG
   */
  typedef log4cpp::Category* logger_ptr;

} /* namespace gr */


  /* Macros for Programmatic Configuration */
#define GR_LOG_DECLARE_LOGPTR(logger)           \
  gr::logger_ptr logger;

#define GR_LOG_ASSIGN_LOGPTR(logger,name)       \
  logger = gr::logger_get_logger(name);

#define GR_CONFIG_LOGGER(config)                \
  gr::logger_config::load_config(config)

#define GR_CONFIG_AND_WATCH_LOGGER(config,period)	\
  gr::logger_config::load_config(config,period)

#define GR_LOG_GETLOGGER(logger, name)                  \
  gr::logger_ptr logger = gr::logger_get_logger(name);

#define GR_SET_LEVEL(name, level) {                             \
    gr::logger_ptr logger = gr::logger_get_logger(name);        \
    gr::logger_set_level(logger,level);}

#define GR_LOG_SET_LEVEL(logger, level)         \
  gr::logger_set_level(logger, level);

#define GR_GET_LEVEL(name, level) {                             \
    gr::logger_ptr logger = gr::logger_get_logger(name);        \
    gr::logger_get_level(logger,level);}

#define GR_LOG_GET_LEVEL(logger, level)         \
  gr::logger_get_level(logger,level);

#define GR_ADD_APPENDER(name, appender) {                       \
    gr::logger_ptr logger = gr::logger_get_logger(name);        \
    gr::logger_add_appender(logger,appender);}

#define GR_LOG_ADD_APPENDER(logger, appender) { \
    gr::logger_add_appender(logger, appender);}

#define GR_SET_APPENDER(name, appender) {                       \
    gr::logger_ptr logger = gr::logger_get_logger(name);        \
    gr::logger_set_appender(logger,appender);}

#define GR_LOG_SET_APPENDER(logger, appender) { \
    gr::logger_set_appender(logger, appender);}

#define GR_ADD_CONSOLE_APPENDER(name, target, pattern) {        \
    gr::logger_ptr logger = gr::logger_get_logger(name);        \
    gr::logger_add_console_appender(logger,target,pattern);}

#define GR_LOG_ADD_CONSOLE_APPENDER(logger, target, pattern) {  \
    gr::logger_add_console_appender(logger,target,pattern);}

#define GR_SET_CONSOLE_APPENDER(name, target, pattern) {        \
    gr::logger_ptr logger = gr::logger_get_logger(name);        \
    gr::logger_set_console_appender(logger,target,pattern);}

#define GR_LOG_SET_CONSOLE_APPENDER(logger, target, pattern) {  \
    gr::logger_set_console_appender(logger,target,pattern);}

#define GR_ADD_FILE_APPENDER(name, filename, append, pattern) {         \
    gr::logger_ptr logger = gr::logger_get_logger(name);                \
    gr::logger_add_file_appender(logger,filename,append,pattern);}

#define GR_LOG_ADD_FILE_APPENDER(logger, filename, append, pattern) {   \
    gr::logger_add_file_appender(logger,filename,append,pattern);}

#define GR_SET_FILE_APPENDER(name, filename, append, pattern) {         \
    gr::logger_ptr logger = gr::logger_get_logger(name);                \
    gr::logger_set_file_appender(logger,filename,append,pattern);}

#define GR_LOG_SET_FILE_APPENDER(logger, filename, append, pattern) {   \
    gr::logger_set_file_appender(logger,filename,append,pattern);}

#define GR_ADD_ROLLINGFILE_APPENDER(name, filename, filesize, bkup_index, append, mode, pattern) { \
    gr::logger_ptr logger = gr::logger_get_logger(name);                    \
    gr::logger_add_rollingfile_appender(logger,filename,filesize,bkup_index,append,mode,pattern);}

#define GR_LOG_ADD_ROLLINGFILE_APPENDER(logger, filename, filesize, bkup_index, append, mode, pattern) { \
    gr::logger_add_rollingfile_appender(logger,filename,filesize,bkup_index,append,mode,pattern);}

#define GR_GET_LOGGER_NAMES(names) {            \
    names = gr::logger_get_logger_names();}

#define GR_RESET_CONFIGURATION()                \
    gr::logger_config::reset_config();

  /* Logger name referenced macros */
#define GR_DEBUG(name, msg) {                                   \
    gr::logger_ptr logger = gr::logger_get_logger(name);        \
    *logger<< log4cpp::Priority::DEBUG << msg << log4cpp::eol;}

#define GR_INFO(name, msg) {                                    \
    gr::logger_ptr logger = gr::logger_get_logger(name);        \
    *logger<< log4cpp::Priority::INFO << msg << log4cpp::eol;}

#define GR_NOTICE(name, msg) {                                  \
    gr::logger_ptr logger = gr::logger_get_logger(name);        \
    *logger << log4cpp::Priority::NOTICE << msg;}

#define GR_WARN(name, msg) {                                    \
    gr::logger_ptr logger = gr::logger_get_logger(name);        \
    *logger<< log4cpp::Priority::WARN << msg << log4cpp::eol;}

#define GR_ERROR(name, msg) {                                   \
    gr::logger_ptr logger = gr::logger_get_logger(name);        \
    *logger<< log4cpp::Priority::ERROR << msg << log4cpp::eol;}

#define GR_CRIT(name, msg) {                                    \
    gr::logger_ptr logger = gr::logger_get_logger(name);        \
    *logger<< log4cpp::Priority::CRIT << msg << log4cpp::eol;}

#define GR_ALERT(name, msg) {                                   \
    gr::logger_ptr logger = gr::logger_get_logger(name);        \
    *logger<< log4cpp::Priority::ALERT << msg << log4cpp::eol;}

#define GR_FATAL(name, msg) {                                   \
    gr::logger_ptr logger = gr::logger_get_logger(name);        \
    *logger<< log4cpp::Priority::FATAL << msg << log4cpp::eol;}

#define GR_EMERG(name, msg) {                                   \
    gr::logger_ptr logger = gr::logger_get_logger(name);        \
    *logger<< log4cpp::Priority::EMERG << msg << log4cpp::eol;}

#define GR_ERRORIF(name, cond, msg) {                                   \
    if((cond)) {                                                        \
      gr::logger_ptr logger = gr::logger_get_logger(name);              \
      *logger<< log4cpp::Priority::ERROR << msg << log4cpp::eol;}       \
  }

#define GR_ASSERT(name, cond, msg) {                                    \
    if(!(cond)) {                                                       \
      gr::logger_ptr logger = gr::logger_get_logger(name);              \
      *logger<< log4cpp::Priority::EMERG << msg << log4cpp::eol;}       \
    assert(0);                                                          \
  }

  /* LoggerPtr Referenced Macros */
#define GR_LOG_DEBUG(logger, msg) {                                     \
    *logger << log4cpp::Priority::DEBUG << msg << log4cpp::eol;}

#define GR_LOG_INFO(logger, msg) {                              \
    *logger << log4cpp::Priority::INFO << msg << log4cpp::eol;}

#define GR_LOG_NOTICE(logger, msg) {                                    \
    *logger << log4cpp::Priority::NOTICE << msg << log4cpp::eol;}

#define GR_LOG_WARN(logger, msg) {                              \
    *logger << log4cpp::Priority::WARN << msg << log4cpp::eol;}

#define GR_LOG_ERROR(logger, msg) {                                     \
    *logger << log4cpp::Priority::ERROR << msg << log4cpp::eol;}

#define GR_LOG_CRIT(logger, msg) {                              \
    *logger << log4cpp::Priority::CRIT << msg << log4cpp::eol;}

#define GR_LOG_ALERT(logger, msg) {                                     \
    *logger << log4cpp::Priority::ALERT << msg << log4cpp::eol;}

#define GR_LOG_FATAL(logger, msg) {                                     \
    *logger << log4cpp::Priority::FATAL << msg << log4cpp::eol;}

#define GR_LOG_EMERG(logger, msg) {                                     \
    *logger << log4cpp::Priority::EMERG << msg << log4cpp::eol;}

#define GR_LOG_ERRORIF(logger,cond, msg) {                              \
    if((cond)) {                                                        \
      *logger<< log4cpp::Priority::ERROR << msg << log4cpp::eol;}       \
  }

#define GR_LOG_ASSERT(logger, cond, msg) {                       \
    if(!(cond)) {                                                \
      *logger<< log4cpp::Priority::EMERG << msg << log4cpp::eol; \
      assert(0);}                                                \
  }

namespace gr {

  /*!
   * \brief Class to control configuration of logger.
   * This is a singleton that cna launch a thread to wathc a config file for changes
   * \ingroup logging
   */
  class GR_RUNTIME_API logger_config
  {
  private:
    /*! \brief filename of logger config file */
    std::string filename;
    /*! \brief Period (seconds) over which watcher thread checks config file for changes */
    unsigned int watch_period;
    /*! \brief Pointer to watch thread for config file changes */
    boost::thread *watch_thread;

    /*! \brief Watcher thread method
     * /param filename Name of configuration file
     * /param watch_period Seconds between checks for changes in config file
     */
    static void watch_file(std::string filename,unsigned int watch_period);

    static bool logger_configured;

    logger_config()/*:
    rpc_get_filename("logger_config", "filename", &logger_config::get_filename4rpc,
      pmt::mp(""), pmt::mp(""), pmt::mp(""),
      "", "filename", RPC_PRIVLVL_MIN,
      DISPTIME | DISPOPTSTRIP),
    rpc_get_watchperiod("logger_config", "watch_period", &logger_config::get_watchperiod4rpc,
      pmt::mp(0), pmt::mp(32768), pmt::mp(0),
      "", "watch_period", RPC_PRIVLVL_MIN,
      DISPTIME | DISPOPTSTRIP),
    rpc_get_config("logger_config", "config", &logger_config::get_config4rpc,
      pmt::mp(""), pmt::mp(""), pmt::mp(""),
      "", "filename", RPC_PRIVLVL_MIN,
      DISPTIME | DISPOPTSTRIP),
    rpc_set_config("logger_config","config", &logger_config::set_config4rpc,
      pmt::mp(""), pmt::mp(""), pmt::mp(""),
      "", "filename", RPC_PRIVLVL_MIN,
      DISPTIME | DISPOPTSTRIP)
                   */
    {
    }  //!< Constructor

    /*
      rpcbasic_register_get<logger_config,std::string> rpc_get_filename;
      rpcbasic_register_get<logger_config,int> rpc_get_watchperiod;
      rpcbasic_register_get<logger_config,std::string> rpc_get_config;
      rpcbasic_register_set<logger_config,std::string> rpc_set_config;
    */

    logger_config(logger_config const&);  //!<Copy constructor
    void operator=(logger_config const&);  //!<Assignment Operator

    std::string get_filename4rpc() {
      return filename;
    }
    int get_watchperiod4rpc(){return watch_period;};

    std::string get_config4rpc() {
      return filename;
    }

    void set_config4rpc(std::string set) {
      printf("Set string was:%s\n", set.c_str());
    }

    /*! \brief destrcutor stops watch thread before exits */
    ~logger_config() {
      stop_watch();
    }

    /*! \brief Instance getter for singleton. Only used by class. */
    static logger_config& get_instance(void);

  public:
    /*! \brief Getter for config filename */
    static std::string get_filename();
    /*! \brief Getter for watch period */
    static unsigned int get_watch_period();
    /*! \brief Method to load configuration
     * /param filename Name of configuration file
     * /param watch_period Seconds between checks for changes in config file
     */
    static void load_config(std::string filename,unsigned int watch_period=0);
    /*! \brief Method to stop watcher thread */
    static void stop_watch();
    /*! \brief method to reset logger configuration */
    static void reset_config(void);
  };

  /*!
   * \brief Retrieve a pointer to a logger by name
   *
   * Retrives a logger pointer
   * \p name.
   *
   * \param name Name of the logger for which a pointer is requested
   */
  GR_RUNTIME_API logger_ptr logger_get_logger(std::string name);

  /*!
   * \brief Load logger's configuration file.
   *
   * Initialize the GNU Radio logger by loading the configuration file
   * \p config_filename.
   *
   * \param config_filename The configuration file. Set to "" for the
   *        basic logger that outputs to the console.
   */
  GR_RUNTIME_API bool logger_load_config(const std::string &config_filename="");

  /*!
   * \brief Reset logger's configuration file.
   *
   * Remove all appenders from loggers
   */
  GR_RUNTIME_API void logger_reset_config(void);

  /*!
   * \brief Set the logger's output level.
   *
   * Sets the level of the logger. This takes a string that is
   * translated to the standard levels and can be (case insensitive):
   *
   * \li off , notset
   * \li debug
   * \li info
   * \li notice
   * \li warn
   * \li error
   * \li crit
   * \li alert
   * \li fatal
   * \li emerg
   *
   * \param logger the logger to set the level of.
   * \param level  string to set the level to.
   */
  GR_RUNTIME_API void logger_set_level(logger_ptr logger,
                                       const std::string &level);

  /*!
   * \brief Set the logger's output level.
   *
   * Sets the level of the logger. This takes the actual Log4cpp::Priority
   * data type, which can be:
   *
   * \li log4cpp::Priority::NOTSET
   * \li log4cpp::Priority::DEBUG
   * \li log4cpp::Priority::INFO
   * \li log4cpp::Priority::NOTICE
   * \li log4cpp::Priority::WARN
   * \li log4cpp::Priority::ERROR
   * \li log4cpp::Priority::CRIT
   * \li log4cpp::Priority::ALERT
   * \li log4cpp::Priority::FATAL
   * \li log4cpp::Priority::EMERG
   *
   * \param logger the logger to set the level of.
   * \param level  new logger level of type Log4cpp::Priority
   */
  GR_RUNTIME_API void logger_set_level(logger_ptr logger,
                                       log4cpp::Priority::Value level);

  /*!
   * \brief Get the logger's output level.
   *
   * Gets the level of the logger. This returns a string that
   * corresponds to the standard levels and can be (case insensitive):
   *
   * \li notset
   * \li debug
   * \li info
   * \li notice
   * \li warn
   * \li error
   * \li crit
   * \li alert
   * \li fatal
   * \li emerg
   *
   * \param logger the logger to get the level of.
   * \param level  string to get the level into.
   */
  GR_RUNTIME_API void logger_get_level(logger_ptr logger, std::string &level);

  /*!
   * \brief Get the logger's output level.
   *
   * Gets the level of the logger. This returns the actual Log4cpp::Level
   * data type, which can be:
   *
   * \li log4cpp::Priority::NOTSET
   * \li log4cpp::Priority::DEBUG
   * \li log4cpp::Priority::INFO
   * \li log4cpp::Priority::NOTICE
   * \li log4cpp::Priority::WARN
   * \li log4cpp::Priority::ERROR
   * \li log4cpp::Priority::CRIT
   * \li log4cpp::Priority::ALERT
   * \li log4cpp::Priority::FATAL
   * \li log4cpp::Priority::EMERG
   *
   * \param logger the logger to get the level of.
   * \param level of the logger.
   */
  GR_RUNTIME_API void logger_get_level(logger_ptr logger,
                                       log4cpp::Priority::Value &level);

  /*!
   * \brief Add console appender to a given logger
   *
   * Add console appender to a given logger
   *
   * \param logger Logger to which appender will be added
   * \param appender Name of appender to add to logger
   */
  GR_RUNTIME_API void logger_add_appender(logger_ptr logger,
                                          std::string appender);

  /*!
   * \brief Sets a console appender to a given logger. Deletes any
   * existing appenders and adds a new one. To add an additional
   * appender, use logger_add_appender.
   *
   * \param logger Logger to which appender will be added
   * \param appender Name of appender to add to logger
   */
  GR_RUNTIME_API void logger_set_appender(logger_ptr logger,
                                          std::string appender);

  /*!
   * \brief Add console appender to a given logger
   *
   * Add console appender to a given logger
   *
   * \param logger Logger to which appender will be added
   * \param target Std target to write 'cout' or 'cerr' (default is cout)
   * \param pattern Formating pattern for log messages
   */
  GR_RUNTIME_API void logger_add_console_appender(logger_ptr logger,
                                                  std::string target,
                                                  std::string pattern);

  /*!
   * \brief Sets a new console appender to a given logger after
   * removing all others. Use logger_add_console_appender to add
   * another.
   *
   * \param logger Logger to which appender will be added
   * \param target Std target to write 'cout' or 'cerr' (default is cout)
   * \param pattern Formating pattern for log messages
   */
  GR_RUNTIME_API void logger_set_console_appender(logger_ptr logger,
                                                  std::string target,
                                                  std::string pattern);

  /*!
   * \brief Add file appender to a given logger
   *
   * Add file appender to a given logger
   *
   * \param logger Logger to which appender will be added
   * \param filename File to which log will be written
   * \param append Overwrite or append to log file
   * \param pattern Formating pattern for log messages
   */
  GR_RUNTIME_API void logger_add_file_appender(logger_ptr logger,
                                               std::string filename,
                                               bool append, std::string pattern);

  /*!
   * \brief Set a file appender to a given logger. To add another file
   * appender, use logger_add_file_appender.
   *
   * \param logger Logger to which appender will be added
   * \param filename File to which log will be written
   * \param append Overwrite or append to log file
   * \param pattern Formating pattern for log messages
   */
  GR_RUNTIME_API void logger_set_file_appender(logger_ptr logger,
                                               std::string filename,
                                               bool append, std::string pattern);

  /*!
   * \brief Add rolling file appender to a given logger
   *
   * Add rolling file appender to a given logger
   *
   * \param logger Logger to which appender will be added
   * \param filename File to which log will be written
   * \param filesize Sizez of files to write
   * \param bkup_index Number of files to write
   * \param append Overwrite or append to log file
   * \param mode Permissions to set on log file
   * \param pattern Formating pattern for log messages
   */
  GR_RUNTIME_API void logger_add_rollingfile_appender(logger_ptr logger, std::string filename,
                                                      size_t filesize, int bkup_index, bool append,
                                                      mode_t mode,std::string pattern);

  /*!
   * \brief Add rolling file appender to a given logger
   *
   * Add rolling file appender to a given logger
   *
   * \return vector of string names of loggers
   */
  GR_RUNTIME_API std::vector<std::string> logger_get_logger_names(void);

} /* namespace gr */

#endif /* HAVE_LOG4CPP */

  // If Logger disable do nothing
#else /* ENABLE_GR_LOG */

namespace gr {
  typedef void* logger_ptr;
} /* namespace gr */

#define GR_LOG_DECLARE_LOGPTR(logger)
#define GR_LOG_ASSIGN_LOGPTR(logger,name)
#define GR_CONFIG_LOGGER(config)
#define GR_CONFIG_AND_WATCH_LOGGER(config,period)
#define GR_LOG_GETLOGGER(logger, name)
#define GR_SET_LEVEL(name, level)
#define GR_LOG_SET_LEVEL(logger, level)
#define GR_GET_LEVEL(name, level)
#define GR_LOG_GET_LEVEL(logger, level)
#define GR_ADD_APPENDER(name,appender)
#define GR_LOG_ADD_APPENDER(logger,appender)
#define GR_SET_APPENDER(name,appender)
#define GR_LOG_SET_APPENDER(logger,appender)
#define GR_ADD_CONSOLE_APPENDER(logger,target,pattern)
#define GR_LOG_ADD_CONSOLE_APPENDER(logger,target,pattern)
#define GR_SET_CONSOLE_APPENDER(logger,target,pattern)
#define GR_LOG_SET_CONSOLE_APPENDER(logger,target,pattern)
#define GR_ADD_FILE_APPENDER(name,filename,append,pattern)
#define GR_LOG_ADD_FILE_APPENDER(logger,filename,append,pattern)
#define GR_SET_FILE_APPENDER(name,filename,append,pattern)
#define GR_LOG_SET_FILE_APPENDER(logger,filename,append,pattern)
#define GR_ADD_ROLLINGFILE_APPENDER(name,filename,filesize,bkup_index,append,mode,pattern)
#define GR_LOG_ADD_ROLLINGFILE_APPENDER(logger,filename,filesize,bkup_index,append,mode,pattern)
#define GR_GET_LOGGER_NAMES(names)
#define GR_RESET_CONFIGURATION()
#define GR_DEBUG(name, msg)
#define GR_INFO(name, msg)
#define GR_NOTICE(name, msg)
#define GR_WARN(name, msg)
#define GR_ERROR(name, msg)
#define GR_ALERT(name, msg)
#define GR_CRIT(name, msg)
#define GR_FATAL(name, msg)
#define GR_EMERG(name, msg)
#define GR_ERRORIF(name, cond, msg)
#define GR_ASSERT(name, cond, msg)
#define GR_LOG_DEBUG(logger, msg)
#define GR_LOG_INFO(logger, msg)
#define GR_LOG_NOTICE(logger, msg)
#define GR_LOG_WARN(logger, msg)
#define GR_LOG_ERROR(logger, msg)
#define GR_LOG_ALERT(logger, msg)
#define GR_LOG_CRIT(logger, msg)
#define GR_LOG_FATAL(logger, msg)
#define GR_LOG_EMERG(logger, msg)
#define GR_LOG_ERRORIF(logger, cond, msg)
#define GR_LOG_ASSERT(logger, cond, msg)

#endif /* ENABLE_GR_LOG */

namespace gr {

  // Even if logger is disabled we'll need for methods below to exist in python.
  // The macros these call will be disabled if ENABLE_GR_LOG is undefined

  /********************* Start  Classes and Methods for Python ******************/
  /*!
   * \brief Logger class for referencing loggers in python.  Not
   * needed in C++ (use macros) Wraps and manipulates loggers for
   * python as python has no macros
   * \ingroup logging
   *
   */
  class GR_RUNTIME_API logger
  {
  private:
    /*! \brief logger pointer to logger associated wiith this wrapper class */
    logger_ptr d_logger;
  public:
    /*!
     * \brief contructor Provide name of logger to associate with this class
     * \param logger_name Name of logger associated with class
     */
    logger(std::string logger_name) {
      GR_LOG_ASSIGN_LOGPTR(d_logger,logger_name);
    };

    /*! \brief Destructor */
    ~logger(){;}

    // Wrappers for logging macros
    /*! \brief inline function, wrapper to set the logger level */
    void set_level(std::string level){GR_LOG_SET_LEVEL(d_logger,level);}

    /*! \brief inline function, wrapper to get the logger level */
    void get_level(std::string &level){GR_LOG_GET_LEVEL(d_logger,level);}

    /*! \brief inline function, wrapper for LOG4CPP_DEBUG for DEBUG message */
    void debug(std::string msg){GR_LOG_DEBUG(d_logger,msg);};

    /*! \brief inline function, wrapper for LOG4CPP_INFO for INFO message */
    void info(std::string msg){GR_LOG_INFO(d_logger,msg);}

    /*! \brief inline function, wrapper for NOTICE message */
    void notice(std::string msg){GR_LOG_NOTICE(d_logger,msg);}

    /*! \brief inline function, wrapper for LOG4CPP_WARN for WARN message */
    void warn(std::string msg){GR_LOG_WARN(d_logger,msg);}

    /*! \brief inline function, wrapper for LOG4CPP_ERROR for ERROR message */
    void error(std::string msg){GR_LOG_ERROR(d_logger,msg);}

    /*! \brief inline function, wrapper for NOTICE message */
    void crit(std::string msg){GR_LOG_CRIT(d_logger,msg);}

    /*! \brief inline function, wrapper for ALERT message */
    void alert(std::string msg){GR_LOG_ALERT(d_logger,msg);}

    /*! \brief inline function, wrapper for FATAL message */
    void fatal(std::string msg){GR_LOG_FATAL(d_logger,msg);}

    /*! \brief inline function, wrapper for EMERG message */
    void emerg(std::string msg){GR_LOG_EMERG(d_logger,msg);}

    /*! \brief inline function, wrapper for LOG4CPP_ASSERT for conditional ERROR message */
    void errorIF(bool cond,std::string msg){GR_LOG_ERRORIF(d_logger,cond,msg);}

    /*! \brief inline function, wrapper for LOG4CPP_ASSERT for conditional ERROR message */
    void log_assert(bool cond,std::string msg){GR_LOG_ASSERT(d_logger,cond,msg);}

    /*! \brief inline function, Method to add appender to logger by
        name (define appender in conf file) */
    void add_appender(std::string appender) {
      GR_LOG_ADD_APPENDER(d_logger, appender);
    }

    /*! \brief inline function, Method to set an appender to logger by
        name (define appender in conf file) */
    void set_appender(std::string appender) {
      GR_LOG_SET_APPENDER(d_logger, appender);
    }

    /*! \brief inline function, Method to add console appender to logger */
    void add_console_appender(std::string target,std::string pattern) {
      GR_LOG_ADD_CONSOLE_APPENDER(d_logger, target, pattern);
    }

    /*! \brief inline function, Method to set a console appender to logger */
    void set_console_appender(std::string target,std::string pattern) {
      GR_LOG_SET_CONSOLE_APPENDER(d_logger, target, pattern);
    }

    /*! \brief inline function, Method to add file appender to logger */
    void add_file_appender(std::string filename, bool append, std::string pattern) {
      GR_LOG_ADD_FILE_APPENDER(d_logger, filename, append, pattern);
    }

    /*! \brief inline function, Method to set a file appender to logger */
    void set_file_appender(std::string filename, bool append, std::string pattern) {
      GR_LOG_SET_FILE_APPENDER(d_logger, filename, append, pattern);
    }

    /*! \brief inline function, Method to add rolling file appender to logger */
    void add_rollingfile_appender(std::string filename, size_t filesize,
                                  int bkup_index, bool append, mode_t mode,
                                  std::string pattern) {
      GR_LOG_ADD_ROLLINGFILE_APPENDER(d_logger,filename,filesize,
                                      bkup_index,append,mode,pattern);
    }
  };

} /* namespace gr */

/**************** Start Configuration Class and Methods for Python ************/
/*!
 * \brief Function to call configuration macro from python.
 *        Note: Configuration is only updated if filename or watch_period has changed.
 * \param config_filename  Name of configuration file
 * \param watch_period Seconds to wait between checking for changes in conf file.
 *        Watch_period defaults to 0 in which case the file is not watched for changes
 */
GR_RUNTIME_API void gr_logger_config(const std::string config_filename,
                                     unsigned int watch_period = 0);

/*!
 * \brief Function to return logger names to python
 * \return Vector of name strings
 *
 */
GR_RUNTIME_API std::vector<std::string> gr_logger_get_logger_names(void);

/*!
 * \brief Function to reset logger configuration from python
 *
 */
GR_RUNTIME_API void gr_logger_reset_config(void);


namespace gr {
  /*!
   * Function to use the GR prefs files to get and setup the two
   * default loggers defined there. The loggers are unique to the
   * class in which they are called, and we pass it the \p name to
   * identify where the log message originates from. For a GNU Radio
   * block, we use 'alias()' for this value, and this is set up for us
   * automatically in gr::block.
   */
  GR_RUNTIME_API bool configure_default_loggers(gr::logger_ptr &l, gr::logger_ptr &d,
                                                const std::string name);

  GR_RUNTIME_API bool update_logger_alias(const std::string &name, const std::string &alias);

} /* namespace gr */


#endif /* INCLUDED_GR_LOGGER_H */