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
}
}]
I've never seen the setting of procedure default values to be the output of a command. Probably better to code it so that you set default to be false and then check whether it is still false. If not, set it to the output of the command:
proc loggingNowStr { {log_now_clock 0} {log_now_msec 0} } {
if { $log_now_clock == 0 } {
set log_now_clock [clock seconds]
}
if { $log_now_msec == 0 } {
set log_now_msec [clock clicks -milliseconds]
}
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
}
- AlexS_ybJul 28, 2022Cirrocumulus
Yeah thats what I ended up doing
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