Changeset 375


Ignore:
Timestamp:
04/26/15 00:59:09 (9 years ago)
Author:
Maciej Komosinski
Message:

Renamed logging functions to more intuitive and simple names

Location:
cpp
Files:
6 deleted
39 edited
6 copied
3 moved

Legend:

Unmodified
Added
Removed
  • cpp/common/log.cpp

    r372 r375  
    33// See LICENSE.txt for details.
    44
    5 #include "hmessage.h"
     5#include "log.h"
    66#include <common/nonstd_stdio.h>
    77#include "stl-util.h"
    88#include "Convert.h"
    99
    10 const char* HMSG_LEVEL[]={"[DEBUG] ","","[WARN] ","[ERROR] ","[CRITICAL] "};
     10const char* LOG_LEVEL[] = { "[DEBUG] ", "", "[WARN] ", "[ERROR] ", "[CRITICAL] " };
    1111
    12 void Hmessage(const char *o, const char *m, const char *txt, int w)
     12void logMessage(const char *obj, const char *method, int level, const char *msg)
    1313{
    1414        int line = 0; //all lines except the first one get the "..." prefix
     
    1616        do
    1717        {
    18                 nextsep = strchr(txt, '\n');
     18                nextsep = strchr(msg, '\n');
    1919                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'))
    2222                        nextsep--;
    2323                if (line == 0)
    2424                {
    2525                        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);
    2727                        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());
    2929                }
    3030                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 simple
     31                        _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
    3232                line++;
    3333                if ((nextsep[0] == '\r') && (nextsep[1] == '\n'))
    34                         txt = nextsep + 2;
     34                        msg = nextsep + 2;
    3535                else if (*nextsep)
    36                         txt = nextsep + 1;
     36                        msg = nextsep + 1;
    3737        } while (*nextsep);
    3838}
    3939
    4040
    41 void Hprintf_va(const char *o,const char *m,int w,const char *bl,va_list va)
     41void logPrintf_va(const char *obj, const char *method, int level, const char *msgf, va_list va)
    4242{
    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());
    4545}
    4646
    47 void Hprintf(const char *o,const char *m,int w,const char *bl, ...)
     47void logPrintf(const char *obj, const char *method, int level, const char *msgf, ...)
    4848{
    4949        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);
    5252        va_end(argptr);
    5353}
    5454
    55 void printH(const char *bl,...)
     55void log_printf(const char *msgf, ...)
    5656{
    5757        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);
    6060        va_end(argptr);
    6161}
  • cpp/common/log.h

    r372 r375  
    33// See LICENSE.txt for details.
    44
    5 #ifndef _HMESSAGE_H_
    6 #define _HMESSAGE_H_
     5#ifndef _COMMON_LOG_H_
     6#define _COMMON_LOG_H_
    77
    88#include <stdarg.h>
    99
    10 extern const char* HMSG_LEVEL[];
    11 #define HMSG_FORMAT "%s%s.%s: %s"
    12 #define HMSG_MULTILINE_CONTINUATION "..."
     10extern const char* LOG_LEVEL[];
     11#define LOG_FORMAT "%s%s.%s: %s"
     12#define LOG_MULTILINE_CONTINUATION "..."
    1313
    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 function
    16 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);
    1814
    19 void _HmessageSingleLine(const char *o,const char *m,const char *txt,int w); //don't call this directly - it is used internally
     15void logPrintf(const char *obj, const char *method, int level, const char *msgf, ...);
     16void 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
     17void 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)
     18void logMessage(const char *obj, const char *method, int level, const char *msg);
    2019
    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
     20void _logMessageSingleLine(const char *obj, const char *method, int level, const char *msg); //don't call this directly - it is used internally
    2621
    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 application
    34 */
     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
    3530
    3631#endif
  • cpp/common/nonstd_math.cpp

    r372 r375  
    8181// 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)
    8282
    83 #include "hmessage.h"
     83#include "log.h"
    8484
    8585unsigned int fp_control_word_std;
     
    8989{
    9090        //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);
    9292        fp_control_word_std=_control87(0, 0);             //4978 = 1001101110010
    9393        // Make the new fp env same as the old one, except for the changes we're going to make
     
    9898{
    9999        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);
    101101        _control87(fp_control_word_std, 0xffffffff);
    102         //Hprintf("","fpExceptEnable ",HMLV_INFO,"control87 flags are %08x", _control87(0, 0)); //kontrola co sie ustawilo
     102        //logPrintf("","fpExceptEnable ",LOG_INFO,"control87 flags are %08x", _control87(0, 0)); //kontrola co sie ustawilo
    103103}
    104104
     
    106106{
    107107        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);
    109109        _control87(fp_control_word_muted, 0xffffffff);
    110         //Hprintf("","fpExceptDisable",HMLV_INFO,"control87 flags are %08x", _control87(0, 0)); //kontrola co sie ustawilo
     110        //logPrintf("","fpExceptDisable",LOG_INFO,"control87 flags are %08x", _control87(0, 0)); //kontrola co sie ustawilo
    111111}
    112112
  • cpp/common/nonstd_stdio.cpp

    r374 r375  
    242242
    243243#ifdef __ANDROID__
    244 #include "hmessage.h"
     244#include "log.h"
    245245#include "nonstd.h"
    246246#include "nonstd_stl.h"
     
    248248{
    249249        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());
    252252        NvFile *rfile=NULL; //can only read
    253253        FILE *rwfile=NULL;
     
    256256                path+=respath.length(); //strip the prefix, we need a relative path in assets
    257257                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);
    259259                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);
    261261                if (rfile==NULL) return NULL;
    262262        } else //a "normal" access (HOME)
    263263        {
    264264                rwfile=fopen(path,mode);
    265                 //printH("Opened HOME file as %p",rwfile);
     265                //log_printf("Opened HOME file as %p",rwfile);
    266266                if (rwfile==NULL) return NULL;
    267267        }
  • cpp/common/stl-util.cpp

    r374 r375  
    99#include "Convert.h"
    1010#include "nonstd.h"
    11 #include "hmessage.h"
     11#include "log.h"
    1212#include <assert.h>
    1313#ifdef USE_VIRTFILE
     
    103103        }
    104104        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);
    106106        return ok;
    107107}
     
    129129        }
    130130        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);
    132132        return ok;
    133133}
  • cpp/frams/Makefile-SDK-files

    r372 r375  
    22
    33# 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}
     4ALL_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}
    55
    66GENMANF4=frams/genetics/f4/oper_f4.o
     
    1919GENMAN_COMMON_OBJS=frams/genetics/genman.o frams/param/mutableparam.o frams/param/mutparamlist.o frams/neuro/geneticneuroparam.o frams/neuro/neurolibparam.o
    2020
    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.o
     21SDK_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
    2222
    2323GEOMETRY_OBJS=frams/model/geometry/meshbuilder.o frams/model/geometry/modelgeometryinfo.o frams/model/geometry/geometryutils.o
     
    2525#### sdk_tests
    2626
    27 GENOMANIPULATION_OBJS= frams/_demos/genomanipulation.o frams/mhandlers/stdouthandler.o frams/virtfile/virtfile.o  $(SDK_OBJS) $(GENOCONV_SDK_OBJS) $(GENMAN_SDK_OBJS)
     27GENOMANIPULATION_OBJS= frams/_demos/genomanipulation.o frams/loggers/loggertostdout.o frams/virtfile/virtfile.o  $(SDK_OBJS) $(GENOCONV_SDK_OBJS) $(GENMAN_SDK_OBJS)
    2828
    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)
     29MULTILINE_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)
    3030
    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)
     31F0_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)
    3232
    3333LOADER_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)
    3434
    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)
     35LOADER_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)
    3636
    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)
     37GENOCONV_TEST_OBJS= frams/_demos/genoconv_test.o frams/_demos/printconvmap.o frams/loggers/loggertostdout.o frams/virtfile/virtfile.o  $(SDK_OBJS) $(GENOCONV_SDK_OBJS)
    3838
    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)
     39GENO_TEST_OBJS= frams/_demos/geno_test.o frams/virtfile/virtfile.o frams/loggers/loggertostdout.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS) $(GENMAN_SDK_OBJS)
    4040
    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)
     41GENOOPER_TEST_OBJS=frams/_demos/genooper_test.o frams/virtfile/virtfile.o frams/loggers/loggertostdout.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS) $(GENMAN_SDK_OBJS)
    4242
    4343GENOOPER_TEST_FTEST_OBJS=frams/_demos/genooper_test_fTest.o frams/virtfile/virtfile.o $(SDK_OBJS) $(GENOCONV_SDK_OBJS) $(GENMAN_SDK_OBJS) $(GENMAN_FT)
    4444
    45 NEURO_TEST_OBJS= frams/_demos/neuro_test.o frams/mhandlers/stdouthandler.o frams/virtfile/virtfile.o \
     45NEURO_TEST_OBJS= frams/_demos/neuro_test.o frams/loggers/loggertostdout.o frams/virtfile/virtfile.o \
    4646        frams/neuro/neuroimpl.o frams/neuro/neurofactory.o frams/neuro/impl/neuroimpl-simple.o frams/neuro/impl/neuroimpl-channels.o \
    4747        frams/neuro/impl/neuroimpl-fuzzy.o frams/neuro/impl/neuroimpl-fuzzy-f0.o  $(SDK_OBJS) $(GENOCONV_SDK_OBJS) $(GENMAN_SDK_OBJS)
    4848
    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)
     49FULL_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)
    5050
    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)
     51SHAPECONVERT_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)
    5252
    5353SERIAL_TEST_OBJS= frams/_demos/serial_test.o frams/virtfile/virtfile.o  $(SDK_OBJS) $(GENOCONV_SDK_OBJS)
     
    5555PART_SHAPES_OBJS= frams/_demos/part_shapes.o frams/virtfile/virtfile.o  $(SDK_OBJS) $(GENOCONV_SDK_OBJS)
    5656
    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.o
     57NEURO_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
    5858
    5959GEOMETRY_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)
     
    6666
    6767SIMIL_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)
    6969
    7070SIMIL_UNITTESTS_OBJS=frams/_demos/simil_unittests.o frams/model/similarity/simil_match.o
  • cpp/frams/_demos/f0_variants_test.cpp

    r372 r375  
    1010#include <frams/genetics/defgenoconv.h>
    1111#include <frams/model/model.h>
    12 #include <frams/mhandlers/stdouthandler.h>
     12#include <frams/loggers/loggertostdout.h>
    1313
    1414void save_as_f0(SString &gen,Model &m,bool omit_default_values)
     
    7474int main(int argc,char*argv[])
    7575{
    76 MessageHandlerToStdout messages_to_stdout(MessageHandlerBase::Enable);
     76LoggerToStdout messages_to_stdout(LoggerBase::Enable);
    7777
    7878//without converters the application would only handle "format 0" genotypes
  • cpp/frams/_demos/full_props.cpp

    r372 r375  
    99
    1010#include <frams/model/model.h>
    11 #include <frams/mhandlers/stdouthandler.h>
     11#include <frams/loggers/loggertostdout.h>
    1212#include <frams/genetics/preconfigured.h>
    1313
     
    5050{
    5151StdioFILE::setStdio();//setup VirtFILE::Vstdin/out/err
    52 MessageHandlerToStdout messages_to_stderr(MessageHandlerBase::Enable | MessageHandlerBase::DontBlock,VirtFILE::Vstderr); //errors -> stderr, don't interfere with stdout
     52LoggerToStdout messages_to_stderr(LoggerBase::Enable | LoggerBase::DontBlock,VirtFILE::Vstderr); //errors -> stderr, don't interfere with stdout
    5353
    5454PreconfiguredGenetics genetics;
     
    7979if (!m.isValid())
    8080        {
    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");
    8282        return 2;       
    8383        }
  • cpp/frams/_demos/geno_test.cpp

    r372 r375  
    66#include <frams/util/sstringutils.h>
    77#include <frams/genetics/preconfigured.h>
    8 #include <frams/mhandlers/stdouthandler.h>
     8#include <frams/loggers/loggertostdout.h>
    99
    1010/**
     
    1818{
    1919        PreconfiguredGenetics genetics;
    20         MessageHandlerToStdout messages_to_stdout(MessageHandlerBase::Enable); //comment this object out to mute error/warning messages
     20        LoggerToStdout messages_to_stdout(LoggerBase::Enable); //comment this object out to mute error/warning messages
    2121
    2222        if (argc <= 1)
  • cpp/frams/_demos/genoconv_test.cpp

    r372 r375  
    99
    1010#include "printconvmap.h"
    11 #include <frams/mhandlers/stdouthandler.h>
     11#include <frams/loggers/loggertostdout.h>
    1212
    1313/**
     
    117117int main(int argc,char *argv[])
    118118{
    119 MessageHandlerToStdout messages_to_stdout(MessageHandlerBase::Enable);
     119LoggerToStdout messages_to_stdout(LoggerBase::Enable);
    120120
    121121DefaultGenoConvManager gcm;
  • cpp/frams/_demos/genomanipulation.cpp

    r372 r375  
    1010#include <frams/model/model.h>
    1111#include <frams/genetics/preconfigured.h>
    12 #include <frams/mhandlers/stdouthandler.h>
     12#include <frams/loggers/loggertostdout.h>
    1313
    1414/**
     
    266266int main(int argc,char*argv[])
    267267{
    268 MessageHandlerToStdout messages_to_stdout(MessageHandlerBase::Enable); //redirect model-related errors to stdout
     268LoggerToStdout messages_to_stdout(LoggerBase::Enable); //redirect model-related errors to stdout
    269269
    270270srand(time(0));
  • cpp/frams/_demos/genooper_test.cpp

    r372 r375  
    33// See LICENSE.txt for details.
    44
    5 #include <frams/mhandlers/stdouthandler.h>
     5#include <frams/loggers/loggertostdout.h>
    66#include <frams/genetics/preconfigured.h>
    77
     
    2121int main(int argc, char *argv[])
    2222{
    23         MessageHandlerToStdout messages_to_stdout(MessageHandlerBase::Enable);
     23        LoggerToStdout messages_to_stdout(LoggerBase::Enable);
    2424        PreconfiguredGenetics genetics;
    2525
  • cpp/frams/_demos/loader_test_param.cpp

    r372 r375  
    55#include <frams/param/multiparamload.h>
    66#include <frams/virtfile/stdiofile.h>
    7 #include <frams/mhandlers/stdouthandler.h>
     7#include <frams/loggers/loggertostdout.h>
    88
    99/**
     
    6666        StdioFILEDontClose virt_stderr(stderr);
    6767        StdioFILEDontClose virt_stdout(stdout);
    68         MessageHandlerToStdout messages_to_stderr(MessageHandlerBase::Enable, &virt_stderr);
     68        LoggerToStdout messages_to_stderr(LoggerBase::Enable, &virt_stderr);
    6969        StdioFileSystem_autoselect stdiofilesys;
    7070        MultiParamLoader loader(argv[1]);
  • cpp/frams/_demos/multiline_f0_test.cpp

    r372 r375  
    1010#include <frams/genetics/preconfigured.h>
    1111#include <frams/model/model.h>
    12 #include <frams/mhandlers/stdouthandler.h>
     12#include <frams/loggers/loggertostdout.h>
    1313#include <frams/virtfile/stringfile.h>
    1414
    1515int main(int argc,char*argv[])
    1616{
    17 MessageHandlerToStdout messages_to_stdout(MessageHandlerBase::Enable);
     17LoggerToStdout messages_to_stdout(LoggerBase::Enable);
    1818PreconfiguredGenetics genetics;
    1919
  • cpp/frams/_demos/neuro_layout_test.cpp

    r372 r375  
    77#include <frams/genetics/preconfigured.h>
    88#include <frams/model/model.h>
    9 #include <frams/mhandlers/stdouthandler.h>
     9#include <frams/loggers/loggertostdout.h>
    1010#include <frams/canvas/nn_layout_model.h>
    1111
     
    8383int main(int argc,char*argv[])
    8484{
    85 MessageHandlerToStdout messages_to_stdout(MessageHandlerBase::Enable);
     85LoggerToStdout messages_to_stdout(LoggerBase::Enable);
    8686PreconfiguredGenetics genetics;
    8787
  • cpp/frams/_demos/neuro_test.cpp

    r372 r375  
    99#include <frams/neuro/neuroimpl.h>
    1010#include <frams/neuro/neurofactory.h>
    11 #include <frams/mhandlers/stdouthandler.h>
     11#include <frams/loggers/loggertostdout.h>
    1212
    1313/**
     
    6060int main(int argc,char*argv[])
    6161{
    62 MessageHandlerToStdout messages_to_stdout(MessageHandlerBase::Enable);
     62LoggerToStdout messages_to_stdout(LoggerBase::Enable);
    6363PreconfiguredGenetics genetics;
    6464
  • cpp/frams/_demos/shapeconvert.cpp

    r372 r375  
    99
    1010#include <frams/model/model.h>
    11 #include <frams/mhandlers/stdouthandler.h>
     11#include <frams/loggers/loggertostdout.h>
    1212#include <frams/genetics/preconfigured.h>
    1313
     
    3434{
    3535        StdioFILE::setStdio();//setup VirtFILE::Vstdin/out/err
    36         MessageHandlerToStdout messages_to_stderr(MessageHandlerBase::Enable | MessageHandlerBase::DontBlock, VirtFILE::Vstderr); //errors -> stderr, don't interfere with stdout
     36        LoggerToStdout messages_to_stderr(LoggerBase::Enable | LoggerBase::DontBlock, VirtFILE::Vstderr); //errors -> stderr, don't interfere with stdout
    3737
    3838        PreconfiguredGenetics genetics;
     
    5050                                if ((shape != Part::SHAPE_ELLIPSOID) && (shape != Part::SHAPE_CUBOID) && (shape != Part::SHAPE_CYLINDER))
    5151                                {
    52                                         Hprintf("", "shapeconvert", HMLV_ERROR, "Invalid shape");
     52                                        logPrintf("", "shapeconvert", LOG_ERROR, "Invalid shape");
    5353                                        return 4;
    5454                                }
     
    7171        if (!m.isValid())
    7272        {
    73                 Hprintf("", "shapeconvert", HMLV_ERROR, "Cannot build Model from the supplied genotype");
     73                logPrintf("", "shapeconvert", LOG_ERROR, "Cannot build Model from the supplied genotype");
    7474                return 2;
    7575        }
     
    7777        if (m.getShape() != Model::SHAPE_OLD)
    7878        {
    79                 Hprintf("", "shapeconvert", HMLV_ERROR, "Only old style shapes can be converted");
     79                logPrintf("", "shapeconvert", LOG_ERROR, "Only old style shapes can be converted");
    8080                return 3;
    8181        }
  • cpp/frams/_demos/simil_test.cpp

    r372 r375  
    55
    66#include <vector>
    7 #include "frams/mhandlers/stdouthandler.h"
     7#include "frams/loggers/loggertostdout.h"
    88#include "frams/_demos/genotypeloader.h"
    99#include "frams/genetics/preconfigured.h"
     
    3939int main(int argc, char *argv[])
    4040{
    41     MessageHandlerToStdout messages_to_stdout(MessageHandlerBase::Enable);
     41    LoggerToStdout messages_to_stdout(LoggerBase::Enable);
    4242    typedef double *pDouble;
    4343    int iCurrParam = 0; // index of the currently processed parameter
  • cpp/frams/genetics/f1/conv_f1.cpp

    r372 r375  
    55#include "conv_f1.h"
    66#include <common/nonstd_stl.h>
    7 #include <common/hmessage.h>
     7#include <common/log.h>
    88#include <frams/util/multirange.h>
    99#include <frams/util/multimap.h>
     
    6363                if ((n1<0) || (n2<0) || (n1>=neuro_f1_to_f0.size()) || (n2>=neuro_f1_to_f0.size()))
    6464                        {
    65                         if (final) Hprintf("GenoConvF1","addInput",HMLV_WARN,
     65                        if (final) logPrintf("GenoConvF1","addInput",LOG_WARN,
    6666                                            "illegal neuron connection %d <- %d (ignored)",n1,n2);
    6767                        return 0;
     
    178178                else
    179179                        {
    180                         Hmessage("GenoConv_F1","grow","Illegal neuron position (ignored)",1);
     180                        logMessage("GenoConv_F1","grow",1,"Illegal neuron position (ignored)");
    181181                        g=skipNeuro(g+1);
    182182                        }
  • cpp/frams/genetics/f4/conv_f4.cpp

    r372 r375  
    66
    77#include "conv_f4.h"
    8 #include <common/hmessage.h>
     8#include <common/log.h>
    99#include "../oper_fx.h" //for GENOPER_OK constant
    1010
     
    110110                if (res)
    111111                {
    112                         Hmessage("f4_Model", "buildModelRec", "Error in building Model", 2);
     112                        logMessage("f4_Model", "buildModelRec", 2, "Error in building Model");
    113113                        error = res;
    114114                        break;
     
    134134                        return cells->C[i];
    135135        // none!
    136         Hmessage("f4_Model", "getStick", "Not a single stick", 2);
     136        logMessage("f4_Model", "getStick", 2, "Not a single stick");
    137137        return NULL;
    138138}
  • cpp/frams/genetics/f4/f4_general.cpp

    r372 r375  
    77#include "f4_general.h"
    88#include <common/nonstd_stl.h>
    9 #include <common/hmessage.h>
     9#include <common/log.h>
    1010#include <frams/model/model.h> // for min and max attributes
    1111#include "../oper_fx.h" //for GENOPER_ constants
     
    581581                        char buf[40];
    582582                        sprintf(buf, "unknown code '%c'", gcur->name);
    583                         Hmessage("f4_Cell", "onestep", buf, 2);
     583                        logMessage("f4_Cell", "onestep", 2, buf);
    584584                        // fix: delete it
    585585                        org->setRepairRemove(gcur->pos, gcur);
  • cpp/frams/genetics/f4/oper_f4.cpp

    r372 r375  
    88#include "oper_f4.h"
    99#include <frams/util/sstring.h>
    10 #include <common/hmessage.h>
     10#include <common/log.h>
    1111
    1212#include <stdio.h>
     
    5151        mutation_method_names[index++] = "deleted a node";
    5252        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");
    5454}
    5555
  • cpp/frams/genetics/genman.cpp

    r372 r375  
    66#include <frams/vm/classes/genoobj.h>
    77#include GEN_CONFIG_FILE //configuration of active genetic operators
    8 #include "common/hmessage.h"
     8#include "common/log.h"
    99#include "common/nonstd_math.h"
    1010#include "common/stl-util.h"
    11 #include <frams/mhandlers/mhandlers.h>
     11#include <frams/loggers/loggers.h>
    1212
    1313
     
    267267                if (gf->mutate(gn, chg, method) == GENOPER_OK)
    268268                {
    269                         MessageHandlerToMemory eh(MessageHandlerBase::Enable | MessageHandlerToMemory::StoreFirstMessage); //mute testValidity()
     269                        LoggerToMemory eh(LoggerBase::Enable | LoggerToMemory::StoreFirstMessage); //mute testValidity()
    270270                        Geno G(gn, gv.getFormat(), "", "");
    271271                        canvalidate = true;
     
    284284                if (!ok && (count - pcount > 100))
    285285                {
    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());
    287287                        return Geno("", -1, "", "GENOPER_OPFAIL: Mutate() tried 100x and failed");
    288288                }
     
    308308
    309309        {
    310                 MessageHandlerToMemory eh(MessageHandlerBase::Enable | MessageHandlerToMemory::StoreFirstMessage); //mute testValidity()
     310                LoggerToMemory eh(LoggerBase::Enable | LoggerToMemory::StoreFirstMessage); //mute testValidity()
    311311                bool canvalidate = true;
    312312                if (testValidity(g1v, canvalidate) > 0 && canvalidate == false)
     
    333333                        if (g1n[0]) { gn = g1n; chg = chg1; }
    334334                        else { gn = g2n; chg = chg2; }
    335                         MessageHandlerToMemory eh(MessageHandlerBase::Enable | MessageHandlerToMemory::StoreFirstMessage); //mute testValidity()
     335                        LoggerToMemory eh(LoggerBase::Enable | LoggerToMemory::StoreFirstMessage); //mute testValidity()
    336336                        Geno G(gn, g1v.getFormat(), "", "");
    337337                        bool canvalidate = true;
     
    351351                if (!ok && (count - pcount > 100))
    352352                {
    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());
    354354                        return Geno("", -1, "", "GENOPER_OPFAIL: CrossOver() tried 100x and failed");
    355355                }
     
    500500        l.chg = chg;
    501501        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());
    503503        GenoLinkList.push_back(l);
    504504}
     
    533533        float f1, f2;
    534534        int m;
    535         Hmessage("GenMan", "Report", "The following genetic operators are available:", 0);
     535        logMessage("GenMan", "Report", 0, "The following genetic operators are available:");
    536536        for (unsigned int i = 0; i < oper_fx_list.size(); i++)
    537537        {
     
    549549                }
    550550                //      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",
    552552                        oper_fx_list[i]->supported_format, oper_fx_list[i]->name.c_str(), l.c_str());
    553553        }
  • cpp/frams/genetics/geno.cpp

    r372 r375  
    250250                }
    251251        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);
    253253}
    254254
  • cpp/frams/genetics/oper_fx.cpp

    r372 r375  
    55#include <ctype.h>  //isupper()
    66#include "oper_fx.h"
    7 #include <common/hmessage.h>
     7#include <common/log.h>
    88#include <common/nonstd_math.h>
    99#include <frams/util/rndutil.h>
     
    173173                }
    174174                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);
    176176}
    177177
     
    250250{
    251251        if (s == NULL)
    252                 Hmessage("GenoOperators", "skipWS", "NULL reference!", HMLV_WARN);
     252                logMessage("GenoOperators", "skipWS", LOG_WARN, "NULL reference!");
    253253        else
    254254        while (isWS(*s)) s++;
  • cpp/frams/loggers/loggers.cpp

    r374 r375  
    33// See LICENSE.txt for details.
    44
    5 #include "mhandlers.h"
     5#include "loggers.h"
    66#include <common/stl-util.h>
    77
    8 void _HmessageSingleLine(const char *o, const char *m, const char *txt, int w)
     8void _logMessageSingleLine(const char *o, const char *m, int w, const char *txt)
    99{
    10         tlsGetRef(message_handler_manager_instance).send(o, m, txt, w);
     10        tlsGetRef(message_handler_manager_instance).send(o, m, w, txt);
    1111}
    1212
    13 THREAD_LOCAL_DEF(MessageHandlerManager, message_handler_manager_instance);
     13THREAD_LOCAL_DEF(LoggerManager, message_handler_manager_instance);
    1414
    15 void MessageHandlerManager::send(int level, const char *o, const char *m, const char *bl, int w)
     15void LoggerManager::send(int level, const char *o, const char *m, int w, const char *bl)
    1616{
    1717        if (level >= handlers.size()) level = handlers.size() - 1;
     
    1919        for (int i = level; i >= 0; i--)
    2020        {
    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)))
    2424                {
    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;
    2727                }
    2828        }
    2929}
    3030
    31 int MessageHandlerManager::add(MessageHandlerBase *h)
     31int LoggerManager::add(LoggerBase *h)
    3232{
    3333        h->manager = this;
     
    3636}
    3737
    38 void MessageHandlerManager::remove(int i)
     38void LoggerManager::remove(int i)
    3939{
    40         MessageHandlerBase *h = handlers(i);
     40        LoggerBase *h = handlers(i);
    4141        h->manager = NULL;
    4242        handlers.remove(i);
    4343}
    4444
    45 void MessageHandlerManager::remove(MessageHandlerBase *h)
     45void LoggerManager::remove(LoggerBase *h)
    4646{
    4747        int i;
     
    5050}
    5151
    52 void MessageHandlerManager::removeAll()
     52void LoggerManager::removeAll()
    5353{
    5454        while (handlers.size() > 0)
     
    5858//////////////////////////////////
    5959
    60 void MessageHandlerBase::send(const char *o, const char *m, const char *bl, int w)
     60void LoggerBase::send(const char *o, const char *m, int w, const char *bl)
    6161{
    6262        if (!isEnabled()) return;
    6363        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);
    6565}
    6666
    67 void MessageHandlerBase::Hprintf(const char *o, const char *m, int w, const char *bl, ...)
     67void LoggerBase::logPrintf(const char *o, const char *m, int w, const char *bl, ...)
    6868{
    6969        if (!isEnabled()) return;
     
    7373        buf = ssprintf_va(bl, argptr);
    7474        va_end(argptr);
    75         send(o, m, buf.c_str(), w);
     75        send(o, m, w, buf.c_str());
    7676}
    7777
    7878
    79 void MessageHandlerBase::enable()
     79void LoggerBase::enable()
    8080{
    8181        if (isEnabled()) return;
     
    8383}
    8484
    85 void MessageHandlerBase::disable()
     85void LoggerBase::disable()
    8686{
    8787        if (!isEnabled()) return;
     
    8989}
    9090
    91 void MessageHandlerBase::pause()
     91void LoggerBase::pause()
    9292{
    9393        if (isPaused()) return;
     
    9595}
    9696
    97 void MessageHandlerBase::resume()
     97void LoggerBase::resume()
    9898{
    9999        if (!isPaused()) return;
     
    103103/////////////////////////////////
    104104
    105 void MessageHandlerToMemory::handle(const char *o, const char *m, const char *bl, int w)
     105void LoggerToMemory::handle(const char *o, const char *m, int w, const char *bl)
    106106{
    107107        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++;
    111111
    112112        if (w >= minleveltostore)
     
    118118                        {
    119119                                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);
    122121                        }
    123122                }
  • cpp/frams/loggers/loggers.h

    r374 r375  
    33// See LICENSE.txt for details.
    44
    5 #ifndef _MHANDLERS_H_
    6 #define _MHANDLERS_H_
     5#ifndef _FRAMS_LOGGERS_H_
     6#define _FRAMS_LOGGERS_H_
    77
    88#include <frams/util/list.h>
    99#include <frams/util/sstring.h>
    10 #include <common/hmessage.h>
     10#include <common/log.h>
    1111#include <common/threads.h>
    1212
    13 class MessageHandlerBase;
     13class LoggerBase;
    1414
    15 class MessageHandlerManager
     15class LoggerManager
    1616{
    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);
    2020public:
    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);
    2323        void remove(int i);
    24         void remove(MessageHandlerBase *r);
     24        void remove(LoggerBase *r);
    2525        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)
    2727        {
    28                 send(handlers.size() - 1, o, m, bl, w);
     28                send(handlers.size() - 1, o, m, w, bl);
    2929        }
    30         ~MessageHandlerManager() { removeAll(); }
     30        ~LoggerManager() { removeAll(); }
    3131};
    3232
    33 extern THREAD_LOCAL_DECL(MessageHandlerManager, message_handler_manager_instance);
     33extern THREAD_LOCAL_DECL(LoggerManager, message_handler_manager_instance);
    3434
    3535////////////////////////////////////////
    3636
    37 class MessageHandlerBase
     37class LoggerBase
    3838{
    39         friend class MessageHandlerManager;
     39        friend class LoggerManager;
    4040protected:
    41         MessageHandlerManager* manager;
     41        LoggerManager* manager;
    4242        int options;
    4343
    4444public:
    4545
    46         enum HandlerOptions
     46        enum LoggerOptions
    4747        {
    4848                DontBlock = 1, CannotBeBlocked = 2, Enable = 4, Paused = 8
    4949        };
    5050
    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);
    5353
    5454        bool isEnabled() { return manager ? true : false; }
     
    5959        void resume();
    6060
    61         MessageHandlerBase(int opts = 0) :manager(NULL), options(opts)
     61        LoggerBase(int opts = 0) :manager(NULL), options(opts)
    6262        {
    6363                if (options&Enable) enable();
    6464        }
    65         virtual ~MessageHandlerBase()
     65        virtual ~LoggerBase()
    6666        {
    6767                disable();
    6868        }
    6969
    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) {}
    7171};
    7272
    7373///////////////////////////////////////////
    7474
    75 class MessageHandlerToMemory : public MessageHandlerBase
     75class LoggerToMemory : public LoggerBase
    7676{
    7777protected:
     
    8181public:
    8282
    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; }
    8484
    8585        enum Options2
     
    9595        const SString& getMessages() { return msgs; }
    9696
    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)
    9898        {
    9999                reset();
    100100        }
    101101
    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);
    103103};
    104104
    105 class RedirectingMessageHandler : public MessageHandlerBase
     105class RedirectingLogger : public LoggerBase
    106106{
    107         MessageHandlerManager *other_manager;
     107        LoggerManager *other_manager;
    108108public:
    109         RedirectingMessageHandler(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) {}
    111111
    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)
    113113        {
    114                 other_manager->send(o, m, bl, w);
     114                other_manager->send(o, m, w, bl);
    115115        }
    116116};
  • cpp/frams/loggers/loggertostdout.cpp

    r374 r375  
    33// See LICENSE.txt for details.
    44
    5 #include "stdouthandler.h"
     5#include "loggertostdout.h"
    66#ifdef SHP
    77#include <FBaseSys.h> //AppLog
     
    1010#endif
    1111
    12 void MessageHandlerToStdout::handle(const char *o, const char *m, const char *bl, int w)
     12void LoggerToStdout::handle(const char *o, const char *m, int w, const char *bl)
    1313{
    1414        if (w < -1) w = -1; else if (w>3) w = 3;
    1515#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);
    1717#else
    1818        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);
    2020        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);
    2222#endif
    2323}
  • cpp/frams/loggers/loggertostdout.h

    r374 r375  
    33// See LICENSE.txt for details.
    44
    5 #ifndef _STDOUTHANDLER_H_
    6 #define _STDOUTHANDLER_H_
     5#ifndef _STDOUT_LOGGER_H_
     6#define _STDOUT_LOGGER_H_
    77
    8 #include "mhandlers.h"
     8#include "loggers.h"
    99#include <frams/virtfile/virtfile.h>
    1010
    11 class MessageHandlerToStdout : public MessageHandlerBase
     11class LoggerToStdout : public LoggerBase
    1212{
    1313        VirtFILE *file;
    1414public:
    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);
    1717};
    1818
  • cpp/frams/model/geometry/geometryutils.cpp

    r372 r375  
    8282                        break;
    8383        }
    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);
    8585        return false;
    8686}
     
    102102                        break;
    103103        }
    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);
    105105        return false;
    106106}
  • cpp/frams/model/geometry/meshbuilder.cpp

    r372 r375  
    639639
    640640                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);
    642642        }
    643643}
     
    725725
    726726                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);
    728728        }
    729729}
  • cpp/frams/model/geometry/modelgeometryinfo.cpp

    r372 r375  
    1616        if (points.size() < 1) //maybe 1 or 2 points are also not enough for findSizesAndAxesOfPointsGroup() to work...
    1717        {
    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());
    1919                sizes = Pt3D_0;
    2020                axes = Orient_1;
     
    116116                        return externalAreaOfCylinder(model, partIndex, density);
    117117        }
    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);
    119119        return 0;
    120120}
  • cpp/frams/model/model.cpp

    r372 r375  
    55#include <common/nonstd_math.h>
    66#include "model.h"
    7 #include <common/hmessage.h>
     7#include <common/log.h>
    88#include <frams/util/multimap.h>
    9 #include <frams/mhandlers/mhandlers.h>
     9#include <frams/loggers/loggers.h>
    1010
    1111Model::Model()
     
    317317SString line;
    318318MultiRange frommap;
    319 MessageHandlerToMemory mh(MessageHandlerBase::Enable | MessageHandlerBase::DontBlock);
     319LoggerToMemory mh(LoggerBase::Enable | LoggerBase::DontBlock);
    320320for (;f0txt.getNextToken(pos,line,'\n');lnum++)
    321321        {
     
    329329                {
    330330                buildstatus=invalid;
    331                 Hprintf("Model","build",HMLV_ERROR,
     331                logPrintf("Model","build",LOG_ERROR,
    332332                         geno.getName().len()?"illegal f0 code at line %d (%s)":"illegal f0 code at line %d",
    333333                         lnum,geno.getName().c_str());
     
    513513{
    514514if (buildstatus!=building)
    515         Hprintf("Model","close",HMLV_WARN,"unexpected close() - no open()");
     515        logPrintf("Model","close",LOG_WARN,"unexpected close() - no open()");
    516516if (internalcheck(1)>0)
    517517        {
     
    609609                {
    610610                delete j;
    611                 Hprintf("Model","build",HMLV_ERROR,
     611                logPrintf("Model","build",LOG_ERROR,
    612612                         "invalid part reference for joint #%d",getJointCount()-1);
    613613                return -1;
     
    694694                return 0;
    695695                }
    696         Hprintf("Model","build",HMLV_ERROR,
     696        logPrintf("Model","build",LOG_ERROR,
    697697                 "invalid neuron connection #%d <- #%d",c.n1_refno,c.n2_refno);
    698698        return -1;
     
    782782                        else
    783783                                {
    784                                 Hprintf("Model","internalCheck",HMLV_ERROR,
     784                                logPrintf("Model","internalCheck",LOG_ERROR,
    785785                                         "illegal N-N connection #%d (reference to #%d) (%s)",
    786786                                         i,n->conn_refno,(const char*)geno.getName());
     
    853853if (var -> field < getMin ## template () . field) \
    854854        { 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);} \
    856856else if (var -> field > getMax ## template () . field) \
    857857        { 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);}
    859859
    860860#define LINKFLAG 0x8000000
     
    912912                        {
    913913                        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)");
    915915                        }
    916916                }
     
    941941                                {
    942942                                ret=0;
    943                                 Hprintf("Model","internalCheck",HMLV_ERROR,
     943                                logPrintf("Model","internalCheck",LOG_ERROR,
    944944                                         "delta joint cycle detected at joint#%d (%s)",
    945945                                         i,geno.getName().c_str());
     
    978978                        {
    979979                        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)",
    981981                                 i,geno.getName().c_str());
    982982                        }
     
    984984                        {
    985985                        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)",
    987987                                 i,geno.getName().c_str());
    988988                        }
     
    992992        else
    993993                {
    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)",
    995995                         i,geno.getName().c_str());
    996996                ret=0;
     
    10011001                        {
    10021002                        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)");
    10041004                        }
    10051005                }
     
    10711071                if (!(p->flags&LINKFLAG))
    10721072                        {
    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)",
    10741074                                 i,geno.getName().c_str());
    10751075                        ret=0;
     
    10841084        if (j->p1_refno==j->p2_refno)
    10851085                {
    1086                 Hprintf("Model","internalCheck",HMLV_ERROR,"illegal self connection, joint #%d (%s)",
     1086                logPrintf("Model","internalCheck",LOG_ERROR,"illegal self connection, joint #%d (%s)",
    10871087                         i,geno.getName().c_str());
    10881088                ret=0;
     
    10951095                    || ((j->p1_refno==j2->p2_refno)&&(j->p2_refno==j2->p1_refno)))
    10961096                        {
    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)",
    10981098                                 i,k,geno.getName().c_str());
    10991099                        ret=0;
     
    11251125{
    11261126if (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()");
    11281128if (buildstatus!=valid)
    11291129        return Geno("",'0',"","invalid");
  • cpp/frams/neuro/neurofactory.cpp

    r372 r375  
    9898        }
    9999if (removed.len())
    100         Hprintf("NeuroFactory","removeUninmplemented",HMLV_INFO,
     100        logPrintf("NeuroFactory","removeUninmplemented",LOG_INFO,
    101101         "Removed Neuro classes: %s",removed.c_str());
    102102}
  • cpp/frams/neuro/neuroimpl.cpp

    r372 r375  
    7272        n->userdata[mytags_id]=ni;
    7373        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",
    7575                         i,n->getClassName().c_str());
    7676                continue; } // implementation not available?!
     
    8787        if (!ni->lateinit())
    8888                { 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",
    9090                         i,n->getClassName().c_str());
    9191                continue; }
  • cpp/frams/neuro/neuroimpl.h

    r372 r375  
    88#include <frams/model/model.h>
    99#include <frams/param/param.h>
    10 #include <common/hmessage.h>
     10#include <common/log.h>
    1111#ifdef NEURO_SIGNALS
    1212#include <frams/simul/signals.h>
  • cpp/frams/param/multiparamload.cpp

    r372 r375  
    55#include "multiparamload.h"
    66#include <frams/util/sstringutils.h>
    7 #include "common/hmessage.h"
     7#include "common/log.h"
    88#include <ctype.h>
    99
     
    107107        else if (status==BeforeUnknown)
    108108                {
    109                 Hprintf("MultiParamLoader","go",HMLV_WARN,"Skipping object '%s'",lastunknown.c_str());
     109                logPrintf("MultiParamLoader","go",LOG_WARN,"Skipping object '%s'",lastunknown.c_str());
    110110                loadObjectNow(&emptyparam,false);
    111111                continue;
     
    137137                                {
    138138                                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(),
    140140                                         (thisfilename?" in ":""),(thisfilename?thisfilename:""));
    141141                                }
     
    204204if (alreadyIncluded(newfilename.c_str()))
    205205        {
    206         Hprintf("MultiParamLoader","include",HMLV_WARN,"circular reference ignored (\"%s\")",
     206        logPrintf("MultiParamLoader","include",LOG_WARN,"circular reference ignored (\"%s\")",
    207207                    filename.c_str());
    208208        return;
     
    212212if (!f)
    213213        {
    214         Hprintf("MultiParamLoader","include",HMLV_WARN,"\"%s\" not found",newfilename.c_str());
     214        logPrintf("MultiParamLoader","include",LOG_WARN,"\"%s\" not found",newfilename.c_str());
    215215        }
    216216else
  • cpp/frams/param/param.cpp

    r372 r375  
    88#include "param.h"
    99#include <frams/util/extvalue.h>
    10 #include "common/hmessage.h"
     10#include "common/log.h"
    1111#include <frams/util/sstringutils.h>
    1212
     
    445445                {
    446446                        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());
    448448                }
    449449
     
    518518        case 'o':       ret.setObject(getObject(i)); break;
    519519        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));
    521521        }
    522522}
     
    562562                        if (v.type == TObj)
    563563                        {
    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());
    565565                                return 0;
    566566                        }
     
    574574                        if (v.type == TObj)
    575575                        {
    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());
    577577                                return 0;
    578578                        }
     
    583583        case 'o': return setObject(i, v.getObject());
    584584        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));
    586586        }
    587587        return 0;
     
    605605                        if ((after == NULL) || (*after))
    606606                        {
    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));
    608608                                e.setEmpty();
    609609                        }
     
    690690        }
    691691        if (err!=NULL)
    692                 Hprintf("SimpleAbstractParam","sanityCheck", HMLV_ERROR,
     692                logPrintf("SimpleAbstractParam","sanityCheck", LOG_ERROR,
    693693                "Invalid ParamEntry for %s.%s (%s)", getName(), pe->id, err);
    694694}       
     
    961961        else
    962962        {
    963                 Hprintf("SimpleAbstractParam", "call", HMLV_ERROR,
     963                logPrintf("SimpleAbstractParam", "call", LOG_ERROR,
    964964                        (*pe->type != 'p') ? "'%s.%s' is not a function" : "Internal error - undefined function pointer for '%s.%s'", getName(), pe->id);
    965965                ret->setInvalid();
     
    10601060                        {
    10611061                                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());
    10631063                        }
    10641064                        t = equals_sign + 1; // t=value
     
    10701070#endif
    10711071                        {
    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')",
    10731073                                getName(), id(i) ? id(i) : "unknown property?");
    10741074                        }
     
    10921092                        fields_loaded++;
    10931093                        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)",
    10951095                                id(i), getName(), (ret&PSET_HITMAX) ? "big" : "small");
    10961096                        *(char*)valstop = remember;
  • cpp/frams/param/param.h

    r372 r375  
    1212#include <frams/util/statrick.h>
    1313#include <frams/virtfile/virtfile.h>
    14 #include <common/hmessage.h>
     14#include <common/log.h>
    1515
    1616class ExtValue;
     
    273273                        SString svaluetoset = SString::valueOf(valuetoset); //converts any type to SString
    274274                        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.",
    276276                                getName(), id(i), svaluetoset.c_str(), (setflags&PSET_HITMAX) ? "big" : "small", actual.c_str());
    277277                }
  • cpp/frams/util/3d.cpp

    r372 r375  
    44
    55#include <common/nonstd_math.h>
    6 #include <common/hmessage.h>
     6#include <common/log.h>
    77#include "3d.h"
    88
     
    1717{
    1818        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; }
    2020        return sqrt(q);
    2121}
     
    2424{
    2525        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; }
    2727        operator/=(len);
    2828        return true;
     
    6464        if (dx == 0 && dy == 0)
    6565        {
    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);
    6767                return 0; // incorrect result, but there is no correct one
    6868        }
     
    147147{
    148148        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; }
    150150        return sqrt(q);
    151151}
  • cpp/frams/util/extvalue.cpp

    r372 r375  
    9898        if (warn)
    9999        {
    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());
    101101        }
    102102
     
    269269                        if (tmp.len() > 30) tmp = tmp.substr(0, 30) + "...";
    270270                        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());
    272272                }
    273273                return NULL;
     
    419419                                context->v2->typeAndValue().c_str());
    420420                }
    421                 Hprintf("ExtValue", "interpretCompare", HMLV_ERROR, "%s", msg.c_str());
     421                logPrintf("ExtValue", "interpretCompare", LOG_ERROR, "%s", msg.c_str());
    422422                ret = -1;
    423423        }
     
    448448                {
    449449                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());
    451451                        setDouble(double(getInt()) + src.getDouble());
    452452                        return;
     
    487487        default:;
    488488        }
    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());
    490490}
    491491
     
    502502                        return;
    503503                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());
    505505                        setDouble(double(getInt()) - src.getDouble());
    506506                        return;
     
    520520        default:;
    521521        }
    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());
    523523}
    524524
     
    535535                        return;
    536536                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());
    538538                        setDouble(double(getInt())*src.getDouble());
    539539                        return;
     
    591591        default:;
    592592        }
    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());
    594594}
    595595
     
    611611        else
    612612        {
    613                 Hprintf("ExtValue", "divide", HMLV_CRITICAL, "Division by zero: %d/0", idata());
     613                logPrintf("ExtValue", "divide", LOG_CRITICAL, "Division by zero: %d/0", idata());
    614614                setInvalid();
    615615        }
     
    620620        if (a == 0.0)
    621621        {
    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());
    623623                setInvalid();
    624624        }
     
    629629                if (!finite(tmp))
    630630                {
    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();
    632632                }
    633633                else
     
    635635                // niby dobrze ale lepiej byloby to robic bardziej systematycznie a nie tylko w dzieleniu?
    636636                //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(); }
    638638                fpExceptEnable();
    639639        }
     
    651651                        return;
    652652                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());
    654654                        divDouble(src.ddata());
    655655                        return;
     
    673673        default:;
    674674        }
    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());
    676676}
    677677
     
    778778
    779779        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());
    781781
    782782        default:;
     
    791791        {
    792792                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)" : "");
    794794                return false;
    795795        }
     
    805805        {
    806806                if (error)
    807                         Hprintf("ExtValue", "parseDouble", HMLV_ERROR, "Could not parse '%s'", s);
     807                        logPrintf("ExtValue", "parseDouble", LOG_ERROR, "Could not parse '%s'", s);
    808808                return false;
    809809        }
     
    836836        case TString: return getInt(sdata().c_str());
    837837        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());
    839839                return (paInt)(intptr_t)odata().param;
    840840        default:;
     
    851851        case TString: return getDouble(sdata().c_str());
    852852        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());
    854854                return (double)(intptr_t)odata().param;
    855855        default:;
     
    989989                else
    990990                {
    991                         Hprintf("ExtValue", "deserialize", HMLV_ERROR, "Missing '\"' in string: '%s'", ret);
     991                        logPrintf("ExtValue", "deserialize", LOG_ERROR, "Missing '\"' in string: '%s'", ret);
    992992                        return NULL;
    993993                }
     
    10111011                                else if (*p != ']')
    10121012                                {
    1013                                         Hprintf("ExtValue", "deserialize", HMLV_ERROR, "Missing ',' in Vector: '%s'", p);
     1013                                        logPrintf("ExtValue", "deserialize", LOG_ERROR, "Missing ',' in Vector: '%s'", p);
    10141014                                        return NULL;
    10151015                                }
     
    10371037                        if ((!ret) || (args[1].getType() != TString)) { p = NULL; break; }
    10381038                        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; }
    10401040                        p++;
    10411041                        ret = args[0].deserialize(p);
     
    10461046                        else if (*p != '}')
    10471047                        {
    1048                                 Hprintf("ExtValue", "deserialize", HMLV_ERROR, "Missing ',' in Dictionary: '%s'", p);
     1048                                logPrintf("ExtValue", "deserialize", LOG_ERROR, "Missing ',' in Dictionary: '%s'", p);
    10491049                                return NULL;
    10501050                        }
     
    10861086                        }
    10871087                }
    1088                 Hprintf("ExtValue", "deserialize", HMLV_ERROR, "Invalid reference: '%s'", in - 1);
     1088                logPrintf("ExtValue", "deserialize", LOG_ERROR, "Invalid reference: '%s'", in - 1);
    10891089                return NULL;
    10901090        }
     
    11331133                }
    11341134                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());
    11361136                return ret;
    11371137        }
    1138         Hprintf("ExtValue", "deserialize", HMLV_ERROR, "Bad syntax: '%s'", in);
     1138        logPrintf("ExtValue", "deserialize", LOG_ERROR, "Bad syntax: '%s'", in);
    11391139        setEmpty();
    11401140        return NULL;
  • cpp/frams/util/sstringutils.cpp

    r372 r375  
    55#include "sstringutils.h"
    66#include <frams/virtfile/virtfile.h>
    7 #include <common/hmessage.h>
     7#include <common/log.h>
    88#include <common/nonstd.h>
    99
     
    1919        }
    2020        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);
    2222        return ret;
    2323}
  • cpp/frams/util/validitychecks.cpp

    r374 r375  
    33// See LICENSE.txt for details.
    44
    5 #include "stderrors.h"
     5#include "validitychecks.h"
    66#include <frams/util/sstringutils.h>
    7 #include <common/hmessage.h>
     7#include <common/log.h>
    88
    99bool listIndexCheck(SList* list,int index,const char* msgobj,const char* msgfun)
     
    1313        {
    1414        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);
    1616        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);
    1818        return 0;
    1919        }
     
    2929        {
    3030        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());
    3232        }
    3333return corrected;
  • cpp/frams/util/validitychecks.h

    r372 r375  
    33// See LICENSE.txt for details.
    44
    5 #ifndef _STDERRORS_H_
    6 #define _STDERRORS_H_
     5#ifndef _VALIDITY_CHECKS_H_
     6#define _VALIDITY_CHECKS_H_
    77
    88#include <frams/util/list.h>
     
    1010
    1111bool 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);
     12SString stringCheck(SString& in,const char* msgobj,const char* msgfun,const char* msg,SString (*checker)(SString& in)=NULL);
    1313
    1414#endif
  • cpp/frams/virtfile/stdiofile.cpp

    r374 r375  
    66#include <common/nonstd_dir.h>
    77#include <common/nonstd_stdio.h>
    8 #include <common/hmessage.h>
     8#include <common/log.h>
    99#include <common/Convert.h>
    1010
    1111VirtFILE* StdioFileSystem::Vfopen(const char *path, const char *mode)
    1212{
    13         //printH("Vfopen %s %s",path,mode);
     13        //log_printf("Vfopen %s %s",path,mode);
    1414#if defined USE_MFILE || defined _WIN32
    1515        MFILE *f = mfopen(path, mode);
     
    1717        FILE *f = fopen(path, mode);
    1818#endif
    19         //printH("%p",f);
     19        //log_printf("%p",f);
    2020        if (f) return new StdioFILE(f, path); else return NULL;
    2121}
     
    2323VirtDIR* StdioFileSystem::Vopendir(const char* path)
    2424{
    25         //printH("Vopendir %s",path);
     25        //log_printf("Vopendir %s",path);
    2626#ifdef _WIN32
    2727        DIRTYPE *d = wopendir(Convert::utf8ToUtf16(path).c_str());
     
    2929        DIR *d = opendir(path);
    3030#endif
    31         //printH("%p",d);
     31        //log_printf("%p",d);
    3232        if (d) return new StdioDIR(d); else return NULL;
    3333}
     
    5252dirent* StdioDIR::Vreaddir()
    5353{
    54         //printH("Vreaddir %s",dir);
     54        //log_printf("Vreaddir %s",dir);
    5555#ifdef _WIN32
    5656        wdirent *wde=wreaddir(dir);
  • cpp/frams/vm/classes/collectionobj.cpp

    r372 r375  
    55#include "collectionobj.h"
    66#include <common/nonstd_math.h> //sqrt in borland
    7 #include <frams/mhandlers/stderrors.h>
     7#include <frams/util/validitychecks.h>
    88#include <common/nonstd_stl.h>
    99#include <frams/util/sstringutils.h>
     
    232232        {
    233233        ret=false;
    234         Hprintf("VectorElementComparator","",HMLV_ERROR,"Comparison function returned no value");
     234        logPrintf("VectorElementComparator","",LOG_ERROR,"Comparison function returned no value");
    235235        }
    236236else
  • cpp/frams/vm/framscript.y

    r348 r375  
    55%{
    66#include "framscript-defs.h"
    7 #include "common/framsg.h"
     7#include "common/log.h"
    88#include <math.h>
    99#include <ctype.h>
     
    145145 {
    146146#ifdef FRAMSCRIPT_GOTO
    147 trctx.out->printf("jump :%s\n",str($2)); FMprintf("FramScriptCompiler","translate",FMLV_WARN,"goto is not recommended"); trctx.emitLine();
     147trctx.out->printf("jump :%s\n",str($2)); logPrintf("FramScriptCompiler","translate",LOG_WARN,"goto is not recommended"); trctx.emitLine();
    148148#else
    149149trctx.err->printf("goto is not supported\n");return 1;
     
    15151515{
    15161516if (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");
    15181518}
    15191519
Note: See TracChangeset for help on using the changeset viewer.