Just for sharing. Sometimes you dont know where an echo cometh from (a 
bottomless pit maybe :-) )

Below code can help with that.

Maybe somebody has a macro that extracts the location-info automatically?

Untill now i havent done macros because i am too busy programming..
    
    
    # logging with file- and proc-location
    
    var
      talkbo: bool = false
      locst = "my_module_"
    
    
    template talk(messagest: string) =
      #[
        - replacement for echo that is only evaluated when talkbo = true
        - you can set talkbo in the function to take precedence over the 
module-value
        - you can append the proc-name to the module-name via procst
       ]#
      
      if talkbo:
        echo locst, ": ", messagest
    
    
    proc letsTalk() =
      
      talkbo = true
      locst &= "letsTalk"
      
      talk("talking..")
    
    
    letsTalk()
    
    # should return:
    # my_module_letsTalk: talking..
    
    
    
    Run

Reply via email to