Forum Discussion
irule proc with default values failing
- Jul 28, 2022
Hi
when i try this
rule proc_lib {
proc loggingNowStr2 { {log_now_clock 0} {log_now_msec 0} } {
}}
i get this
01070151:3: Rule [/Common/YB_SOEv2_Platform_logging_v1.1] error: /Common/YB_SOEv2_Platform_logging_v1.1:53: error: [undefined procedure: rule][rule proc_lib {
proc loggingNowStr2 { {log_now_clock 0} {log_now_msec 0} } {
}
}]I have my proc outside rule proc_lib
why do you use rule proc_lib ?
I tried your code - started a new irule and got this error
01070151:3: Rule [/Common/test] error: /Common/test:1: error: [undefined procedure: rule][rule proc_lib {
proc loggingNowStr { {log_now_clock 123456789} {log_now_msec 78341239432} } {
set log_now_diff [expr { $log_now_msec - ( $log_now_clock * 1000 ) }]
incr log_now_clock [ expr { $log_now_diff / 1000 }]
set log_now_fract [expr { $log_now_diff % 1000 }]
set log_now_fract [format "%03d" $log_now_fract]
set log_now_start_time_str [clock format $log_now_clock -format "%Y-%m-%d %H:%M:%S.${log_now_fract}"]
return $log_now_start_time_str
}
}]
HI AlexS_yb , it looks like it doesn't like clock to provide default values there...got the same errors you did until I just tried a test pattern. RULE_INIT works just fine for me otherwise.
rule proc_lib {
proc loggingNowStr { {log_now_clock 123456789} {log_now_msec 78341239432} } {
set log_now_diff [expr { $log_now_msec - ( $log_now_clock * 1000 ) }]
incr log_now_clock [ expr { $log_now_diff / 1000 }]
set log_now_fract [expr { $log_now_diff % 1000 }]
set log_now_fract [format "%03d" $log_now_fract]
set log_now_start_time_str [clock format $log_now_clock -format "%Y-%m-%d %H:%M:%S.${log_now_fract}"]
return $log_now_start_time_str
}
}
rule init_proc_test {
when RULE_INIT {
set x [call proc_lib::loggingNowStr]
set y [call proc_lib::loggingNowStr [clock clicks] [clock clicks -milliseconds]]
log local0. "Default args: $x; Provided args: $y"
}
}
### RESULT ###
Jul 28 00:06:29 ltm3.test.local info tmm1[20054]: Rule /Common/init_proc_test : Default args: 1972-06-25 12:27:19.432; Provided args: 2022-07-28 00:06:29.879
Hi
when i try this
rule proc_lib {
proc loggingNowStr2 { {log_now_clock 0} {log_now_msec 0} } {
}
}
i get this
01070151:3: Rule [/Common/YB_SOEv2_Platform_logging_v1.1] error: /Common/YB_SOEv2_Platform_logging_v1.1:53: error: [undefined procedure: rule][rule proc_lib {
proc loggingNowStr2 { {log_now_clock 0} {log_now_msec 0} } {
}
}]
I have my proc outside rule proc_lib
why do you use rule proc_lib ?
I tried your code - started a new irule and got this error
01070151:3: Rule [/Common/test] error: /Common/test:1: error: [undefined procedure: rule][rule proc_lib {
proc loggingNowStr { {log_now_clock 123456789} {log_now_msec 78341239432} } {
set log_now_diff [expr { $log_now_msec - ( $log_now_clock * 1000 ) }]
incr log_now_clock [ expr { $log_now_diff / 1000 }]
set log_now_fract [expr { $log_now_diff % 1000 }]
set log_now_fract [format "%03d" $log_now_fract]
set log_now_start_time_str [clock format $log_now_clock -format "%Y-%m-%d %H:%M:%S.${log_now_fract}"]
return $log_now_start_time_str
}
}]
- JRahmJul 28, 2022Admin
I centralize all my procedures together in a library iRule that I call proc_lib so they can be maintained / managed separately from the logic of individual iRules. I updated my example to show the two named iRule objects, proc_lib and init_proc_test. First I created your procedure (unchanged except for a static default value for each argument) in the proc_lib iRule and then I added the init_proc_test iRule, which generated the resulting log entry when I saved it due to the RULE_INIT event firing and calling that loggingNowStr procedure in the proc_lib iRule twice, the first time with defaults in use and the second time with clock command values sent as arguments.
- AlexS_ybJul 28, 2022Cirrocumulus
Yes I try that too, but
rule <> {
}
syntax fails !
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com