Loading...
Searching...
No Matches
Log.h
1/*
2
3MIT License
4
5Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26/*
27Part of Rack development has been done in the BALTRAD projects part-financed
28by the European Union (European Regional Development Fund and European
29Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30*/
31
32#ifndef DRAIN_LOG_H_
33#define DRAIN_LOG_H_
34
35#include <cstddef> // nullptr
36#include <stdlib.h>
37#include <sstream>
38#include <string>
39#include <iostream>
40#include <fstream>
41#include <stdexcept>
42
43//#include <ctime>
44#include <sys/time.h>
45#include <string.h> // strrchr()
46
47#include <syslog.h>
48#include <map>
49
50#include "StringBuilder.h"
51// #include "TextStyle.h"
52#include "TextStyleVT100.h"
53/*
54#define LOG_EMERG 0 // system is unusable //
55#define LOG_ALERT 1 // action must be taken immediately // RACK examples
56#define LOG_CRIT 2 // critical conditions //
57#define LOG_ERR 3 // error conditions // // File read/write failed
58#define LOG_WARNING 4 // warning conditions // // HDF5 empty or contains no relevant data
59#define LOG_NOTICE 5 // normal but significant condition // No volumes used for a composite
60#define LOG_INFO 6 // informational // // Read/Write File, start/end of operator
61#define LOG_DEBUG 7 // debug-level messages // Store variable
62 10 // Write control files (function input, output)
63 11 // Write intermediate results in files
64 15 // Debug 1D loops
65 20 // Debug 2D loops
66
67Compare with Python: https://docs.python.org/3/library/logging.html#logging-levels
68 */
69
70
71/*
72#ifdef __GNUC__
73 inline std::string className(const std::string & prettyFunction)
74 {
75 const size_t colons = prettyFunction.find("::");
76 if (colons == std::string::npos){
77 return "::";
78 }
79 else {
80 const size_t begin = prettyFunction.substr(0, colons).rfind(" ") + 1;
81 const size_t end = colons - begin;
82 return prettyFunction.substr(begin,end);
83 }
84}
85#define CLASSNAME className(__PRETTY_FUNCTION__)
86#else
87#define CLASSNAME __FILE__
88#endif
89*/
90
91namespace drain {
92
93// using namespace std;
94
96
97 /*
98 Notification(const std::string & key="", int vt100color=35){
99 set(key, vt100color);
100 };
101 */
102
103 template <typename ... T>
104 Notification(const std::string & key, const T &... args){
105
106 this->key = key;
107
108 TextStyleVT100 vt100;
109 std::stringstream sstr;
110 //vt100.write(sstr, args..., key);
111 vt100.append(sstr, args...);
112 vt100color = sstr.str();
113 };
114
115
116 //void set(const std::string & key, int vt100color);
117
118
119 std::string key;
120 std::string vt100color;
121
122};
123
124// extern unsigned int Debug; // getting obsolete
125
127class Logger;
128
130
147class Log {
148
149public:
150
152 typedef unsigned short level_t;
153
154 //typedef std::vector<Notification> notif_dict_t;
155 typedef std::map<int,std::string> status_dict_t;
156
157 const
158 static status_dict_t statusDict;
159
160 // experimental
161 int id = 0;
162
164
167 inline
168 Log(std::ostream & ostr=std::cerr, int verbosityLevel=LOG_WARNING) : ostrPtr(&ostr), verbosityLevel(verbosityLevel) // VT100(true),
169 {
170 resetTime();
171 //std::cerr << "start monitor, level=" << verbosityLevel << std::endl;
172 };
173
174 inline
175 Log(const Log &m) : ostrPtr(m.ostrPtr), verbosityLevel(m.verbosityLevel) { // VT100(m.VT100),
176 resetTime();
177 };
178
179 inline
180 ~Log(){
181 close(); // Note: external ofstream will not be closed.
182 /*
183 if (ostrPtr != nullptr){ // it never is...
184 ostrPtr->close();
185 }
186 */
187 }
188
189
190 inline
191 void setOstr(std::ostream & ostr){
192 /*
193 if (ostrPtr != nullptr){ // it never is...
194 ostrPtr->close();
195 }
196 */
197 close();
198 ostrPtr = &ostr;
199 }
200
201 inline
202 void setOstr(const std::string & filename){
203 /*
204 if (ostrPtr != nullptr){ // it never is...
205 ostrPtr->close();
206 }
207 */
208 close();
209 ofstr.open(filename, std::ios::out);
210 ostrPtr = &ofstr;
211 }
212
214 void close(){
215 if (ofstr.is_open()){
216 ostrPtr = nullptr; // or what, std::cerr ?
217 ofstr.close();
218 }
219 }
220
221 //
222 inline
223 void setVerbosity(level_t level){
224 verbosityLevel = level;
225 };
226
227 void setVerbosity(const std::string & level);
228
229 inline
230 int getVerbosity() const {
231 return verbosityLevel;
232 };
233
234 void flush(level_t level, const std::string & prefix, const std::stringstream & sstr);
235
236 //void flush(level_t level, const Notification & notif, const std::string & prefix, const std::ostream & sstr);
237 void flush(level_t level, const Notification & notif, const std::string & prefix, const std::stringstream & sstr);
238
239
240 inline
241 long getRelativeMilliseconds(){
242 return getMilliseconds() - millisecondsStart;
243 }
244
245 static inline
246 long getMilliseconds(){
247 timeval time;
248 gettimeofday(&time, NULL);
249 return (time.tv_sec * 1000) + (time.tv_usec / 1000);
250 }
251
252 inline
253 void resetTime(){
254 millisecondsStart = getMilliseconds();
255 };
256
257 static
258 bool USE_VT100; // = true;
259
260 // static
261 // const notif_dict_t & getDict();
262
263protected:
264
265 std::ostream *ostrPtr;
266
267 std::ofstream ofstr;
268
269 level_t verbosityLevel;
270
271 long millisecondsStart;
272
273 //drain::Dictionary<int, Notification> dict;
274
275};
276
277//extern Log monitor;
278
279Log & getLog();
280
281namespace image {
282
283Log & getImgLog();
284
285} // namespace image
286
287
288class DrainException : public std::runtime_error {
289
290public:
291
292
293
294 // Either this or previous is unneeded?
295 template<typename T,typename ... TT>
296 DrainException(const T &elem, const TT &... rest) : std::runtime_error(drain::StringBuilder<>(elem, rest...)){
297 }
298
299
300};
301
303#define DRAIN_LOG_VAR(name) '#', #name, '=', name
304
305
306
308
311//class Logger : public std::stringstream {
312class Logger : public StreamBuilder<0> {
313
314 std::stringstream & message;
315
316public:
317
318
319
320 typedef Log::level_t level_t;
321
323
327 template <typename ... TT>
328 Logger(const char *filename, const TT & ...args);
329 //Logger(const char *filename, const std::string & name = "");
330
332
336 template <typename ... TT>
337 Logger(Log &log, const char *filename, const TT & ...args); //const char *className = NULL);
338 //Logger(Log &log, const char *filename, const std::string & name = ""); //const char *className = NULL);
339
340 ~Logger();
341
343
347 inline
348 bool isLevel(level_t l){
349 return (monitor.getVerbosity() >= l);
350 };
351
353
357 inline
358 bool isDebug(level_t l=0){
359 return isLevel(LOG_DEBUG+l);
360 //return (monitor.getVerbosity() >= (LOG_DEBUG+l));
361 };
362
363
364
366 template <int L, typename ... TT>
367 inline
368 Logger & start(const TT &... args){
369 static const Notification notif(__FUNCTION__, TextStyle::DIM); //, TextStyle::BOLD
370 initMessage<L>(notif);
371 flush(args...);
372 return *this;
373 };
374
375
377 template<typename ... TT>
378 inline
379 Logger & quit(const TT &... args){
380 static const Notification notif(__FUNCTION__, TextStyle::PURPLE, TextStyle::REVERSE, TextStyle::BOLD);
381 initMessage<LOG_EMERG>(notif);
382 flush(args...);
383 return *this;
384 };
385
387 template<typename ... TT>
388 inline
389 Logger & alert(const TT &... args){
390 static const Notification notif(__FUNCTION__, TextStyle::PURPLE, TextStyle::BOLD);
391 initMessage<LOG_ALERT>(notif);
392 flush(args...);
393 return *this;
394 };
395
397 template<typename ... TT>
398 inline
399 Logger & critical(const TT &... args){
400 static const Notification notif(__FUNCTION__, TextStyle::RED, TextStyle::REVERSE);
401 initMessage<LOG_CRIT>(notif);
402 flush(args...);
403 return *this;
404 };
405
407 /*
408 inline
409 Logger & error(){
410 return initMessage<LOG_ERR>();
411 };
412 */
413
414 template<typename ... TT>
415 inline
416 Logger & error(const TT &... args){
417 static const Notification notif(__FUNCTION__, TextStyle::RED, TextStyle::BOLD);
418 // error();
419 initMessage<LOG_ERR>(notif);
420 flush(args...);
421 return *this;
422 };
423
424
425 // LOG_WARNING
426
428 template<typename ... TT>
429 inline
430 Logger & warn(const TT &... args){
431 // warn();
432 static const Notification notif(__FUNCTION__, TextStyle::YELLOW, TextStyle::BOLD);
433 initMessage<LOG_WARNING>(notif);
434 flush(args...);
435 return *this;
436 };
437
439 template<int L=LOG_WARNING,typename ... TT>
440 inline
441 Logger & discouraged(const TT &... args){
442 //static const Notification notif(__FUNCTION__, 35);
443 static const Notification notif(__FUNCTION__, TextStyle::YELLOW, TextStyle::DIM);
444 initMessage<L>(notif);
445 flush(args...);
446 return *this;
447 };
448
449
451 template<int L=LOG_WARNING,typename ... TT>
452 inline
453 Logger & fail(const TT &... args){
454 //static const Notification notif(__FUNCTION__, 33);
455 static const Notification notif(__FUNCTION__, TextStyle::YELLOW, TextStyle::DIM);
456 initMessage<L>(notif);
457 flush(args...);
458 return *this;
459 };
460
462 // Valid alternative should be displayed.
463 template<int L=LOG_WARNING,typename ... TT>
464 inline
465 Logger & obsolete(const TT &... args){
466 //static const Notification notif(__FUNCTION__, 35);
467 static const Notification notif(__FUNCTION__, TextStyle::PURPLE, TextStyle::DIM, TextStyle::UNDERLINE);
468 initMessage<L>(notif);
469 flush(args...);
470 return *this;
471 };
472
474 template<int L=LOG_WARNING,typename ... TT>
475 inline
476 Logger & attention(const TT &... args){
477 static const Notification notif(__FUNCTION__, TextStyle::CYAN, TextStyle::REVERSE, TextStyle::DIM); // 46);
478 initMessage<L>(notif);
479 flush(args...);
480 return *this;
481 };
482
483
484 // LOG_NOTICE
485
487 template<typename ... TT>
488 inline
489 Logger & note(const TT &... args){
490 static const Notification notif(__FUNCTION__, TextStyle::BOLD);
491 initMessage<LOG_NOTICE>(notif);
492 //initMessage<LOG_NOTICE>();
493 flush(args...);
494 return *this;
495 };
496
498 template<int L=LOG_NOTICE,typename ... TT>
499 inline
500 Logger & suspicious(const TT &... args){
501 static const Notification notif(__FUNCTION__, TextStyle::YELLOW, TextStyle::DIM);
502 initMessage<L>(notif);
503 flush(args...);
504 return *this;
505 };
506
507
509 template<int L=LOG_NOTICE,typename ... TT>
510 inline
511 Logger & unimplemented(const TT &... args){
512 static const Notification notif(__FUNCTION__, TextStyle::YELLOW, TextStyle::OVERLINE); // , 35);
513 initMessage<L>(notif);
514 flush(args...);
515 return *this;
516 };
517
519 template<int L=LOG_NOTICE,typename ... TT>
520 inline
521 Logger & deprecating(const TT &... args){
522 static const Notification notif(__FUNCTION__, TextStyle::YELLOW, TextStyle::DIM, TextStyle::UNDERLINE); //33);
523 initMessage<L>(notif);
524 flush(args...);
525 return *this;
526 };
527
529 template<int L=LOG_NOTICE,typename ... TT>
530 inline
531 Logger & special(const TT &... args){
532 static const Notification notif(__FUNCTION__, TextStyle::CYAN); //36);
533 initMessage<L>(notif);
534 flush(args...);
535 return *this;
536 };
537
538
539 template<int L=LOG_NOTICE,typename ... TT>
540 inline
541 Logger & experimental(const TT &... args){
542 static const Notification notif(__FUNCTION__, TextStyle::CYAN, TextStyle::REVERSE); // 94);
543 initMessage<L>(notif);
544 flush(args...);
545 return *this;
546 };
547
548 template<int L=LOG_NOTICE,typename ... TT>
549 inline
550 Logger & advice(const TT &... args){
551 static const Notification notif(__FUNCTION__, TextStyle::UNDERLINE);// 40);
552 initMessage<L>(notif);
553 flush(args...);
554 return *this;
555 };
556
557
558 // LOG_INFO
559
560 template<typename ... TT>
561 inline
562 Logger & info(const TT &... args){
563 static const Notification notif(__FUNCTION__, TextStyle::WHITE); //32);
564 initMessage<LOG_INFO>(notif);
565 // initMessage<LOG_INFO>();
566 flush(args...);
567 return *this;
568 };
569
570 template<int L=LOG_INFO,typename ... TT>
571 inline
572 Logger & ok(const TT &... args){
573 static const Notification notif(__FUNCTION__, TextStyle::GREEN); //32);
574 initMessage<L>(notif);
575 flush(args...);
576 return *this;
577 };
578
580 template<int L=LOG_INFO,typename ... TT>
581 inline
582 Logger & accept(const TT &... args){
583 //static const Notification notif(__FUNCTION__, 42);
584 static const Notification notif(__FUNCTION__, TextStyle::GREEN, TextStyle::REVERSE, TextStyle::DIM);
585 initMessage<L>(notif);
586 flush(args...);
587 return *this;
588 };
589
591
594 template<int L=LOG_INFO,typename ... TT>
595 inline
596 Logger & pending(const TT &... args){
597 //static const Notification notif(__FUNCTION__, 42);
598 static const Notification notif(__FUNCTION__, TextStyle::YELLOW, TextStyle::REVERSE, TextStyle::DIM);
599 initMessage<L>(notif);
600 flush(args...);
601 return *this;
602 };
603
605
608 template<int L=LOG_INFO,typename ... TT>
609 inline
610 Logger & reject(const TT &... args){
611 // static const Notification notif(__FUNCTION__, 41);
612 static const Notification notif(__FUNCTION__, TextStyle::RED, TextStyle::REVERSE, TextStyle::DIM);
613 initMessage<L>(notif);
614 flush(args...);
615 return *this;
616 };
617
618
620 template<int L=LOG_INFO,typename ... TT>
621 inline
622 Logger & success(const TT &... args){
623 // static const Notification notif(__FUNCTION__, 92);
624 static const Notification notif(__FUNCTION__, TextStyle::GREEN, TextStyle::DIM);
625 initMessage<L>(notif);
626 flush(args...);
627 return *this;
628 };
629
630
632 template<int L=LOG_INFO,typename ... TT>
633 inline
634 Logger & hint(const TT &... args){
635 static const Notification notif(__FUNCTION__, TextStyle::CYAN, TextStyle::DIM, TextStyle::ITALIC);
636 initMessage<L>(notif);
637 flush(args...);
638 return *this;
639 };
640
641
642 template<int L=LOG_INFO,typename ... TT>
643 inline
644 Logger & revised(const TT &... args){
645 static const Notification notif(__FUNCTION__, TextStyle::YELLOW, TextStyle::ITALIC); // , TextStyle::DIM
646 initMessage<L>(notif);
647 flush(args...);
648 return *this;
649 };
650
651
652
654
664 template<typename ... TT>
665 inline
666 Logger & debug(const TT &... args){
667 static const Notification notif(__FUNCTION__, TextStyle::DIM);
668 initMessage<LOG_DEBUG>(notif);
669 flush(args...);
670 return *this;
671 };
672
674 template<typename ... TT>
675 inline
676 Logger & debug2(const TT &... args){
677 static const Notification notif(__FUNCTION__, TextStyle::DIM, TextStyle::ITALIC);
678 initMessage<LOG_DEBUG+1>(notif);
679 flush(args...);
680 return *this;
681 };
682
683 template<typename ... TT>
684 inline
685 Logger & debug3(const TT &... args){
686 static const Notification notif(__FUNCTION__, TextStyle::CYAN, TextStyle::DIM, TextStyle::ITALIC);
687 initMessage<LOG_DEBUG+2>(notif);
688 flush(args...);
689 return *this;
690 };
691
692
693 inline
694 Logger & log(level_t level){
695 initMessage(level); // avoid
696 return *this;
697 };
698
699 // Experimental! For mout.log(level)(args); !
700 template<typename ... TT>
701 inline
702 Logger & operator()(const TT &... args){
703 flush(args...);
704 return *this;
705 };
706
707
708 static bool TIMING; // = false;
709 static char MARKER;
710
711 bool timing;
712
714 //Logger & timestamp(const std::string & label);
715
719 inline
721 if (TIMING && !timing){
722 initTiming(this->prefix);
723 }
724 };
725
729 template<typename ... TT>
730 void startTiming(const TT &... args){
731 if (TIMING && !timing){ // consider error if already timing?
732 initTiming(args...);
733 }
734 };
735
736 //template<typename ... TT>
737 //void endTiming(const TT &... args){
738 void endTiming(){
739 if (timing){
740 time = monitor.getMilliseconds() - time;
741 std::cerr << "TIMING:" << MARKER << "</div> ";
742 //describeTiming(args...); // STORE timing label?
743 // << ": "
744 std::cerr << "<b>" << (static_cast<float>(time)/1000.0f) << "</b>" << "<br/>" << '\n';
745 /*
746 std::cerr << "TIMING:" << MARKER << "</ol> ";
747 //describeTiming(args...); // STORE timing label?
748 // << ": "
749 std::cerr << "<b>" << (static_cast<float>(time)/1000.0f) << "</b>" << "</li>" << '\n';
750 */
751 timing = false;
752 }
753 }
754
755
756public:
757
758
760 // Logger & timestamp();
761
762
764
765 Logger &operator<<(const std::ostream & sstr) {
766 // TODO if (!message.empty())
767 if (level <= monitor.getVerbosity())
768 message << sstr.rdbuf();
769 return *this;
770 }
771
772
773
774 template <class T>
775 Logger &operator<<(const T & x) {
776 //cerr << "source input:" << x << '\n';
777 if (level <= monitor.getVerbosity())
778 message << x;
779 return *this;
780 }
781
782 typedef void * oper;
783 static oper endl;
784
785
786 inline
787 void end(){
788 monitor.flush(level, *notif_ptr, prefix, message);
789 }
790
792 inline
794 monitor.flush(level, *notif_ptr, prefix, message);
795 return *this; // <- drop this?
796 }
797
799 inline
801
802 if (&l != this){
803 message << " NOTE: Logger" << __FUNCTION__ << " flush with non-this Logger";
804 }
805 monitor.flush(level, *notif_ptr, prefix, message);
806 return *this;
807 }
808
809 inline
810 int getVerbosity() const {
811 return monitor.getVerbosity();
812 };
813
814protected:
815
816 Log & monitor;
817
818 std::string prefix;
819
820 level_t level;
821 time_t time;
822
823 const Notification * notif_ptr;
824
825protected:
826
827 template<typename ... TT>
828 void initTiming(const TT &... args){
829 timing = true; // consider error if already timing?
830 std::cerr << "TIMING:" << MARKER; // << "<li>";
831 describeTiming(args...);
832 // std::cerr << " [" << prefix << "] <ol>" << '\n';
833 //std::cerr << " <ol>" << '\n';
834 std::cerr << " <div>" << '\n';
835 time = monitor.getMilliseconds();
836 };
837
838
839 template<typename T, typename ... TT>
840 void describeTiming(const T & arg, const TT &... args){
841 std::cerr << arg;
842 describeTiming(args...);
843 };
844
845 inline
846 void describeTiming(){
847 };
848
857
864 template<typename ... TT>
865 inline
866 //void setPrefix(const char * filename, const char * func_name, const TT &... args){
867 void setPrefix(const char * filename, const TT &... args){
868
869 std::stringstream sstr;
870
871 if (filename){
872
873 if (*filename != '\0'){
874
875 const char * s2 = strrchr(filename, '/');
876 if (s2 == nullptr)
877 s2 = filename;
878 else
879 ++s2;
880
882 const char * s3 = strrchr(s2, '.');
883 if (s3 == nullptr)
884 sstr << s2;
885 //prefix.assign(s2);
886 else
887 //prefix.assign(s2, s3-s2);
888 sstr.write(s2, size_t(s3-s2));
889 // prefix.append(":");
890 // sstr << ':';
891 }
892 }
893 // NEW sstr << func_name << ": ";
894 //appendPrefix(sstr, func_name, args...);
895 appendPrefix(sstr, args...);
896 prefix = sstr.str();
897 }
898
899 /*
900 template<typename T, typename ... TT>
901 inline
902 void setPrefix(const TT &... args){
903 std::stringstream sstr;
904 appendPrefix(sstr, args...);
905 prefix = sstr.str();
906 }
907 */
908
909
910 inline
911 void appendPrefix(std::stringstream & sstr){
912 }
913
914 template<typename T, typename ... TT>
915 void appendPrefix(std::stringstream & sstr, const T & arg, const TT &... args){
916 sstr << ":" << arg;
917 appendPrefix(sstr, args...);
918 }
919
920 template <level_t L>
921 Logger & initMessage(const Notification & notif){
922 this->notif_ptr = & notif;
923 this->level = L;
924 this->message.str("");
925 return *this;
926 }
927 //void initMessage(level_t level);
928
929 /*
930 template <level_t L>
931 Logger & initMessage(){
932
933 static
934 const Notification & notif = Log::getDict()[L];
935
936 this->notif_ptr = &notif;
937 this->level = L;
938 this->message.str("");
939 return *this;
940 }
941 */
942
944 Logger & initMessage(level_t level);
945
946 /*
947 inline
948 Logger & initMessage(level_t level){
949 static const Notification notif(__FUNCTION__); // TextStyle::DIM, TextStyle::ITALIC);
950 this->notif_ptr = & notif; // Log::getDict()[level];
951 this->level = level;
952 this->message.str("");
953 return *this;
954 }
955 */
956
957 template<typename T, typename ... TT>
958 inline
959 Logger & flush(const T & arg, const TT &... rest){
960 //*this << arg;
961 append(arg);
962 flush(rest...);
963 return *this;
964 };
965
966 template<typename T>
967 inline
968 Logger & flush(const T & arg){
969 // *this << arg;
970 append(arg);
971 monitor.flush(level, *notif_ptr, prefix, message);
972 return *this;
973 };
974
975 inline
976 Logger & flush(){
977 return *this;
978 };
979
980 template<typename T>
981 inline
982 void append(const T & arg){
983 *this << arg;
984 }
985
986 /*
987 inline
988 Logger & flush(){
989 monitor.flush(level, *notif_ptr, prefix, message);
990 return *this;
991 };
992 */
993
994
995};
996
997
998template <>
999inline
1000void Logger::append(const TextStyle::Colour & colour){
1001 *this << "<color>";
1002}
1003
1004
1005template <typename ... TT>
1006Logger::Logger(const char *filename, const TT & ...args):
1007 message(*this),
1008 timing(false),
1009 monitor(getLog()),
1010 level(LOG_NOTICE),
1011 time(getLog().getMilliseconds()),
1012 notif_ptr(NULL){
1013 setPrefix(filename, args...);
1014}
1015
1016template <typename ... TT>
1017Logger::Logger(Log &log, const char *filename, const TT & ...args):
1018 message(*this),
1019 timing(false),
1020 monitor(log),
1021 level(LOG_NOTICE),
1022 time(log.getMilliseconds()),
1023 notif_ptr(NULL){
1024 setPrefix(filename, args...);
1025}
1026//std::ostream &operator<<(std::ostream &ostr, const Log &error);
1027
1028
1029}
1030
1031//const std::string FEELU(__FILE__);
1032
1033#endif /* DEBUG_H_ */
1034
1035// Drain
Definition Log.h:288
Handler for notifications sent by a Logger.
Definition Log.h:147
unsigned short level_t
Log verbosity level type.
Definition Log.h:152
Log(std::ostream &ostr=std::cerr, int verbosityLevel=LOG_WARNING)
Definition Log.h:168
void close()
Closes internal ofstr, if used. External ofstream will not be closed.
Definition Log.h:214
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition Log.h:312
Logger & start(const TT &... args)
General.
Definition Log.h:368
Logger & operator<<(const std::ostream &sstr)
Send a longer [INFO] preceded with a time stamp.
Definition Log.h:765
Logger & discouraged(const TT &... args)
Warning on user's convention or action that can potentially cause errors or confusions.
Definition Log.h:441
Logger & pending(const TT &... args)
Report a conditional accept/reject, to be completed next.
Definition Log.h:596
Logger & operator<<(const Logger &l)
NEW: sending "mout" insread of "mout.endl" Handling flush operator.
Definition Log.h:800
bool isDebug(level_t l=0)
Returns true, if the debug level of the monitor is at least l.
Definition Log.h:358
Logger & warn(const TT &... args)
Possible error, but execution can continue.
Definition Log.h:430
Logger & success(const TT &... args)
Some processing step has completed with desired result.
Definition Log.h:622
Logger & alert(const TT &... args)
Quits immediately, dumps pending messages.
Definition Log.h:389
void setPrefix(const char *filename, const TT &... args)
Sets a label that starts every line in the log.
Definition Log.h:867
Logger & obsolete(const TT &... args)
Feature has been removed. Special type of Logger::warn().
Definition Log.h:465
Logger & debug(const TT &... args)
Debug information.
Definition Log.h:666
Logger & quit(const TT &... args)
Quits immediately, dumps pending messages.
Definition Log.h:379
Logger & note(const TT &... args)
For top-level information.
Definition Log.h:489
Logger & hint(const TT &... args)
Like advice, but weaker.
Definition Log.h:634
void startTiming(const TT &... args)
Definition Log.h:730
void startTiming()
Send a short [INFO] preceded with a time stamp.
Definition Log.h:720
Logger & critical(const TT &... args)
Quits immediately, dumps pending messages.
Definition Log.h:399
Logger & special(const TT &... args)
Other useful information.
Definition Log.h:531
Logger & reject(const TT &... args)
Some input has been rejected, for example by a syntax.
Definition Log.h:610
Logger & fail(const TT &... args)
Possible error, but execution can continue. Special type of Logger::warn().
Definition Log.h:453
bool isLevel(level_t l)
Returns true, if the log monitor level is at least l.
Definition Log.h:348
Logger & attention(const TT &... args)
Possible error, but execution can continue. Special type of Logger::warn().
Definition Log.h:476
Logger(const char *filename, const TT &...args)
Start logging,.
Definition Log.h:1006
Logger & error(const TT &... args)
Echoes.
Definition Log.h:416
Logger & suspicious(const TT &... args)
A weak warning about something going possibly wrong.
Definition Log.h:500
Logger & accept(const TT &... args)
Some input has been accepted, for example by a syntax.
Definition Log.h:582
Logger & operator<<(oper op)
Handling flush operator.
Definition Log.h:793
Logger & unimplemented(const TT &... args)
Feature to be done. Special type of Logger::note().
Definition Log.h:511
Logger & deprecating(const TT &... args)
Feature will be removed. Special type of Logger::note().
Definition Log.h:521
Logger & debug2(const TT &... args)
Debug information.
Definition Log.h:676
Definition StreamBuilder.h:59
Definition StringBuilder.h:58
Definition TextStyleVT100.h:45
Definition DataSelector.cpp:1277
Definition Log.h:95