Forum Discussion

Nicolas_MENOUX_'s avatar
Nicolas_MENOUX_
Icon for Nimbostratus rankNimbostratus
May 18, 2010

How to get the line number of my Irule for debugging ?

Hi,

 

 

I use many IRules on my F5 BigIP to rewrite URLs for specific services. I logged these rewrited urls into local0.info but I would like to insert in that log the line concerned in my IRule script. Indeed, I used many if elsif... and I would like to get the line number of my script which will transform my url. Thus, in my log I could easily see which line in a specific script is concerned for rewriting url...easier to debug ;-)

 

 

A sort of "_line" variable I could use before writing my string to the log file. Any idea ?

 

 

Thanks for your help,

 

 

Regards,

2 Replies

  • Hi Nicolas,

     

     

    I don't think there is a way to get the line number programmatically from an iRule. I suppose you could increment a local variable before each log line and log that though:

     

     

    set counter 0

     

    log local0. "$counter: my log message"

     

    ... iRule code ...

     

    incr counter

     

    log local0. "$counter: my next log message"

     

    ... iRule code ...

     

     

    Or you could hard code the debug lines:

     

     

    log local0. "1: my log message"

     

    ... iRule code ...

     

    log local0. "2: my next log message"

     

    ... iRule code ...

     

     

    Aaron
  • Hi Aaron,

     

     

    thanks for your quick reply. Yes, I think as you, there is no way to get the line number from the script...may be I'm wrong I hope so :-)

     

    Increment a variable is a good solution but quite a nightmare to find the line after :-)

     

    Anyway, I will try to change all of my if elseif endif blocs to be able to track the active line.

     

     

    Thanks a lot,

     

     

    Nicolas