使用 Progress 4GL 防止调试代码投入生产?
使用 Progress 4GL 时,如何防止调试代码块意外泄漏到生产环境中?
How would you prevent chunks of debugging code from accidentally leaking into production enviroment when using Progress 4GL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我通常只发布一个特殊事件 - 调试消息。 在我的开发环境中,应用程序中有一个菜单项,它将启动一个窗口,该窗口在任何地方订阅调试消息并显示生成的任何消息。 因此,我可以将调试消息插入到我的代码中,然后如果我想查看这些消息,则打开窗口。 如果我忘记整理调试代码,那么实时用户将看不到任何消息,尽管我仍然可以打开调试窗口来查看发生了什么。
(此版本的 webspeed 只会将输出写入操作系统文件)
I usually just publish a special event - debug-message. In my dev environment there's a menu item in the application which will fire up a window which susbscribes to debug-message anywhere and displays any messages generated. So I can insert debug-messages into my code and then open the window if I want to see the messages. If I forget to tidy up the debug code then the live users don't see any messages, although I can still open the debug window to see what's going on.
( The webspeed version of this would just write the output to an OS file )
如果您的测试数据库和生产数据库具有不同的名称,您可以使用以下代码:
If your test database and production databases have different names, you could use this code:
与我关于断言的其他答案类似,您可以设置一个包含,该包含在包含调试标志的生产站点上将为空。 在开发站点上,您只需定义该值,以便将调试代码包含在您的程序中。
通过将代码包装在预处理器中,当您将其编译到生产站点时,编译器将完全省略调试代码。
&如果已定义( debugalert ) <> 0 &然后
<代码>
&endif
然后,您可以在要包含调试代码的代码版本中使用“&global-define debug”。 不定义“debug”会导致编译器忽略代码。
/* debug.i 在生产中省略以下内容 */
&GLOBAL-DEFINE DEBUGALERT
/* test.p */
{debug.i}
DEF VAR h_ct AS INT NO-UNDO
DO h_ct = 1 TO 10:
&IF DEFINED( DEBUGALERT ) <> 0 &THEN
&ENDIF
结束。
Similar to my other answer about the assertions, you can setup an include that will be empty on production sites containing the debug flag. On development sites you just need to define the value so that your debugging code is included in your program.
By wrapping code in a preprocessor the compiler will omit the debug code altogether when you compile it onto a production site.
&if defined( debugalert ) <> 0 &then
&endif
You would then use the "&global-define debug" in versions of the code you want to contain the debug code. Not defining "debug" should cause the compiler to omit the code.
/* debug.i omit the following on production */
&GLOBAL-DEFINE DEBUGALERT
/* test.p */
{debug.i}
DEF VAR h_ct AS INT NO-UNDO
DO h_ct = 1 TO 10:
&IF DEFINED( DEBUGALERT ) <> 0 &THEN
&ENDIF
END.
解决方案基于这样的假设:开发环境具有唯一的 propath 条目,该条目在其他环境中不可用,并且代码在移动时会重新编译:
用法
将文件另存为“debug”(不带扩展名)到propath指向的目录,则:
A solution is based on the assumption that development enviroment has a unique propath entry that is not available in other enviroments and code is recompiled when moved over:
Usage
Save file as "debug" (without extension) to a directory pointed at by propath, then: