Changeset 375
- Timestamp:
- 04/26/15 00:59:09 (9 years ago)
- Location:
- cpp
- Files:
-
- 6 deleted
- 39 edited
- 6 copied
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
cpp/common/log.cpp
r372 r375 3 3 // See LICENSE.txt for details. 4 4 5 #include " hmessage.h"5 #include "log.h" 6 6 #include <common/nonstd_stdio.h> 7 7 #include "stl-util.h" 8 8 #include "Convert.h" 9 9 10 const char* HMSG_LEVEL[]={"[DEBUG] ","","[WARN] ","[ERROR] ","[CRITICAL] "};10 const char* LOG_LEVEL[] = { "[DEBUG] ", "", "[WARN] ", "[ERROR] ", "[CRITICAL] " }; 11 11 12 void Hmessage(const char *o, const char *m, const char *txt, int w)12 void logMessage(const char *obj, const char *method, int level, const char *msg) 13 13 { 14 14 int line = 0; //all lines except the first one get the "..." prefix … … 16 16 do 17 17 { 18 nextsep = strchr( txt, '\n');18 nextsep = strchr(msg, '\n'); 19 19 if (nextsep == NULL) //last chunk, until the end 20 nextsep = strchr( txt, '\0');21 if ((nextsep > txt) && (nextsep[-1] == '\r'))20 nextsep = strchr(msg, '\0'); 21 if ((nextsep > msg) && (nextsep[-1] == '\r')) 22 22 nextsep--; 23 23 if (line == 0) 24 24 { 25 25 if (*nextsep == 0) //there was only one line! no need to modify it in any way. 26 _ HmessageSingleLine(o, m, txt, w);26 _logMessageSingleLine(obj, method, level, msg); 27 27 else //first line from multi-line 28 _ HmessageSingleLine(o, m, string(txt, nextsep - txt).c_str(), w);28 _logMessageSingleLine(obj, method, level, string(msg, nextsep - msg).c_str()); 29 29 } 30 30 else //consecutive lines from multi-line 31 _ HmessageSingleLine(o, m, (HMSG_MULTILINE_CONTINUATION + string(txt, nextsep - txt)).c_str(), w); //could also add line numbers like ...(3)... but let's keep the prefix short and simple31 _logMessageSingleLine(obj, method, level, (LOG_MULTILINE_CONTINUATION + string(msg, nextsep - msg)).c_str()); //could also add line numbers like ...(3)... but let's keep the prefix short and simple 32 32 line++; 33 33 if ((nextsep[0] == '\r') && (nextsep[1] == '\n')) 34 txt= nextsep + 2;34 msg = nextsep + 2; 35 35 else if (*nextsep) 36 txt= nextsep + 1;36 msg = nextsep + 1; 37 37 } while (*nextsep); 38 38 } 39 39 40 40 41 void Hprintf_va(const char *o,const char *m,int w,const char *bl,va_list va)41 void logPrintf_va(const char *obj, const char *method, int level, const char *msgf, va_list va) 42 42 { 43 string buf =ssprintf_va(bl,va);44 Hmessage(o,m,buf.c_str(),w);43 string buf = ssprintf_va(msgf, va); 44 logMessage(obj, method, level, buf.c_str()); 45 45 } 46 46 47 void Hprintf(const char *o,const char *m,int w,const char *bl, ...)47 void logPrintf(const char *obj, const char *method, int level, const char *msgf, ...) 48 48 { 49 49 va_list argptr; 50 va_start(argptr, bl);51 Hprintf_va(o,m,w,bl,argptr);50 va_start(argptr, msgf); 51 logPrintf_va(obj, method, level, msgf, argptr); 52 52 va_end(argptr); 53 53 } 54 54 55 void printH(const char *bl,...)55 void log_printf(const char *msgf, ...) 56 56 { 57 57 va_list argptr; 58 va_start(argptr, bl);59 Hprintf_va("Message","printf",HMLV_INFO,bl,argptr);58 va_start(argptr, msgf); 59 logPrintf_va("Message", "printf", LOG_INFO, msgf, argptr); 60 60 va_end(argptr); 61 61 } -
cpp/common/log.h
r372 r375 3 3 // See LICENSE.txt for details. 4 4 5 #ifndef _ HMESSAGE_H_6 #define _ HMESSAGE_H_5 #ifndef _COMMON_LOG_H_ 6 #define _COMMON_LOG_H_ 7 7 8 8 #include <stdarg.h> 9 9 10 extern const char* HMSG_LEVEL[];11 #define HMSG_FORMAT "%s%s.%s: %s"12 #define HMSG_MULTILINE_CONTINUATION "..."10 extern const char* LOG_LEVEL[]; 11 #define LOG_FORMAT "%s%s.%s: %s" 12 #define LOG_MULTILINE_CONTINUATION "..." 13 13 14 void Hprintf(const char *o,const char *m,int w,const char *bl, ...);15 void Hprintf_va(const char *o,const char *m,int w,const char *bl,va_list va); //a different name than Hprintf - otherwise the compiler could confuse the "string" parameter with va_list and could call the wrong function16 void printH(const char *bl,...); //a shorthand for printf (a different name again to avoid the risk of confusion with the two functions above. This would be unlikely but possible when the argument types would match)17 void Hmessage(const char *o,const char *m,const char *txt,int w);18 14 19 void _HmessageSingleLine(const char *o,const char *m,const char *txt,int w); //don't call this directly - it is used internally 15 void logPrintf(const char *obj, const char *method, int level, const char *msgf, ...); 16 void logPrintf_va(const char *obj, const char *method, int level, const char *msgf, va_list va); //a different name than logPrintf - otherwise the compiler could confuse the "string" parameter with va_list and could call the wrong function 17 void log_printf(const char *msgf, ...); //a shorthand for printf (a different name again to avoid the risk of confusion with the two functions above. This would be unlikely but possible when the argument types would match) 18 void logMessage(const char *obj, const char *method, int level, const char *msg); 20 19 21 #define HMLV_DEBUG -1 22 #define HMLV_INFO 0 23 #define HMLV_WARN 1 24 #define HMLV_ERROR 2 25 #define HMLV_CRITICAL 3 20 void _logMessageSingleLine(const char *obj, const char *method, int level, const char *msg); //don't call this directly - it is used internally 26 21 27 /* 28 w: weight (importance) of a message 29 -1:debugging information, not needed for final users 30 0: information 31 1: warning or corrected error 32 2: uncorrected error. can cause malfunction 33 3: serious error, causes side effects. user should save what can be saved and restart the application34 */ 22 23 24 //level (importance) of a message 25 #define LOG_DEBUG -1 //debugging information, not needed for final users 26 #define LOG_INFO 0 //information 27 #define LOG_WARN 1 //warning or corrected error 28 #define LOG_ERROR 2 //uncorrected error, can cause malfunction 29 #define LOG_CRITICAL 3 //serious error, causes side effects. User should save what can be saved and restart the application 35 30 36 31 #endif -
cpp/common/nonstd_math.cpp
r372 r375 81 81 // But it was resolved by restarting windows and cleaning all intermediate compilation files :o (restarting windows was the key element! restarting BC++Builder and deleting files would not help) 82 82 83 #include " hmessage.h"83 #include "log.h" 84 84 85 85 unsigned int fp_control_word_std; … … 89 89 { 90 90 //unsigned int was=_clear87(); 91 // Hprintf("","fpExceptInit",HMLV_INFO,"control87 status before clear was %08x", was);91 //logPrintf("","fpExceptInit",LOG_INFO,"control87 status before clear was %08x", was); 92 92 fp_control_word_std=_control87(0, 0); //4978 = 1001101110010 93 93 // Make the new fp env same as the old one, except for the changes we're going to make … … 98 98 { 99 99 unsigned int was=_clear87(); //trzeba czyscic zeby nie bylo exception... 100 // Hprintf("","fpExceptEnable ",HMLV_INFO,"control87 status before clear was %08x", was);100 //logPrintf("","fpExceptEnable ",LOG_INFO,"control87 status before clear was %08x", was); 101 101 _control87(fp_control_word_std, 0xffffffff); 102 // Hprintf("","fpExceptEnable ",HMLV_INFO,"control87 flags are %08x", _control87(0, 0)); //kontrola co sie ustawilo102 //logPrintf("","fpExceptEnable ",LOG_INFO,"control87 flags are %08x", _control87(0, 0)); //kontrola co sie ustawilo 103 103 } 104 104 … … 106 106 { 107 107 unsigned int was=_clear87(); //trzeba czyscic zeby nie bylo exception... 108 // Hprintf("","fpExceptDisable",HMLV_INFO,"control87 status before clear was %08x", was);108 //logPrintf("","fpExceptDisable",LOG_INFO,"control87 status before clear was %08x", was); 109 109 _control87(fp_control_word_muted, 0xffffffff); 110 // Hprintf("","fpExceptDisable",HMLV_INFO,"control87 flags are %08x", _control87(0, 0)); //kontrola co sie ustawilo110 //logPrintf("","fpExceptDisable",LOG_INFO,"control87 flags are %08x", _control87(0, 0)); //kontrola co sie ustawilo 111 111 } 112 112 -
cpp/common/nonstd_stdio.cpp
r374 r375 242 242 243 243 #ifdef __ANDROID__ 244 #include " hmessage.h"244 #include "log.h" 245 245 #include "nonstd.h" 246 246 #include "nonstd_stl.h" … … 248 248 { 249 249 string respath=getAppResourcesDir(); 250 // printH("Opening '%s', mode='%s'",path,mode);251 // printH("getAppResourcesDir()='%s'",respath.c_str());250 //log_printf("Opening '%s', mode='%s'",path,mode); 251 //log_printf("getAppResourcesDir()='%s'",respath.c_str()); 252 252 NvFile *rfile=NULL; //can only read 253 253 FILE *rwfile=NULL; … … 256 256 path+=respath.length(); //strip the prefix, we need a relative path in assets 257 257 if (strstr(mode,"w")) 258 printH("Warning: attempt to open a read-only resource '%s' in writable mode '%s'",path,mode);258 log_printf("Warning: attempt to open a read-only resource '%s' in writable mode '%s'",path,mode); 259 259 rfile=NvFOpen(path); //"mode" not supported! can only read 260 // printH("Opened RES file as %p",rfile);260 //log_printf("Opened RES file as %p",rfile); 261 261 if (rfile==NULL) return NULL; 262 262 } else //a "normal" access (HOME) 263 263 { 264 264 rwfile=fopen(path,mode); 265 // printH("Opened HOME file as %p",rwfile);265 //log_printf("Opened HOME file as %p",rwfile); 266 266 if (rwfile==NULL) return NULL; 267 267 } -
cpp/common/stl-util.cpp
r374 r375 9 9 #include "Convert.h" 10 10 #include "nonstd.h" 11 #include " hmessage.h"11 #include "log.h" 12 12 #include <assert.h> 13 13 #ifdef USE_VIRTFILE … … 103 103 } 104 104 if (warn_on_missing_file && !ok) 105 Hprintf("stl-util", "readCompleteFile", HMLV_WARN, "Couldn't open file '%s'", filename);105 logPrintf("stl-util", "readCompleteFile", LOG_WARN, "Couldn't open file '%s'", filename); 106 106 return ok; 107 107 } … … 129 129 } 130 130 if (warn_on_fail && !ok) 131 Hprintf("stl-util", "writeCompleteFile", HMLV_WARN, "couldn't write file '%s'", filename);131 logPrintf("stl-util", "writeCompleteFile", LOG_WARN, "couldn't write file '%s'", filename); 132 132 return ok; 133 133 } -
cpp/frams/Makefile-SDK-files
r372 r375 2 2 3 3 # ALL_DIRS is later expanded by the shell, no spaces/newlines allowed, or it breaks 4 ALL_DIRS={common,frams,frams/canvas,frams/config,frams/ mhandlers,frams/genetics,frams/genetics/f0,frams/genetics/f1,frams/genetics/f2,frams/genetics/f3,frams/genetics/f4,frams/genetics/f5,frams/genetics/f6,frams/genetics/f7,frams/genetics/f8,frams/genetics/f9,frams/genetics/fF,frams/genetics/fT,frams/model,frams/neuro,frams/neuro/impl,frams/param,frams/test,frams/util,frams/vm/classes,frams/virtfile,frams/_demos,frams/model/geometry,frams/_demos/geometry,frams/model/similarity,frams/model/similarity/SVD}4 ALL_DIRS={common,frams,frams/canvas,frams/config,frams/loggers,frams/genetics,frams/genetics/f0,frams/genetics/f1,frams/genetics/f2,frams/genetics/f3,frams/genetics/f4,frams/genetics/f5,frams/genetics/f6,frams/genetics/f7,frams/genetics/f8,frams/genetics/f9,frams/genetics/fF,frams/genetics/fT,frams/model,frams/neuro,frams/neuro/impl,frams/param,frams/test,frams/util,frams/vm/classes,frams/virtfile,frams/_demos,frams/model/geometry,frams/_demos/geometry,frams/model/similarity,frams/model/similarity/SVD} 5 5 6 6 GENMANF4=frams/genetics/f4/oper_f4.o … … 19 19 GENMAN_COMMON_OBJS=frams/genetics/genman.o frams/param/mutableparam.o frams/param/mutparamlist.o frams/neuro/geneticneuroparam.o frams/neuro/neurolibparam.o 20 20 21 SDK_OBJS=frams/util/list.o frams/util/advlist.o frams/param/param.o frams/util/sstring.o frams/util/sstringutils.o frams/util/3d.o frams/vm/classes/3dobject.o frams/model/model.o frams/model/modelparts.o frams/neuro/neurolibrary.o frams/genetics/geno.o frams/genetics/genoconv.o frams/util/extvalue.o frams/vm/classes/collectionobj.o frams/util/hashtable.o common/ hmessage.o common/stl-util.o common/nonstd_stdio.o frams/util/callbacks.o frams/param/syntparam.o frams/util/multirange.o frams/util/multimap.o frams/param/paramtabobj.o frams/mhandlers/mhandlers.o frams/param/paramobj.o frams/genetics/oper_fx.o common/nonstd_math.o frams/mhandlers/stderrors.o common/Convert.o frams/util/rndutil.o21 SDK_OBJS=frams/util/list.o frams/util/advlist.o frams/param/param.o frams/util/sstring.o frams/util/sstringutils.o frams/util/3d.o frams/vm/classes/3dobject.o frams/model/model.o frams/model/modelparts.o frams/neuro/neurolibrary.o frams/genetics/geno.o frams/genetics/genoconv.o frams/util/extvalue.o frams/vm/classes/collectionobj.o frams/util/hashtable.o common/log.o common/stl-util.o common/nonstd_stdio.o frams/util/callbacks.o frams/param/syntparam.o frams/util/multirange.o frams/util/multimap.o frams/param/paramtabobj.o frams/loggers/loggers.o frams/param/paramobj.o frams/genetics/oper_fx.o common/nonstd_math.o frams/util/validitychecks.o common/Convert.o frams/util/rndutil.o 22 22 23 23 GEOMETRY_OBJS=frams/model/geometry/meshbuilder.o frams/model/geometry/modelgeometryinfo.o frams/model/geometry/geometryutils.o … … 25 25 #### sdk_tests 26 26 27 GENOMANIPULATION_OBJS= frams/_demos/genomanipulation.o frams/ mhandlers/stdouthandler.o frams/virtfile/virtfile.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS) $(GENMAN_SDK_OBJS)27 GENOMANIPULATION_OBJS= frams/_demos/genomanipulation.o frams/loggers/loggertostdout.o frams/virtfile/virtfile.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS) $(GENMAN_SDK_OBJS) 28 28 29 MULTILINE_F0_OBJS=frams/_demos/multiline_f0_test.o frams/virtfile/stringfile.o frams/virtfile/virtfile.o frams/ mhandlers/stdouthandler.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS) $(GENMAN_SDK_OBJS)29 MULTILINE_F0_OBJS=frams/_demos/multiline_f0_test.o frams/virtfile/stringfile.o frams/virtfile/virtfile.o frams/loggers/loggertostdout.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS) $(GENMAN_SDK_OBJS) 30 30 31 F0_VARIANTS_OBJS=frams/_demos/f0_variants_test.o frams/virtfile/stringfile.o frams/virtfile/virtfile.o frams/ mhandlers/stdouthandler.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS)31 F0_VARIANTS_OBJS=frams/_demos/f0_variants_test.o frams/virtfile/stringfile.o frams/virtfile/virtfile.o frams/loggers/loggertostdout.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS) 32 32 33 33 LOADER_TEST_OBJS=frams/_demos/genotypeloader.o frams/_demos/loader_test.o frams/virtfile/virtfile.o frams/param/multiparamload.o frams/virtfile/stdiofile.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS) 34 34 35 LOADER_TEST_PARAM_OBJS=frams/_demos/loader_test_param.o frams/virtfile/virtfile.o frams/param/multiparamload.o frams/virtfile/stdiofile.o frams/ mhandlers/stdouthandler.o $(SDK_OBJS)35 LOADER_TEST_PARAM_OBJS=frams/_demos/loader_test_param.o frams/virtfile/virtfile.o frams/param/multiparamload.o frams/virtfile/stdiofile.o frams/loggers/loggertostdout.o $(SDK_OBJS) 36 36 37 GENOCONV_TEST_OBJS= frams/_demos/genoconv_test.o frams/_demos/printconvmap.o frams/ mhandlers/stdouthandler.o frams/virtfile/virtfile.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS)37 GENOCONV_TEST_OBJS= frams/_demos/genoconv_test.o frams/_demos/printconvmap.o frams/loggers/loggertostdout.o frams/virtfile/virtfile.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS) 38 38 39 GENO_TEST_OBJS= frams/_demos/geno_test.o frams/virtfile/virtfile.o frams/ mhandlers/stdouthandler.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS) $(GENMAN_SDK_OBJS)39 GENO_TEST_OBJS= frams/_demos/geno_test.o frams/virtfile/virtfile.o frams/loggers/loggertostdout.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS) $(GENMAN_SDK_OBJS) 40 40 41 GENOOPER_TEST_OBJS=frams/_demos/genooper_test.o frams/virtfile/virtfile.o frams/ mhandlers/stdouthandler.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS) $(GENMAN_SDK_OBJS)41 GENOOPER_TEST_OBJS=frams/_demos/genooper_test.o frams/virtfile/virtfile.o frams/loggers/loggertostdout.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS) $(GENMAN_SDK_OBJS) 42 42 43 43 GENOOPER_TEST_FTEST_OBJS=frams/_demos/genooper_test_fTest.o frams/virtfile/virtfile.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS) $(GENMAN_SDK_OBJS) $(GENMAN_FT) 44 44 45 NEURO_TEST_OBJS= frams/_demos/neuro_test.o frams/ mhandlers/stdouthandler.o frams/virtfile/virtfile.o \45 NEURO_TEST_OBJS= frams/_demos/neuro_test.o frams/loggers/loggertostdout.o frams/virtfile/virtfile.o \ 46 46 frams/neuro/neuroimpl.o frams/neuro/neurofactory.o frams/neuro/impl/neuroimpl-simple.o frams/neuro/impl/neuroimpl-channels.o \ 47 47 frams/neuro/impl/neuroimpl-fuzzy.o frams/neuro/impl/neuroimpl-fuzzy-f0.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS) $(GENMAN_SDK_OBJS) 48 48 49 FULL_PROPS_OBJS= frams/_demos/full_props.o frams/ mhandlers/stdouthandler.o frams/virtfile/virtfile.o frams/virtfile/stdiofile.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS) $(GENMAN_SDK_OBJS)49 FULL_PROPS_OBJS= frams/_demos/full_props.o frams/loggers/loggertostdout.o frams/virtfile/virtfile.o frams/virtfile/stdiofile.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS) $(GENMAN_SDK_OBJS) 50 50 51 SHAPECONVERT_OBJS= frams/_demos/shapeconvert.o frams/ mhandlers/stdouthandler.o frams/virtfile/virtfile.o frams/virtfile/stdiofile.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS) $(GENMAN_SDK_OBJS)51 SHAPECONVERT_OBJS= frams/_demos/shapeconvert.o frams/loggers/loggertostdout.o frams/virtfile/virtfile.o frams/virtfile/stdiofile.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS) $(GENMAN_SDK_OBJS) 52 52 53 53 SERIAL_TEST_OBJS= frams/_demos/serial_test.o frams/virtfile/virtfile.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS) … … 55 55 PART_SHAPES_OBJS= frams/_demos/part_shapes.o frams/virtfile/virtfile.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS) 56 56 57 NEURO_LAYOUT_TEST_OBJS= frams/_demos/neuro_layout_test.o frams/virtfile/virtfile.o frams/ mhandlers/stdouthandler.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS) $(GENMAN_SDK_OBJS) frams/canvas/nn_layout_model.o frams/canvas/nn_simple_layout.o frams/canvas/nn_smart_layout.o57 NEURO_LAYOUT_TEST_OBJS= frams/_demos/neuro_layout_test.o frams/virtfile/virtfile.o frams/loggers/loggertostdout.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS) $(GENMAN_SDK_OBJS) frams/canvas/nn_layout_model.o frams/canvas/nn_simple_layout.o frams/canvas/nn_smart_layout.o 58 58 59 59 GEOMETRY_INFO_TEST_OBJS=frams/_demos/geometry/info_test.o frams/_demos/geometry/geometrytestutils.o frams/_demos/genotypeloader.o frams/virtfile/virtfile.o frams/param/multiparamload.o frams/virtfile/stdiofile.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS) $(GEOMETRY_OBJS) … … 66 66 67 67 SIMIL_TEST_OBJS=frams/_demos/simil_test.o frams/model/similarity/SVD/lapack.o frams/model/similarity/SVD/matrix_tools.o frams/model/similarity/simil_match.o frams/model/similarity/simil_model.o \ 68 frams/_demos/genotypeloader.o frams/virtfile/virtfile.o frams/param/multiparamload.o frams/virtfile/stdiofile.o frams/ mhandlers/stdouthandler.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS) $(GENMAN_SDK_OBJS)68 frams/_demos/genotypeloader.o frams/virtfile/virtfile.o frams/param/multiparamload.o frams/virtfile/stdiofile.o frams/loggers/loggertostdout.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS) $(GENMAN_SDK_OBJS) 69 69 70 70 SIMIL_UNITTESTS_OBJS=frams/_demos/simil_unittests.o frams/model/similarity/simil_match.o -
cpp/frams/_demos/f0_variants_test.cpp
r372 r375 10 10 #include <frams/genetics/defgenoconv.h> 11 11 #include <frams/model/model.h> 12 #include <frams/ mhandlers/stdouthandler.h>12 #include <frams/loggers/loggertostdout.h> 13 13 14 14 void save_as_f0(SString &gen,Model &m,bool omit_default_values) … … 74 74 int main(int argc,char*argv[]) 75 75 { 76 MessageHandlerToStdout messages_to_stdout(MessageHandlerBase::Enable);76 LoggerToStdout messages_to_stdout(LoggerBase::Enable); 77 77 78 78 //without converters the application would only handle "format 0" genotypes -
cpp/frams/_demos/full_props.cpp
r372 r375 9 9 10 10 #include <frams/model/model.h> 11 #include <frams/ mhandlers/stdouthandler.h>11 #include <frams/loggers/loggertostdout.h> 12 12 #include <frams/genetics/preconfigured.h> 13 13 … … 50 50 { 51 51 StdioFILE::setStdio();//setup VirtFILE::Vstdin/out/err 52 MessageHandlerToStdout messages_to_stderr(MessageHandlerBase::Enable | MessageHandlerBase::DontBlock,VirtFILE::Vstderr); //errors -> stderr, don't interfere with stdout52 LoggerToStdout messages_to_stderr(LoggerBase::Enable | LoggerBase::DontBlock,VirtFILE::Vstderr); //errors -> stderr, don't interfere with stdout 53 53 54 54 PreconfiguredGenetics genetics; … … 79 79 if (!m.isValid()) 80 80 { 81 Hprintf("","full_props",HMLV_ERROR,"Cannot build Model from the supplied genotype\n");81 logPrintf("","full_props",LOG_ERROR,"Cannot build Model from the supplied genotype\n"); 82 82 return 2; 83 83 } -
cpp/frams/_demos/geno_test.cpp
r372 r375 6 6 #include <frams/util/sstringutils.h> 7 7 #include <frams/genetics/preconfigured.h> 8 #include <frams/ mhandlers/stdouthandler.h>8 #include <frams/loggers/loggertostdout.h> 9 9 10 10 /** … … 18 18 { 19 19 PreconfiguredGenetics genetics; 20 MessageHandlerToStdout messages_to_stdout(MessageHandlerBase::Enable); //comment this object out to mute error/warning messages20 LoggerToStdout messages_to_stdout(LoggerBase::Enable); //comment this object out to mute error/warning messages 21 21 22 22 if (argc <= 1) -
cpp/frams/_demos/genoconv_test.cpp
r372 r375 9 9 10 10 #include "printconvmap.h" 11 #include <frams/ mhandlers/stdouthandler.h>11 #include <frams/loggers/loggertostdout.h> 12 12 13 13 /** … … 117 117 int main(int argc,char *argv[]) 118 118 { 119 MessageHandlerToStdout messages_to_stdout(MessageHandlerBase::Enable);119 LoggerToStdout messages_to_stdout(LoggerBase::Enable); 120 120 121 121 DefaultGenoConvManager gcm; -
cpp/frams/_demos/genomanipulation.cpp
r372 r375 10 10 #include <frams/model/model.h> 11 11 #include <frams/genetics/preconfigured.h> 12 #include <frams/ mhandlers/stdouthandler.h>12 #include <frams/loggers/loggertostdout.h> 13 13 14 14 /** … … 266 266 int main(int argc,char*argv[]) 267 267 { 268 MessageHandlerToStdout messages_to_stdout(MessageHandlerBase::Enable); //redirect model-related errors to stdout268 LoggerToStdout messages_to_stdout(LoggerBase::Enable); //redirect model-related errors to stdout 269 269 270 270 srand(time(0)); -
cpp/frams/_demos/genooper_test.cpp
r372 r375 3 3 // See LICENSE.txt for details. 4 4 5 #include <frams/ mhandlers/stdouthandler.h>5 #include <frams/loggers/loggertostdout.h> 6 6 #include <frams/genetics/preconfigured.h> 7 7 … … 21 21 int main(int argc, char *argv[]) 22 22 { 23 MessageHandlerToStdout messages_to_stdout(MessageHandlerBase::Enable);23 LoggerToStdout messages_to_stdout(LoggerBase::Enable); 24 24 PreconfiguredGenetics genetics; 25 25 -
cpp/frams/_demos/loader_test_param.cpp
r372 r375 5 5 #include <frams/param/multiparamload.h> 6 6 #include <frams/virtfile/stdiofile.h> 7 #include <frams/ mhandlers/stdouthandler.h>7 #include <frams/loggers/loggertostdout.h> 8 8 9 9 /** … … 66 66 StdioFILEDontClose virt_stderr(stderr); 67 67 StdioFILEDontClose virt_stdout(stdout); 68 MessageHandlerToStdout messages_to_stderr(MessageHandlerBase::Enable, &virt_stderr);68 LoggerToStdout messages_to_stderr(LoggerBase::Enable, &virt_stderr); 69 69 StdioFileSystem_autoselect stdiofilesys; 70 70 MultiParamLoader loader(argv[1]); -
cpp/frams/_demos/multiline_f0_test.cpp
r372 r375 10 10 #include <frams/genetics/preconfigured.h> 11 11 #include <frams/model/model.h> 12 #include <frams/ mhandlers/stdouthandler.h>12 #include <frams/loggers/loggertostdout.h> 13 13 #include <frams/virtfile/stringfile.h> 14 14 15 15 int main(int argc,char*argv[]) 16 16 { 17 MessageHandlerToStdout messages_to_stdout(MessageHandlerBase::Enable);17 LoggerToStdout messages_to_stdout(LoggerBase::Enable); 18 18 PreconfiguredGenetics genetics; 19 19 -
cpp/frams/_demos/neuro_layout_test.cpp
r372 r375 7 7 #include <frams/genetics/preconfigured.h> 8 8 #include <frams/model/model.h> 9 #include <frams/ mhandlers/stdouthandler.h>9 #include <frams/loggers/loggertostdout.h> 10 10 #include <frams/canvas/nn_layout_model.h> 11 11 … … 83 83 int main(int argc,char*argv[]) 84 84 { 85 MessageHandlerToStdout messages_to_stdout(MessageHandlerBase::Enable);85 LoggerToStdout messages_to_stdout(LoggerBase::Enable); 86 86 PreconfiguredGenetics genetics; 87 87 -
cpp/frams/_demos/neuro_test.cpp
r372 r375 9 9 #include <frams/neuro/neuroimpl.h> 10 10 #include <frams/neuro/neurofactory.h> 11 #include <frams/ mhandlers/stdouthandler.h>11 #include <frams/loggers/loggertostdout.h> 12 12 13 13 /** … … 60 60 int main(int argc,char*argv[]) 61 61 { 62 MessageHandlerToStdout messages_to_stdout(MessageHandlerBase::Enable);62 LoggerToStdout messages_to_stdout(LoggerBase::Enable); 63 63 PreconfiguredGenetics genetics; 64 64 -
cpp/frams/_demos/shapeconvert.cpp
r372 r375 9 9 10 10 #include <frams/model/model.h> 11 #include <frams/ mhandlers/stdouthandler.h>11 #include <frams/loggers/loggertostdout.h> 12 12 #include <frams/genetics/preconfigured.h> 13 13 … … 34 34 { 35 35 StdioFILE::setStdio();//setup VirtFILE::Vstdin/out/err 36 MessageHandlerToStdout messages_to_stderr(MessageHandlerBase::Enable | MessageHandlerBase::DontBlock, VirtFILE::Vstderr); //errors -> stderr, don't interfere with stdout36 LoggerToStdout messages_to_stderr(LoggerBase::Enable | LoggerBase::DontBlock, VirtFILE::Vstderr); //errors -> stderr, don't interfere with stdout 37 37 38 38 PreconfiguredGenetics genetics; … … 50 50 if ((shape != Part::SHAPE_ELLIPSOID) && (shape != Part::SHAPE_CUBOID) && (shape != Part::SHAPE_CYLINDER)) 51 51 { 52 Hprintf("", "shapeconvert", HMLV_ERROR, "Invalid shape");52 logPrintf("", "shapeconvert", LOG_ERROR, "Invalid shape"); 53 53 return 4; 54 54 } … … 71 71 if (!m.isValid()) 72 72 { 73 Hprintf("", "shapeconvert", HMLV_ERROR, "Cannot build Model from the supplied genotype");73 logPrintf("", "shapeconvert", LOG_ERROR, "Cannot build Model from the supplied genotype"); 74 74 return 2; 75 75 } … … 77 77 if (m.getShape() != Model::SHAPE_OLD) 78 78 { 79 Hprintf("", "shapeconvert", HMLV_ERROR, "Only old style shapes can be converted");79 logPrintf("", "shapeconvert", LOG_ERROR, "Only old style shapes can be converted"); 80 80 return 3; 81 81 } -
cpp/frams/_demos/simil_test.cpp
r372 r375 5 5 6 6 #include <vector> 7 #include "frams/ mhandlers/stdouthandler.h"7 #include "frams/loggers/loggertostdout.h" 8 8 #include "frams/_demos/genotypeloader.h" 9 9 #include "frams/genetics/preconfigured.h" … … 39 39 int main(int argc, char *argv[]) 40 40 { 41 MessageHandlerToStdout messages_to_stdout(MessageHandlerBase::Enable);41 LoggerToStdout messages_to_stdout(LoggerBase::Enable); 42 42 typedef double *pDouble; 43 43 int iCurrParam = 0; // index of the currently processed parameter -
cpp/frams/genetics/f1/conv_f1.cpp
r372 r375 5 5 #include "conv_f1.h" 6 6 #include <common/nonstd_stl.h> 7 #include <common/ hmessage.h>7 #include <common/log.h> 8 8 #include <frams/util/multirange.h> 9 9 #include <frams/util/multimap.h> … … 63 63 if ((n1<0) || (n2<0) || (n1>=neuro_f1_to_f0.size()) || (n2>=neuro_f1_to_f0.size())) 64 64 { 65 if (final) Hprintf("GenoConvF1","addInput",HMLV_WARN,65 if (final) logPrintf("GenoConvF1","addInput",LOG_WARN, 66 66 "illegal neuron connection %d <- %d (ignored)",n1,n2); 67 67 return 0; … … 178 178 else 179 179 { 180 Hmessage("GenoConv_F1","grow","Illegal neuron position (ignored)",1);180 logMessage("GenoConv_F1","grow",1,"Illegal neuron position (ignored)"); 181 181 g=skipNeuro(g+1); 182 182 } -
cpp/frams/genetics/f4/conv_f4.cpp
r372 r375 6 6 7 7 #include "conv_f4.h" 8 #include <common/ hmessage.h>8 #include <common/log.h> 9 9 #include "../oper_fx.h" //for GENOPER_OK constant 10 10 … … 110 110 if (res) 111 111 { 112 Hmessage("f4_Model", "buildModelRec", "Error in building Model", 2);112 logMessage("f4_Model", "buildModelRec", 2, "Error in building Model"); 113 113 error = res; 114 114 break; … … 134 134 return cells->C[i]; 135 135 // none! 136 Hmessage("f4_Model", "getStick", "Not a single stick", 2);136 logMessage("f4_Model", "getStick", 2, "Not a single stick"); 137 137 return NULL; 138 138 } -
cpp/frams/genetics/f4/f4_general.cpp
r372 r375 7 7 #include "f4_general.h" 8 8 #include <common/nonstd_stl.h> 9 #include <common/ hmessage.h>9 #include <common/log.h> 10 10 #include <frams/model/model.h> // for min and max attributes 11 11 #include "../oper_fx.h" //for GENOPER_ constants … … 581 581 char buf[40]; 582 582 sprintf(buf, "unknown code '%c'", gcur->name); 583 Hmessage("f4_Cell", "onestep", buf, 2);583 logMessage("f4_Cell", "onestep", 2, buf); 584 584 // fix: delete it 585 585 org->setRepairRemove(gcur->pos, gcur); -
cpp/frams/genetics/f4/oper_f4.cpp
r372 r375 8 8 #include "oper_f4.h" 9 9 #include <frams/util/sstring.h> 10 #include <common/ hmessage.h>10 #include <common/log.h> 11 11 12 12 #include <stdio.h> … … 51 51 mutation_method_names[index++] = "deleted a node"; 52 52 mutation_method_names[index++] = "modified a node"; 53 if (index != F4_COUNT + F4_ADD_COUNT - 1) Hmessage("Geno_f4", "Constructor", "Mutation names init error", 3);53 if (index != F4_COUNT + F4_ADD_COUNT - 1) logMessage("Geno_f4", "Constructor", 3, "Mutation names init error"); 54 54 } 55 55 -
cpp/frams/genetics/genman.cpp
r372 r375 6 6 #include <frams/vm/classes/genoobj.h> 7 7 #include GEN_CONFIG_FILE //configuration of active genetic operators 8 #include "common/ hmessage.h"8 #include "common/log.h" 9 9 #include "common/nonstd_math.h" 10 10 #include "common/stl-util.h" 11 #include <frams/ mhandlers/mhandlers.h>11 #include <frams/loggers/loggers.h> 12 12 13 13 … … 267 267 if (gf->mutate(gn, chg, method) == GENOPER_OK) 268 268 { 269 MessageHandlerToMemory eh(MessageHandlerBase::Enable | MessageHandlerToMemory::StoreFirstMessage); //mute testValidity()269 LoggerToMemory eh(LoggerBase::Enable | LoggerToMemory::StoreFirstMessage); //mute testValidity() 270 270 Geno G(gn, gv.getFormat(), "", ""); 271 271 canvalidate = true; … … 284 284 if (!ok && (count - pcount > 100)) 285 285 { 286 Hprintf("GenMan", "Mutate", 2, "Tried 100x and failed: %s", g.getGene().c_str());286 logPrintf("GenMan", "Mutate", 2, "Tried 100x and failed: %s", g.getGene().c_str()); 287 287 return Geno("", -1, "", "GENOPER_OPFAIL: Mutate() tried 100x and failed"); 288 288 } … … 308 308 309 309 { 310 MessageHandlerToMemory eh(MessageHandlerBase::Enable | MessageHandlerToMemory::StoreFirstMessage); //mute testValidity()310 LoggerToMemory eh(LoggerBase::Enable | LoggerToMemory::StoreFirstMessage); //mute testValidity() 311 311 bool canvalidate = true; 312 312 if (testValidity(g1v, canvalidate) > 0 && canvalidate == false) … … 333 333 if (g1n[0]) { gn = g1n; chg = chg1; } 334 334 else { gn = g2n; chg = chg2; } 335 MessageHandlerToMemory eh(MessageHandlerBase::Enable | MessageHandlerToMemory::StoreFirstMessage); //mute testValidity()335 LoggerToMemory eh(LoggerBase::Enable | LoggerToMemory::StoreFirstMessage); //mute testValidity() 336 336 Geno G(gn, g1v.getFormat(), "", ""); 337 337 bool canvalidate = true; … … 351 351 if (!ok && (count - pcount > 100)) 352 352 { 353 Hprintf("GenMan", "CrossOver", 2, "Tried 100x and failed: %s and %s", g1.getGene().c_str(), g2.getGene().c_str());353 logPrintf("GenMan", "CrossOver", 2, "Tried 100x and failed: %s and %s", g1.getGene().c_str(), g2.getGene().c_str()); 354 354 return Geno("", -1, "", "GENOPER_OPFAIL: CrossOver() tried 100x and failed"); 355 355 } … … 500 500 l.chg = chg; 501 501 l.fit = 0; //temporarily. Will be set when the genotype dies 502 // Hprintf("GenMan","saveLink",0,"#%d: [%d] '%s' + '%s' -> '%s'",GenoLinkList.size(),count,parent1.c_str(),parent2.c_str(),child.c_str());502 //logPrintf("GenMan","saveLink",0,"#%d: [%d] '%s' + '%s' -> '%s'",GenoLinkList.size(),count,parent1.c_str(),parent2.c_str(),child.c_str()); 503 503 GenoLinkList.push_back(l); 504 504 } … … 533 533 float f1, f2; 534 534 int m; 535 Hmessage("GenMan", "Report", "The following genetic operators are available:", 0);535 logMessage("GenMan", "Report", 0, "The following genetic operators are available:"); 536 536 for (unsigned int i = 0; i < oper_fx_list.size(); i++) 537 537 { … … 549 549 } 550 550 // if (oper_fx_list[i]->similarity("","")!=GENOPER_NOOPER) l+=" similarity"; 551 Hprintf("GenMan", "Report", 0, "format f%c (%s):%s",551 logPrintf("GenMan", "Report", 0, "format f%c (%s):%s", 552 552 oper_fx_list[i]->supported_format, oper_fx_list[i]->name.c_str(), l.c_str()); 553 553 } -
cpp/frams/genetics/geno.cpp
r372 r375 250 250 } 251 251 isvalid = 0; 252 Hprintf("Geno", "validate", HMLV_WARN, "Wrong configuration? No genotype validators defined for genetic format f%c.", format);252 logPrintf("Geno", "validate", LOG_WARN, "Wrong configuration? No genotype validators defined for genetic format f%c.", format); 253 253 } 254 254 -
cpp/frams/genetics/oper_fx.cpp
r372 r375 5 5 #include <ctype.h> //isupper() 6 6 #include "oper_fx.h" 7 #include <common/ hmessage.h>7 #include <common/log.h> 8 8 #include <common/nonstd_math.h> 9 9 #include <frams/util/rndutil.h> … … 173 173 } 174 174 else 175 Hprintf("GenoOperators", "linearMix", HMLV_WARN, "Cannot mix values of types '%c' and '%c'", type1, type2);175 logPrintf("GenoOperators", "linearMix", LOG_WARN, "Cannot mix values of types '%c' and '%c'", type1, type2); 176 176 } 177 177 … … 250 250 { 251 251 if (s == NULL) 252 Hmessage("GenoOperators", "skipWS", "NULL reference!", HMLV_WARN);252 logMessage("GenoOperators", "skipWS", LOG_WARN, "NULL reference!"); 253 253 else 254 254 while (isWS(*s)) s++; -
cpp/frams/loggers/loggers.cpp
r374 r375 3 3 // See LICENSE.txt for details. 4 4 5 #include " mhandlers.h"5 #include "loggers.h" 6 6 #include <common/stl-util.h> 7 7 8 void _ HmessageSingleLine(const char *o, const char *m, const char *txt, int w)8 void _logMessageSingleLine(const char *o, const char *m, int w, const char *txt) 9 9 { 10 tlsGetRef(message_handler_manager_instance).send(o, m, txt, w);10 tlsGetRef(message_handler_manager_instance).send(o, m, w, txt); 11 11 } 12 12 13 THREAD_LOCAL_DEF( MessageHandlerManager, message_handler_manager_instance);13 THREAD_LOCAL_DEF(LoggerManager, message_handler_manager_instance); 14 14 15 void MessageHandlerManager::send(int level, const char *o, const char *m, const char *bl, int w)15 void LoggerManager::send(int level, const char *o, const char *m, int w, const char *bl) 16 16 { 17 17 if (level >= handlers.size()) level = handlers.size() - 1; … … 19 19 for (int i = level; i >= 0; i--) 20 20 { 21 MessageHandlerBase *r = handlers(i);22 if ((!(r->options & MessageHandlerBase::Paused)) &&23 ((!blocked) || (r->options & MessageHandlerBase::CannotBeBlocked)))21 LoggerBase *r = handlers(i); 22 if ((!(r->options & LoggerBase::Paused)) && 23 ((!blocked) || (r->options & LoggerBase::CannotBeBlocked))) 24 24 { 25 r->handle(o, m, bl, w);26 if (!(r->options & MessageHandlerBase::DontBlock)) blocked = 1;25 r->handle(o, m, w, bl); 26 if (!(r->options & LoggerBase::DontBlock)) blocked = 1; 27 27 } 28 28 } 29 29 } 30 30 31 int MessageHandlerManager::add(MessageHandlerBase *h)31 int LoggerManager::add(LoggerBase *h) 32 32 { 33 33 h->manager = this; … … 36 36 } 37 37 38 void MessageHandlerManager::remove(int i)38 void LoggerManager::remove(int i) 39 39 { 40 MessageHandlerBase *h = handlers(i);40 LoggerBase *h = handlers(i); 41 41 h->manager = NULL; 42 42 handlers.remove(i); 43 43 } 44 44 45 void MessageHandlerManager::remove(MessageHandlerBase *h)45 void LoggerManager::remove(LoggerBase *h) 46 46 { 47 47 int i; … … 50 50 } 51 51 52 void MessageHandlerManager::removeAll()52 void LoggerManager::removeAll() 53 53 { 54 54 while (handlers.size() > 0) … … 58 58 ////////////////////////////////// 59 59 60 void MessageHandlerBase::send(const char *o, const char *m, const char *bl, int w)60 void LoggerBase::send(const char *o, const char *m, int w, const char *bl) 61 61 { 62 62 if (!isEnabled()) return; 63 63 int level = manager->find(this); 64 if (level >= 0) manager->send(level - 1, o, m, bl, w);64 if (level >= 0) manager->send(level - 1, o, m, w, bl); 65 65 } 66 66 67 void MessageHandlerBase::Hprintf(const char *o, const char *m, int w, const char *bl, ...)67 void LoggerBase::logPrintf(const char *o, const char *m, int w, const char *bl, ...) 68 68 { 69 69 if (!isEnabled()) return; … … 73 73 buf = ssprintf_va(bl, argptr); 74 74 va_end(argptr); 75 send(o, m, buf.c_str(), w);75 send(o, m, w, buf.c_str()); 76 76 } 77 77 78 78 79 void MessageHandlerBase::enable()79 void LoggerBase::enable() 80 80 { 81 81 if (isEnabled()) return; … … 83 83 } 84 84 85 void MessageHandlerBase::disable()85 void LoggerBase::disable() 86 86 { 87 87 if (!isEnabled()) return; … … 89 89 } 90 90 91 void MessageHandlerBase::pause()91 void LoggerBase::pause() 92 92 { 93 93 if (isPaused()) return; … … 95 95 } 96 96 97 void MessageHandlerBase::resume()97 void LoggerBase::resume() 98 98 { 99 99 if (!isPaused()) return; … … 103 103 ///////////////////////////////// 104 104 105 void MessageHandlerToMemory::handle(const char *o, const char *m, const char *bl, int w)105 void LoggerToMemory::handle(const char *o, const char *m, int w, const char *bl) 106 106 { 107 107 if (w > maxlevel) maxlevel = w; 108 if (w >= HMLV_INFO) infocount++;109 if (w >= HMLV_WARN) warncount++;110 if (w >= HMLV_ERROR) errcount++;108 if (w >= LOG_INFO) infocount++; 109 if (w >= LOG_WARN) warncount++; 110 if (w >= LOG_ERROR) errcount++; 111 111 112 112 if (w >= minleveltostore) … … 118 118 { 119 119 if (msgs.len() > 0) msgs += '\n'; 120 msgs += o; msgs += "::"; msgs += m; 121 msgs += " - "; msgs += bl; 120 msgs += SString::sprintf(LOG_FORMAT,LOG_LEVEL[w+1],o,m,bl); 122 121 } 123 122 } -
cpp/frams/loggers/loggers.h
r374 r375 3 3 // See LICENSE.txt for details. 4 4 5 #ifndef _ MHANDLERS_H_6 #define _ MHANDLERS_H_5 #ifndef _FRAMS_LOGGERS_H_ 6 #define _FRAMS_LOGGERS_H_ 7 7 8 8 #include <frams/util/list.h> 9 9 #include <frams/util/sstring.h> 10 #include <common/ hmessage.h>10 #include <common/log.h> 11 11 #include <common/threads.h> 12 12 13 class MessageHandlerBase;13 class LoggerBase; 14 14 15 class MessageHandlerManager15 class LoggerManager 16 16 { 17 friend class MessageHandlerBase;18 SListTempl< MessageHandlerBase*> handlers;19 void send(int level, const char *o, const char *m, const char *bl, int w);17 friend class LoggerBase; 18 SListTempl<LoggerBase*> handlers; 19 void send(int level, const char *o, const char *m, int w, const char *bl); 20 20 public: 21 int find( MessageHandlerBase *r) { return handlers.find(r); }22 int add( MessageHandlerBase *r);21 int find(LoggerBase *r) { return handlers.find(r); } 22 int add(LoggerBase *r); 23 23 void remove(int i); 24 void remove( MessageHandlerBase *r);24 void remove(LoggerBase *r); 25 25 void removeAll(); 26 void send(const char *o, const char *m, const char *bl, int w)26 void send(const char *o, const char *m, int w, const char *bl) 27 27 { 28 send(handlers.size() - 1, o, m, bl, w);28 send(handlers.size() - 1, o, m, w, bl); 29 29 } 30 ~ MessageHandlerManager() { removeAll(); }30 ~LoggerManager() { removeAll(); } 31 31 }; 32 32 33 extern THREAD_LOCAL_DECL( MessageHandlerManager, message_handler_manager_instance);33 extern THREAD_LOCAL_DECL(LoggerManager, message_handler_manager_instance); 34 34 35 35 //////////////////////////////////////// 36 36 37 class MessageHandlerBase37 class LoggerBase 38 38 { 39 friend class MessageHandlerManager;39 friend class LoggerManager; 40 40 protected: 41 MessageHandlerManager* manager;41 LoggerManager* manager; 42 42 int options; 43 43 44 44 public: 45 45 46 enum HandlerOptions46 enum LoggerOptions 47 47 { 48 48 DontBlock = 1, CannotBeBlocked = 2, Enable = 4, Paused = 8 49 49 }; 50 50 51 void Hprintf(const char *o, const char *m, int w, const char *bl, ...);52 void send(const char *o, const char *m, const char *bl, int w);51 void logPrintf(const char *o, const char *m, int w, const char *bl, ...); 52 void send(const char *o, const char *m, int w, const char *bl); 53 53 54 54 bool isEnabled() { return manager ? true : false; } … … 59 59 void resume(); 60 60 61 MessageHandlerBase(int opts = 0) :manager(NULL), options(opts)61 LoggerBase(int opts = 0) :manager(NULL), options(opts) 62 62 { 63 63 if (options&Enable) enable(); 64 64 } 65 virtual ~ MessageHandlerBase()65 virtual ~LoggerBase() 66 66 { 67 67 disable(); 68 68 } 69 69 70 virtual void handle(const char *o, const char *m, const char *bl, int w) {}70 virtual void handle(const char *o, const char *m, int w, const char *bl) {} 71 71 }; 72 72 73 73 /////////////////////////////////////////// 74 74 75 class MessageHandlerToMemory : public MessageHandlerBase75 class LoggerToMemory : public LoggerBase 76 76 { 77 77 protected: … … 81 81 public: 82 82 83 void reset() { maxlevel = HMLV_INFO - 1; errcount = warncount = storedcount = infocount = 0; msgs = 0; }83 void reset() { maxlevel = LOG_INFO - 1; errcount = warncount = storedcount = infocount = 0; msgs = 0; } 84 84 85 85 enum Options2 … … 95 95 const SString& getMessages() { return msgs; } 96 96 97 MessageHandlerToMemory(int opts = 0, int minimal_level_to_store = HMLV_ERROR) :MessageHandlerBase(opts), minleveltostore(minimal_level_to_store)97 LoggerToMemory(int opts = 0, int minimal_level_to_store = LOG_ERROR) :LoggerBase(opts), minleveltostore(minimal_level_to_store) 98 98 { 99 99 reset(); 100 100 } 101 101 102 void handle(const char *o, const char *m, const char *bl, int w);102 void handle(const char *o, const char *m, int w, const char *bl); 103 103 }; 104 104 105 class Redirecting MessageHandler : public MessageHandlerBase105 class RedirectingLogger : public LoggerBase 106 106 { 107 MessageHandlerManager *other_manager;107 LoggerManager *other_manager; 108 108 public: 109 Redirecting MessageHandler(MessageHandlerManager *other_mgr,int opts=0)110 : MessageHandlerBase(opts), other_manager(other_mgr) {}109 RedirectingLogger(LoggerManager *other_mgr,int opts=0) 110 :LoggerBase(opts), other_manager(other_mgr) {} 111 111 112 void handle(const char *o, const char *m, const char *bl, int w)112 void handle(const char *o, const char *m, int w, const char *bl) 113 113 { 114 other_manager->send(o, m, bl, w);114 other_manager->send(o, m, w, bl); 115 115 } 116 116 }; -
cpp/frams/loggers/loggertostdout.cpp
r374 r375 3 3 // See LICENSE.txt for details. 4 4 5 #include " stdouthandler.h"5 #include "loggertostdout.h" 6 6 #ifdef SHP 7 7 #include <FBaseSys.h> //AppLog … … 10 10 #endif 11 11 12 void MessageHandlerToStdout::handle(const char *o, const char *m, const char *bl, int w)12 void LoggerToStdout::handle(const char *o, const char *m, int w, const char *bl) 13 13 { 14 14 if (w < -1) w = -1; else if (w>3) w = 3; 15 15 #ifdef SHP 16 AppLog( HMSG_FORMAT "\n",HMSG_LEVEL[w+1],o,m,bl);16 AppLog(LOG_FORMAT "\n",LOG_LEVEL[w+1],o,m,bl); 17 17 #else 18 18 if (file) 19 file->printf( HMSG_FORMAT "\n", HMSG_LEVEL[w + 1], o, m, bl);19 file->printf(LOG_FORMAT "\n", LOG_LEVEL[w + 1], o, m, bl); 20 20 else 21 printf( HMSG_FORMAT "\n", HMSG_LEVEL[w + 1], o, m, bl);21 printf(LOG_FORMAT "\n", LOG_LEVEL[w + 1], o, m, bl); 22 22 #endif 23 23 } -
cpp/frams/loggers/loggertostdout.h
r374 r375 3 3 // See LICENSE.txt for details. 4 4 5 #ifndef _STDOUT HANDLER_H_6 #define _STDOUT HANDLER_H_5 #ifndef _STDOUT_LOGGER_H_ 6 #define _STDOUT_LOGGER_H_ 7 7 8 #include " mhandlers.h"8 #include "loggers.h" 9 9 #include <frams/virtfile/virtfile.h> 10 10 11 class MessageHandlerToStdout : public MessageHandlerBase11 class LoggerToStdout : public LoggerBase 12 12 { 13 13 VirtFILE *file; 14 14 public: 15 MessageHandlerToStdout(int opts = 0, VirtFILE *_file = NULL) :MessageHandlerBase(opts), file(_file) {}16 void handle(const char *o, const char *m, const char *bl, int w);15 LoggerToStdout(int opts = 0, VirtFILE *_file = NULL) :LoggerBase(opts), file(_file) {} 16 void handle(const char *o, const char *m, int w, const char *bl); 17 17 }; 18 18 -
cpp/frams/model/geometry/geometryutils.cpp
r372 r375 82 82 break; 83 83 } 84 Hprintf("GeometryUtils", "isPointInsidePart", HMLV_ERROR, "Part shape=%d not supported", part->shape);84 logPrintf("GeometryUtils", "isPointInsidePart", LOG_ERROR, "Part shape=%d not supported", part->shape); 85 85 return false; 86 86 } … … 102 102 break; 103 103 } 104 Hprintf("GeometryUtils", "isPointStrictlyInsidePart", HMLV_ERROR, "Part shape=%d not supported", part->shape);104 logPrintf("GeometryUtils", "isPointStrictlyInsidePart", LOG_ERROR, "Part shape=%d not supported", part->shape); 105 105 return false; 106 106 } -
cpp/frams/model/geometry/meshbuilder.cpp
r372 r375 639 639 640 640 default: 641 Hprintf("MeshBuilder::PartSurface", "initialize", HMLV_WARN, "Part shape=%d not supported, skipping...", part->shape);641 logPrintf("MeshBuilder::PartSurface", "initialize", LOG_WARN, "Part shape=%d not supported, skipping...", part->shape); 642 642 } 643 643 } … … 725 725 726 726 default: 727 Hprintf("MeshBuilder::PartApices", "initialize", HMLV_WARN, "Part shape=%d not supported, skipping...", part->shape);727 logPrintf("MeshBuilder::PartApices", "initialize", LOG_WARN, "Part shape=%d not supported, skipping...", part->shape); 728 728 } 729 729 } -
cpp/frams/model/geometry/modelgeometryinfo.cpp
r372 r375 16 16 if (points.size() < 1) //maybe 1 or 2 points are also not enough for findSizesAndAxesOfPointsGroup() to work... 17 17 { 18 Hprintf("ModelGeometryInfo", "findSizesAndAxesOfModel", HMLV_ERROR, "Empty points sample for model with %d part(s)", model.getPartCount());18 logPrintf("ModelGeometryInfo", "findSizesAndAxesOfModel", LOG_ERROR, "Empty points sample for model with %d part(s)", model.getPartCount()); 19 19 sizes = Pt3D_0; 20 20 axes = Orient_1; … … 116 116 return externalAreaOfCylinder(model, partIndex, density); 117 117 } 118 Hprintf("ModelGeometryInfo", "externalAreaOfPart", HMLV_ERROR, "Part shape=%d not supported", part->shape);118 logPrintf("ModelGeometryInfo", "externalAreaOfPart", LOG_ERROR, "Part shape=%d not supported", part->shape); 119 119 return 0; 120 120 } -
cpp/frams/model/model.cpp
r372 r375 5 5 #include <common/nonstd_math.h> 6 6 #include "model.h" 7 #include <common/ hmessage.h>7 #include <common/log.h> 8 8 #include <frams/util/multimap.h> 9 #include <frams/ mhandlers/mhandlers.h>9 #include <frams/loggers/loggers.h> 10 10 11 11 Model::Model() … … 317 317 SString line; 318 318 MultiRange frommap; 319 MessageHandlerToMemory mh(MessageHandlerBase::Enable | MessageHandlerBase::DontBlock);319 LoggerToMemory mh(LoggerBase::Enable | LoggerBase::DontBlock); 320 320 for (;f0txt.getNextToken(pos,line,'\n');lnum++) 321 321 { … … 329 329 { 330 330 buildstatus=invalid; 331 Hprintf("Model","build",HMLV_ERROR,331 logPrintf("Model","build",LOG_ERROR, 332 332 geno.getName().len()?"illegal f0 code at line %d (%s)":"illegal f0 code at line %d", 333 333 lnum,geno.getName().c_str()); … … 513 513 { 514 514 if (buildstatus!=building) 515 Hprintf("Model","close",HMLV_WARN,"unexpected close() - no open()");515 logPrintf("Model","close",LOG_WARN,"unexpected close() - no open()"); 516 516 if (internalcheck(1)>0) 517 517 { … … 609 609 { 610 610 delete j; 611 Hprintf("Model","build",HMLV_ERROR,611 logPrintf("Model","build",LOG_ERROR, 612 612 "invalid part reference for joint #%d",getJointCount()-1); 613 613 return -1; … … 694 694 return 0; 695 695 } 696 Hprintf("Model","build",HMLV_ERROR,696 logPrintf("Model","build",LOG_ERROR, 697 697 "invalid neuron connection #%d <- #%d",c.n1_refno,c.n2_refno); 698 698 return -1; … … 782 782 else 783 783 { 784 Hprintf("Model","internalCheck",HMLV_ERROR,784 logPrintf("Model","internalCheck",LOG_ERROR, 785 785 "illegal N-N connection #%d (reference to #%d) (%s)", 786 786 i,n->conn_refno,(const char*)geno.getName()); … … 853 853 if (var -> field < getMin ## template () . field) \ 854 854 { var->field= getMin ## template () . field; \ 855 Hprintf("Model","internalCheck",HMLV_WARN,# field " too small in " # template "#%d (adjusted)",i);} \855 logPrintf("Model","internalCheck",LOG_WARN,# field " too small in " # template "#%d (adjusted)",i);} \ 856 856 else if (var -> field > getMax ## template () . field) \ 857 857 { var->field= getMax ## template () . field; \ 858 Hprintf("Model","internalCheck",HMLV_WARN,# field " too big in " # template "#%d (adjusted)",i);}858 logPrintf("Model","internalCheck",LOG_WARN,# field " too big in " # template "#%d (adjusted)",i);} 859 859 860 860 #define LINKFLAG 0x8000000 … … 912 912 { 913 913 shape=SHAPE_ILLEGAL; 914 Hprintf("Model","internalCheck",HMLV_WARN,"Inconsistent part shapes (mixed old and new shapes)");914 logPrintf("Model","internalCheck",LOG_WARN,"Inconsistent part shapes (mixed old and new shapes)"); 915 915 } 916 916 } … … 941 941 { 942 942 ret=0; 943 Hprintf("Model","internalCheck",HMLV_ERROR,943 logPrintf("Model","internalCheck",LOG_ERROR, 944 944 "delta joint cycle detected at joint#%d (%s)", 945 945 i,geno.getName().c_str()); … … 978 978 { 979 979 ret=0; 980 Hprintf("Model","internalCheck",HMLV_ERROR,"delta too big in joint #%d (%s)",980 logPrintf("Model","internalCheck",LOG_ERROR,"delta too big in joint #%d (%s)", 981 981 i,geno.getName().c_str()); 982 982 } … … 984 984 { 985 985 ret=0; 986 Hprintf("Model","internalCheck",HMLV_ERROR,"delta too small in joint #%d (%s)",986 logPrintf("Model","internalCheck",LOG_ERROR,"delta too small in joint #%d (%s)", 987 987 i,geno.getName().c_str()); 988 988 } … … 992 992 else 993 993 { 994 Hprintf("Model","internalCheck",HMLV_ERROR,"illegal part references in joint #%d (%s)",994 logPrintf("Model","internalCheck",LOG_ERROR,"illegal part references in joint #%d (%s)", 995 995 i,geno.getName().c_str()); 996 996 ret=0; … … 1001 1001 { 1002 1002 shape=SHAPE_ILLEGAL; 1003 Hprintf("Model","internalCheck",HMLV_WARN,"Inconsistent joint shapes (mixed old and new shapes)");1003 logPrintf("Model","internalCheck",LOG_WARN,"Inconsistent joint shapes (mixed old and new shapes)"); 1004 1004 } 1005 1005 } … … 1071 1071 if (!(p->flags&LINKFLAG)) 1072 1072 { 1073 Hprintf("Model","internalCheck",HMLV_ERROR,"not all parts connected (eg.#0-#%d) (%s)",1073 logPrintf("Model","internalCheck",LOG_ERROR,"not all parts connected (eg.#0-#%d) (%s)", 1074 1074 i,geno.getName().c_str()); 1075 1075 ret=0; … … 1084 1084 if (j->p1_refno==j->p2_refno) 1085 1085 { 1086 Hprintf("Model","internalCheck",HMLV_ERROR,"illegal self connection, joint #%d (%s)",1086 logPrintf("Model","internalCheck",LOG_ERROR,"illegal self connection, joint #%d (%s)", 1087 1087 i,geno.getName().c_str()); 1088 1088 ret=0; … … 1095 1095 || ((j->p1_refno==j2->p2_refno)&&(j->p2_refno==j2->p1_refno))) 1096 1096 { 1097 Hprintf("Model","internalCheck",HMLV_ERROR,"illegal duplicate joints #%d and #%d (%s)",1097 logPrintf("Model","internalCheck",LOG_ERROR,"illegal duplicate joints #%d and #%d (%s)", 1098 1098 i,k,geno.getName().c_str()); 1099 1099 ret=0; … … 1125 1125 { 1126 1126 if (buildstatus==building) 1127 Hprintf("Model","getGeno",HMLV_WARN,"model was not completed - missing close()");1127 logPrintf("Model","getGeno",LOG_WARN,"model was not completed - missing close()"); 1128 1128 if (buildstatus!=valid) 1129 1129 return Geno("",'0',"","invalid"); -
cpp/frams/neuro/neurofactory.cpp
r372 r375 98 98 } 99 99 if (removed.len()) 100 Hprintf("NeuroFactory","removeUninmplemented",HMLV_INFO,100 logPrintf("NeuroFactory","removeUninmplemented",LOG_INFO, 101 101 "Removed Neuro classes: %s",removed.c_str()); 102 102 } -
cpp/frams/neuro/neuroimpl.cpp
r372 r375 72 72 n->userdata[mytags_id]=ni; 73 73 if (!ni) { errorcount++; 74 Hprintf("NeuroNetImpl","create",HMLV_WARN,"neuron #%d (%s) implementation not available",74 logPrintf("NeuroNetImpl","create",LOG_WARN,"neuron #%d (%s) implementation not available", 75 75 i,n->getClassName().c_str()); 76 76 continue; } // implementation not available?! … … 87 87 if (!ni->lateinit()) 88 88 { ni->status=NeuroImpl::InitError; errorcount++; 89 Hprintf("NeuroNetImpl","create",HMLV_WARN,"neuron #%d (%s) initialization failed",89 logPrintf("NeuroNetImpl","create",LOG_WARN,"neuron #%d (%s) initialization failed", 90 90 i,n->getClassName().c_str()); 91 91 continue; } -
cpp/frams/neuro/neuroimpl.h
r372 r375 8 8 #include <frams/model/model.h> 9 9 #include <frams/param/param.h> 10 #include <common/ hmessage.h>10 #include <common/log.h> 11 11 #ifdef NEURO_SIGNALS 12 12 #include <frams/simul/signals.h> -
cpp/frams/param/multiparamload.cpp
r372 r375 5 5 #include "multiparamload.h" 6 6 #include <frams/util/sstringutils.h> 7 #include "common/ hmessage.h"7 #include "common/log.h" 8 8 #include <ctype.h> 9 9 … … 107 107 else if (status==BeforeUnknown) 108 108 { 109 Hprintf("MultiParamLoader","go",HMLV_WARN,"Skipping object '%s'",lastunknown.c_str());109 logPrintf("MultiParamLoader","go",LOG_WARN,"Skipping object '%s'",lastunknown.c_str()); 110 110 loadObjectNow(&emptyparam,false); 111 111 continue; … … 137 137 { 138 138 const char* thisfilename=file->VgetPath(); 139 Hprintf("MultiParamLoader","go",HMLV_WARN,"invalid \"%s\"%s%s",buf.c_str(),139 logPrintf("MultiParamLoader","go",LOG_WARN,"invalid \"%s\"%s%s",buf.c_str(), 140 140 (thisfilename?" in ":""),(thisfilename?thisfilename:"")); 141 141 } … … 204 204 if (alreadyIncluded(newfilename.c_str())) 205 205 { 206 Hprintf("MultiParamLoader","include",HMLV_WARN,"circular reference ignored (\"%s\")",206 logPrintf("MultiParamLoader","include",LOG_WARN,"circular reference ignored (\"%s\")", 207 207 filename.c_str()); 208 208 return; … … 212 212 if (!f) 213 213 { 214 Hprintf("MultiParamLoader","include",HMLV_WARN,"\"%s\" not found",newfilename.c_str());214 logPrintf("MultiParamLoader","include",LOG_WARN,"\"%s\" not found",newfilename.c_str()); 215 215 } 216 216 else -
cpp/frams/param/param.cpp
r372 r375 8 8 #include "param.h" 9 9 #include <frams/util/extvalue.h> 10 #include "common/ hmessage.h"10 #include "common/log.h" 11 11 #include <frams/util/sstringutils.h> 12 12 … … 445 445 { 446 446 SString name(p0, p_len); 447 Hprintf("ParamInterface", "load", HMLV_WARN, "Ignored unknown property '%s' while reading object '%s'", name.c_str(), getName());447 logPrintf("ParamInterface", "load", LOG_WARN, "Ignored unknown property '%s' while reading object '%s'", name.c_str(), getName()); 448 448 } 449 449 … … 518 518 case 'o': ret.setObject(getObject(i)); break; 519 519 case 'x': ret = getExtValue(i); break; 520 default: Hprintf("ParamInterface", "get", HMLV_ERROR, "'%s.%s' is not a field", getName(), id(i));520 default: logPrintf("ParamInterface", "get", LOG_ERROR, "'%s.%s' is not a field", getName(), id(i)); 521 521 } 522 522 } … … 562 562 if (v.type == TObj) 563 563 { 564 Hprintf("ParamInterface", "set", HMLV_WARN, "Getting integer value from object reference (%s)", v.getString().c_str());564 logPrintf("ParamInterface", "set", LOG_WARN, "Getting integer value from object reference (%s)", v.getString().c_str()); 565 565 return 0; 566 566 } … … 574 574 if (v.type == TObj) 575 575 { 576 Hprintf("ParamInterface", "set", HMLV_WARN, "Getting floating point value from object reference (%s)", v.getString().c_str());576 logPrintf("ParamInterface", "set", LOG_WARN, "Getting floating point value from object reference (%s)", v.getString().c_str()); 577 577 return 0; 578 578 } … … 583 583 case 'o': return setObject(i, v.getObject()); 584 584 case 'x': return setExtValue(i, v); 585 default: Hprintf("ParamInterface", "set", HMLV_ERROR, "'%s.%s' is not a field", getName(), id(i));585 default: logPrintf("ParamInterface", "set", LOG_ERROR, "'%s.%s' is not a field", getName(), id(i)); 586 586 } 587 587 return 0; … … 605 605 if ((after == NULL) || (*after)) 606 606 { 607 Hprintf("ParamInterface", "set", HMLV_WARN, "serialization format mismatch in %s.%s", (getName() ? getName() : "<Unknown>"), id(i));607 logPrintf("ParamInterface", "set", LOG_WARN, "serialization format mismatch in %s.%s", (getName() ? getName() : "<Unknown>"), id(i)); 608 608 e.setEmpty(); 609 609 } … … 690 690 } 691 691 if (err!=NULL) 692 Hprintf("SimpleAbstractParam","sanityCheck", HMLV_ERROR,692 logPrintf("SimpleAbstractParam","sanityCheck", LOG_ERROR, 693 693 "Invalid ParamEntry for %s.%s (%s)", getName(), pe->id, err); 694 694 } … … 961 961 else 962 962 { 963 Hprintf("SimpleAbstractParam", "call", HMLV_ERROR,963 logPrintf("SimpleAbstractParam", "call", LOG_ERROR, 964 964 (*pe->type != 'p') ? "'%s.%s' is not a function" : "Internal error - undefined function pointer for '%s.%s'", getName(), pe->id); 965 965 ret->setInvalid(); … … 1060 1060 { 1061 1061 SString name(t, (int)(equals_sign - t)); 1062 Hprintf("Param", "load2", HMLV_WARN, "Unknown property '%s' while reading object '%s' (ignored)", name.c_str(), getName());1062 logPrintf("Param", "load2", LOG_WARN, "Unknown property '%s' while reading object '%s' (ignored)", name.c_str(), getName()); 1063 1063 } 1064 1064 t = equals_sign + 1; // t=value … … 1070 1070 #endif 1071 1071 { 1072 Hprintf("Param", "load2", HMLV_WARN, "Missing property name in '%s' (assuming '%s')",1072 logPrintf("Param", "load2", LOG_WARN, "Missing property name in '%s' (assuming '%s')", 1073 1073 getName(), id(i) ? id(i) : "unknown property?"); 1074 1074 } … … 1092 1092 fields_loaded++; 1093 1093 if (ret&(PSET_HITMAX | PSET_HITMIN)) 1094 Hprintf("Param", "load2", HMLV_WARN, "Adjusted '%s' in '%s' (was too %s)",1094 logPrintf("Param", "load2", LOG_WARN, "Adjusted '%s' in '%s' (was too %s)", 1095 1095 id(i), getName(), (ret&PSET_HITMAX) ? "big" : "small"); 1096 1096 *(char*)valstop = remember; -
cpp/frams/param/param.h
r372 r375 12 12 #include <frams/util/statrick.h> 13 13 #include <frams/virtfile/virtfile.h> 14 #include <common/ hmessage.h>14 #include <common/log.h> 15 15 16 16 class ExtValue; … … 273 273 SString svaluetoset = SString::valueOf(valuetoset); //converts any type to SString 274 274 SString actual = get(i); 275 Hprintf("Param", "set", HMLV_WARN, "Setting '%s.%s = %s' exceeded allowed range (too %s). Adjusted to %s.",275 logPrintf("Param", "set", LOG_WARN, "Setting '%s.%s = %s' exceeded allowed range (too %s). Adjusted to %s.", 276 276 getName(), id(i), svaluetoset.c_str(), (setflags&PSET_HITMAX) ? "big" : "small", actual.c_str()); 277 277 } -
cpp/frams/util/3d.cpp
r372 r375 4 4 5 5 #include <common/nonstd_math.h> 6 #include <common/ hmessage.h>6 #include <common/log.h> 7 7 #include "3d.h" 8 8 … … 17 17 { 18 18 double q = x*x + y*y + z*z; 19 if (q < 0) { if (report_errors) Hprintf("Pt3D", "operator()", HMLV_ERROR, "sqrt(%g): domain error", q); return 0; }19 if (q < 0) { if (report_errors) logPrintf("Pt3D", "operator()", LOG_ERROR, "sqrt(%g): domain error", q); return 0; } 20 20 return sqrt(q); 21 21 } … … 24 24 { 25 25 double len = length(); 26 if (fabs(len) < 1e-50) { if (report_errors) Hprintf("Pt3D", "normalize()", HMLV_WARN, "vector[%g,%g,%g] too small", x, y, z); x = 1; y = 0; z = 0; return false; }26 if (fabs(len) < 1e-50) { if (report_errors) logPrintf("Pt3D", "normalize()", LOG_WARN, "vector[%g,%g,%g] too small", x, y, z); x = 1; y = 0; z = 0; return false; } 27 27 operator/=(len); 28 28 return true; … … 64 64 if (dx == 0 && dy == 0) 65 65 { 66 if (report_errors) Hprintf("Pt3D", "getAngle()", HMLV_WARN, "atan2(%g,%g)", dy, dx);66 if (report_errors) logPrintf("Pt3D", "getAngle()", LOG_WARN, "atan2(%g,%g)", dy, dx); 67 67 return 0; // incorrect result, but there is no correct one 68 68 } … … 147 147 { 148 148 double q = x*x + y*y; 149 if (q < 0) { if (Pt3D::report_errors) Hprintf("", "d2()", HMLV_ERROR, "sqrt(%g): domain error", q); return 0; }149 if (q < 0) { if (Pt3D::report_errors) logPrintf("", "d2()", LOG_ERROR, "sqrt(%g): domain error", q); return 0; } 150 150 return sqrt(q); 151 151 } -
cpp/frams/util/extvalue.cpp
r372 r375 98 98 if (warn) 99 99 { 100 Hprintf("ExtValue", "getObjectTarget", HMLV_WARN, "%s object expected, %s found", classname, interfaceName());100 logPrintf("ExtValue", "getObjectTarget", LOG_WARN, "%s object expected, %s found", classname, interfaceName()); 101 101 } 102 102 … … 269 269 if (tmp.len() > 30) tmp = tmp.substr(0, 30) + "..."; 270 270 if (type == TString) tmp = SString("\"") + tmp + SString("\""); 271 Hprintf("ExtValue", "getObjectTarget", HMLV_WARN, "%s object expected, %s found", classname, tmp.c_str());271 logPrintf("ExtValue", "getObjectTarget", LOG_WARN, "%s object expected, %s found", classname, tmp.c_str()); 272 272 } 273 273 return NULL; … … 419 419 context->v2->typeAndValue().c_str()); 420 420 } 421 Hprintf("ExtValue", "interpretCompare", HMLV_ERROR, "%s", msg.c_str());421 logPrintf("ExtValue", "interpretCompare", LOG_ERROR, "%s", msg.c_str()); 422 422 ret = -1; 423 423 } … … 448 448 { 449 449 case TDouble: 450 Hprintf("ExtValue", "add", HMLV_WARN, "Adding %s to %s", src.typeAndValue().c_str(), typeAndValue().c_str());450 logPrintf("ExtValue", "add", LOG_WARN, "Adding %s to %s", src.typeAndValue().c_str(), typeAndValue().c_str()); 451 451 setDouble(double(getInt()) + src.getDouble()); 452 452 return; … … 487 487 default:; 488 488 } 489 Hprintf("ExtValue", "add", HMLV_ERROR, "Can't add %s to %s", src.typeAndValue().c_str(), typeAndValue().c_str());489 logPrintf("ExtValue", "add", LOG_ERROR, "Can't add %s to %s", src.typeAndValue().c_str(), typeAndValue().c_str()); 490 490 } 491 491 … … 502 502 return; 503 503 case TDouble: 504 Hprintf("ExtValue", "subtract", HMLV_WARN, "Subtracting %s from %s", src.typeAndValue().c_str(), typeAndValue().c_str());504 logPrintf("ExtValue", "subtract", LOG_WARN, "Subtracting %s from %s", src.typeAndValue().c_str(), typeAndValue().c_str()); 505 505 setDouble(double(getInt()) - src.getDouble()); 506 506 return; … … 520 520 default:; 521 521 } 522 Hprintf("ExtValue", "subtract", HMLV_ERROR, "Can't subtract %s from %s", src.typeAndValue().c_str(), typeAndValue().c_str());522 logPrintf("ExtValue", "subtract", LOG_ERROR, "Can't subtract %s from %s", src.typeAndValue().c_str(), typeAndValue().c_str()); 523 523 } 524 524 … … 535 535 return; 536 536 case TDouble: 537 Hprintf("ExtValue", "multiply", HMLV_WARN, "Multiplying %s by %s", typeAndValue().c_str(), src.typeAndValue().c_str());537 logPrintf("ExtValue", "multiply", LOG_WARN, "Multiplying %s by %s", typeAndValue().c_str(), src.typeAndValue().c_str()); 538 538 setDouble(double(getInt())*src.getDouble()); 539 539 return; … … 591 591 default:; 592 592 } 593 Hprintf("ExtValue", "multiply", HMLV_WARN, "Can't multiply %s by %s", typeAndValue().c_str(), src.typeAndValue().c_str());593 logPrintf("ExtValue", "multiply", LOG_WARN, "Can't multiply %s by %s", typeAndValue().c_str(), src.typeAndValue().c_str()); 594 594 } 595 595 … … 611 611 else 612 612 { 613 Hprintf("ExtValue", "divide", HMLV_CRITICAL, "Division by zero: %d/0", idata());613 logPrintf("ExtValue", "divide", LOG_CRITICAL, "Division by zero: %d/0", idata()); 614 614 setInvalid(); 615 615 } … … 620 620 if (a == 0.0) 621 621 { 622 Hprintf("ExtValue", "divide", HMLV_CRITICAL, "Division by zero: %s/0.0", getString().c_str());622 logPrintf("ExtValue", "divide", LOG_CRITICAL, "Division by zero: %s/0.0", getString().c_str()); 623 623 setInvalid(); 624 624 } … … 629 629 if (!finite(tmp)) 630 630 { 631 Hprintf("ExtValue", "divide", HMLV_CRITICAL, "Overflow %s/%g", getString().c_str(), a); setInvalid();631 logPrintf("ExtValue", "divide", LOG_CRITICAL, "Overflow %s/%g", getString().c_str(), a); setInvalid(); 632 632 } 633 633 else … … 635 635 // niby dobrze ale lepiej byloby to robic bardziej systematycznie a nie tylko w dzieleniu? 636 636 //if (isnan(ddata())) //http://www.digitalmars.com/d/archives/c++/Traping_divide_by_zero_5728.html 637 // { Hprintf("ExtValue","divide",HMLV_ERROR,"not-a-number",(const char*)getString()); setInvalid(); }637 // { logPrintf("ExtValue","divide",LOG_ERROR,"not-a-number",(const char*)getString()); setInvalid(); } 638 638 fpExceptEnable(); 639 639 } … … 651 651 return; 652 652 case TDouble: 653 Hprintf("ExtValue", "divide", HMLV_WARN, "Dividing %s by %s", typeAndValue().c_str(), src.typeAndValue().c_str());653 logPrintf("ExtValue", "divide", LOG_WARN, "Dividing %s by %s", typeAndValue().c_str(), src.typeAndValue().c_str()); 654 654 divDouble(src.ddata()); 655 655 return; … … 673 673 default:; 674 674 } 675 Hprintf("ExtValue", "divide", HMLV_ERROR, "Can't divide %s by %s", typeAndValue().c_str(), src.typeAndValue().c_str());675 logPrintf("ExtValue", "divide", LOG_ERROR, "Can't divide %s by %s", typeAndValue().c_str(), src.typeAndValue().c_str()); 676 676 } 677 677 … … 778 778 779 779 case TObj: case TUnknown: case TInvalid: 780 Hprintf("ExtValue", "modulo", HMLV_WARN, "Can't apply modulo to %s", typeDescription().c_str());780 logPrintf("ExtValue", "modulo", LOG_WARN, "Can't apply modulo to %s", typeDescription().c_str()); 781 781 782 782 default:; … … 791 791 { 792 792 if (error) 793 Hprintf("ExtValue", "parseInt", HMLV_ERROR, "Could not parse '%s'%s", s, strict ? " (strict)" : "");793 logPrintf("ExtValue", "parseInt", LOG_ERROR, "Could not parse '%s'%s", s, strict ? " (strict)" : ""); 794 794 return false; 795 795 } … … 805 805 { 806 806 if (error) 807 Hprintf("ExtValue", "parseDouble", HMLV_ERROR, "Could not parse '%s'", s);807 logPrintf("ExtValue", "parseDouble", LOG_ERROR, "Could not parse '%s'", s); 808 808 return false; 809 809 } … … 836 836 case TString: return getInt(sdata().c_str()); 837 837 case TObj: 838 Hprintf("ExtValue", "getInt", HMLV_WARN, "Getting integer value from object reference (%s)", getString().c_str());838 logPrintf("ExtValue", "getInt", LOG_WARN, "Getting integer value from object reference (%s)", getString().c_str()); 839 839 return (paInt)(intptr_t)odata().param; 840 840 default:; … … 851 851 case TString: return getDouble(sdata().c_str()); 852 852 case TObj: 853 Hprintf("ExtValue", "getDouble", HMLV_WARN, "Getting floating point value from object reference (%s)", getString().c_str());853 logPrintf("ExtValue", "getDouble", LOG_WARN, "Getting floating point value from object reference (%s)", getString().c_str()); 854 854 return (double)(intptr_t)odata().param; 855 855 default:; … … 989 989 else 990 990 { 991 Hprintf("ExtValue", "deserialize", HMLV_ERROR, "Missing '\"' in string: '%s'", ret);991 logPrintf("ExtValue", "deserialize", LOG_ERROR, "Missing '\"' in string: '%s'", ret); 992 992 return NULL; 993 993 } … … 1011 1011 else if (*p != ']') 1012 1012 { 1013 Hprintf("ExtValue", "deserialize", HMLV_ERROR, "Missing ',' in Vector: '%s'", p);1013 logPrintf("ExtValue", "deserialize", LOG_ERROR, "Missing ',' in Vector: '%s'", p); 1014 1014 return NULL; 1015 1015 } … … 1037 1037 if ((!ret) || (args[1].getType() != TString)) { p = NULL; break; } 1038 1038 p = ret; 1039 if (*p != ':') { Hprintf("ExtValue", "deserialize", HMLV_ERROR, "Missing ':' in Dictionary: '%s'", p); p = NULL; break; }1039 if (*p != ':') { logPrintf("ExtValue", "deserialize", LOG_ERROR, "Missing ':' in Dictionary: '%s'", p); p = NULL; break; } 1040 1040 p++; 1041 1041 ret = args[0].deserialize(p); … … 1046 1046 else if (*p != '}') 1047 1047 { 1048 Hprintf("ExtValue", "deserialize", HMLV_ERROR, "Missing ',' in Dictionary: '%s'", p);1048 logPrintf("ExtValue", "deserialize", LOG_ERROR, "Missing ',' in Dictionary: '%s'", p); 1049 1049 return NULL; 1050 1050 } … … 1086 1086 } 1087 1087 } 1088 Hprintf("ExtValue", "deserialize", HMLV_ERROR, "Invalid reference: '%s'", in - 1);1088 logPrintf("ExtValue", "deserialize", LOG_ERROR, "Invalid reference: '%s'", in - 1); 1089 1089 return NULL; 1090 1090 } … … 1133 1133 } 1134 1134 setEmpty(); 1135 Hprintf("ExtValue", "deserialize", HMLV_WARN, "object of class \"%s\" could not be deserialized", clsname.c_str());1135 logPrintf("ExtValue", "deserialize", LOG_WARN, "object of class \"%s\" could not be deserialized", clsname.c_str()); 1136 1136 return ret; 1137 1137 } 1138 Hprintf("ExtValue", "deserialize", HMLV_ERROR, "Bad syntax: '%s'", in);1138 logPrintf("ExtValue", "deserialize", LOG_ERROR, "Bad syntax: '%s'", in); 1139 1139 setEmpty(); 1140 1140 return NULL; -
cpp/frams/util/sstringutils.cpp
r372 r375 5 5 #include "sstringutils.h" 6 6 #include <frams/virtfile/virtfile.h> 7 #include <common/ hmessage.h>7 #include <common/log.h> 8 8 #include <common/nonstd.h> 9 9 … … 19 19 } 20 20 else if (framsgmodule) 21 Hprintf(framsgmodule, "loadSString", HMLV_WARN, error ? error : "can't open file \"%s\"", filename);21 logPrintf(framsgmodule, "loadSString", LOG_WARN, error ? error : "can't open file \"%s\"", filename); 22 22 return ret; 23 23 } -
cpp/frams/util/validitychecks.cpp
r374 r375 3 3 // See LICENSE.txt for details. 4 4 5 #include " stderrors.h"5 #include "validitychecks.h" 6 6 #include <frams/util/sstringutils.h> 7 #include <common/ hmessage.h>7 #include <common/log.h> 8 8 9 9 bool listIndexCheck(SList* list,int index,const char* msgobj,const char* msgfun) … … 13 13 { 14 14 if (size>0) 15 Hprintf(msgobj,msgfun,HMLV_ERROR,"Invalid index %d (allowed range is 0..%d)",index,size-1);15 logPrintf(msgobj,msgfun,LOG_ERROR,"Invalid index %d (allowed range is 0..%d)",index,size-1); 16 16 else 17 Hprintf(msgobj,msgfun,HMLV_ERROR,"Invalid index %d (this list is empty)",index);17 logPrintf(msgobj,msgfun,LOG_ERROR,"Invalid index %d (this list is empty)",index); 18 18 return 0; 19 19 } … … 29 29 { 30 30 SString msg2=SString(msg)+": \"%s\" (adjusted to \"%s\")"; 31 Hprintf(msgobj,msgfun,HMLV_WARN,msg2.c_str(),in.c_str(),corrected.c_str());31 logPrintf(msgobj,msgfun,LOG_WARN,msg2.c_str(),in.c_str(),corrected.c_str()); 32 32 } 33 33 return corrected; -
cpp/frams/util/validitychecks.h
r372 r375 3 3 // See LICENSE.txt for details. 4 4 5 #ifndef _ STDERRORS_H_6 #define _ STDERRORS_H_5 #ifndef _VALIDITY_CHECKS_H_ 6 #define _VALIDITY_CHECKS_H_ 7 7 8 8 #include <frams/util/list.h> … … 10 10 11 11 bool listIndexCheck(SList* list,int index,const char* msgobj,const char* msgfun); 12 SString stringCheck(SString& in,const char* msgobj,const char* msgfun,const char* msg,SString (*checker)(SString& in)= 0);12 SString stringCheck(SString& in,const char* msgobj,const char* msgfun,const char* msg,SString (*checker)(SString& in)=NULL); 13 13 14 14 #endif -
cpp/frams/virtfile/stdiofile.cpp
r374 r375 6 6 #include <common/nonstd_dir.h> 7 7 #include <common/nonstd_stdio.h> 8 #include <common/ hmessage.h>8 #include <common/log.h> 9 9 #include <common/Convert.h> 10 10 11 11 VirtFILE* StdioFileSystem::Vfopen(const char *path, const char *mode) 12 12 { 13 // printH("Vfopen %s %s",path,mode);13 //log_printf("Vfopen %s %s",path,mode); 14 14 #if defined USE_MFILE || defined _WIN32 15 15 MFILE *f = mfopen(path, mode); … … 17 17 FILE *f = fopen(path, mode); 18 18 #endif 19 // printH("%p",f);19 //log_printf("%p",f); 20 20 if (f) return new StdioFILE(f, path); else return NULL; 21 21 } … … 23 23 VirtDIR* StdioFileSystem::Vopendir(const char* path) 24 24 { 25 // printH("Vopendir %s",path);25 //log_printf("Vopendir %s",path); 26 26 #ifdef _WIN32 27 27 DIRTYPE *d = wopendir(Convert::utf8ToUtf16(path).c_str()); … … 29 29 DIR *d = opendir(path); 30 30 #endif 31 // printH("%p",d);31 //log_printf("%p",d); 32 32 if (d) return new StdioDIR(d); else return NULL; 33 33 } … … 52 52 dirent* StdioDIR::Vreaddir() 53 53 { 54 // printH("Vreaddir %s",dir);54 //log_printf("Vreaddir %s",dir); 55 55 #ifdef _WIN32 56 56 wdirent *wde=wreaddir(dir); -
cpp/frams/vm/classes/collectionobj.cpp
r372 r375 5 5 #include "collectionobj.h" 6 6 #include <common/nonstd_math.h> //sqrt in borland 7 #include <frams/ mhandlers/stderrors.h>7 #include <frams/util/validitychecks.h> 8 8 #include <common/nonstd_stl.h> 9 9 #include <frams/util/sstringutils.h> … … 232 232 { 233 233 ret=false; 234 Hprintf("VectorElementComparator","",HMLV_ERROR,"Comparison function returned no value");234 logPrintf("VectorElementComparator","",LOG_ERROR,"Comparison function returned no value"); 235 235 } 236 236 else -
cpp/frams/vm/framscript.y
r348 r375 5 5 %{ 6 6 #include "framscript-defs.h" 7 #include "common/ framsg.h"7 #include "common/log.h" 8 8 #include <math.h> 9 9 #include <ctype.h> … … 145 145 { 146 146 #ifdef FRAMSCRIPT_GOTO 147 trctx.out->printf("jump :%s\n",str($2)); FMprintf("FramScriptCompiler","translate",FMLV_WARN,"goto is not recommended"); trctx.emitLine();147 trctx.out->printf("jump :%s\n",str($2)); logPrintf("FramScriptCompiler","translate",LOG_WARN,"goto is not recommended"); trctx.emitLine(); 148 148 #else 149 149 trctx.err->printf("goto is not supported\n");return 1; … … 1515 1515 { 1516 1516 if (t.assign && (!t.parens)) 1517 FMprintf("FramScriptCompiler","translate",FMLV_WARN,"Assignment used as truth value, use ((double parens)) if you really mean it");1517 logPrintf("FramScriptCompiler","translate",LOG_WARN,"Assignment used as truth value, use ((double parens)) if you really mean it"); 1518 1518 } 1519 1519
Note: See TracChangeset
for help on using the changeset viewer.