代码之家  ›  专栏  ›  技术社区  ›  Dominique

如何登录OpenEdge进程?

  •  0
  • Dominique  · 技术社区  · 5 年前

    简单的 MESSAGE

    ON CHOOSE OF btn-Q4
    DO:
      MESSAGE "Line 1".
      MESSAGE "Line 2".
      MESSAGE "Line 3".
    
      PROMPT-FOR ...
        WITH FRAME ...
      ...
      MESSAGE "Alert message" VIEW-AS ALERT-BOX.
      
      PROMPT-FOR ...
        WITH FRAME ... /* (another frame) */
      ...
      MESSAGE "Another alert message" VIEW-AS ALERT-BOX.
      ...
      MESSAGE "Normal message".
    END.
    

    这从显示第1行和第2行开始,第3行有一个滚动条,但由于其他类似对话框的框架,因此无法访问,一旦这些框架消失,原始消息行就不再存在。

    MESSAGE ... VIEW-AS ALERT-BOX . 这样做很好,甚至可以进行复制粘贴,但是所有消息都显示在单独的警报框中,这使得处理起来非常困难。

    第三种可能性,在这个网站上提到,是使用日志管理器,但我没有一个文件,叫做 *log*manager* 在我的进步4GL安装的某处,所以我不知道如何使用这个。

    有人能给我解释一下怎么做测井吗?我想要的是:

    ...
    LOG("Line1").
    ...
          LOG("Line2").
    ...
      LOG("Line3").
    ...
    

    缩进表示调用堆栈中的位置(“Line3”由函数调用,而“Line2”由子函数调用,由子函数调用,由函数调用)。

    理想的:

    Line1
    ......Line2
    ..Line3
    

    如果这不可能,我同意:

    Line1
    Line2
    Line3
    

    提前谢谢

    0 回复  |  直到 5 年前
        1
  •  1
  •   TheDrooper    5 年前

    如果您只想记录一些简单的消息,可以将输出重定向到一个文件。使用 OUTPUT TO

    OUTPUT TO VALUE("logfile.txt").
    
    PUT UNFORMATTED "Message 1" SKIP.
    PUT UNFORMATTED "Message 2" SKIP.
    PUT UNFORMATTED "Message 3" SKIP.
    
    OUTPUT CLOSE.
    

    Message 1
    Message 2
    Message 3
    

    这个 PUT UNFORMATTED 语句向文件发送字符串。这个 SKIP 关键字添加换行符。这个 OUTPUT CLOSE

    如果要添加到现有文件中,请使用 APPEND OUTPUT 声明:

    OUTPUT TO VALUE("logfile.txt") APPEND.
    
        2
  •  1
  •   andrew cooke    5 年前

    doc 关于伐木,尤其是 LOG-MANAGER 命令和 4GLTrace 日志条目类型。

    日志管理器 一般来说,对于“系统”类型信息非常有用—有很多跟踪和调试数据可用。它还可以用于应用程序日志记录 WRITE-MESSAGE 方法;虽然这样做是很粗糙的,所以如果您想使用它,您可能需要在它周围编写一个包装器(例如,用于过滤日志级别)。

    如果你使用的是合理的最新版本,你可以看看 https://docs.progress.com/bundle/openedge-abl-develop-services/page/ABL-application-logging.html 它为这个(以及更多)提供了一个包装器。

        3
  •  1
  •   Tom Bascom    5 年前

    /* logger.p
     *
     * to instantiate:
     *
     *      run logger.p persistent
     *
     * three ways to call it from your code:
     *
     *   publish "logMsg" ( msgLevel, messageText ).        // requires no knowledge in the caller, no error if logger.p has not first been run persistently
     *   run doLogMsg ( msgLevel, messageText ).            // requires no knowledge in the caller, error if logger.p is not run first
     *   logMsg( msgLevel, messageText ).                   // requires forward declaration in the caller
     */
    
    
    subscribe to "setLogName" anywhere run-procedure "setLogName".
    subscribe to "logMsg"     anywhere run-procedure "doLogMsg".
    
    define variable logMsgLevel    as integer   no-undo initial 3.
    define variable logMsgFileName as character no-undo initial "application.log".
    
    define stream logStream.
    
    /* install self as a session super-procedure
     */
    
    session:add-super-procedure( this-procedure ).
    
    return.
    
    
    /* housekeeping
     */
    
    procedure setLogName:
      define input parameter logName as character no-undo.
      logMsgFileName = logName.
      return.
    end.
    
    
    procedure setLogLevel:
      define input parameter logLevel as integer no-undo.
      logMsgLevel = logLevel.
      return.
    end.
    
    
    /* to use this function directly from another procedure you must first declare it in that procedure:
     *
     *      function logMsg returns logical ( input msgLevel as integer, input msgText as character ) in super.
     */
    
    function logMsg returns logical ( input msgLevel as integer, input msgText as character ):
      run doLogMsg( msgLevel, msgText ).
      return true.
    end.
    
    
    /* procedures do not need to be forward declared but we can not have a function and a procedure with the same name
     */
    
    procedure doLogMsg:
    
      define input parameter msgLevel as integer   no-undo.
      define input parameter msgText  as character no-undo.
    
      if msgLevel <= logMsgLevel then
        do:
          output stream logStream to value( logMsgFileName ) append.
          put    stream logStream unformatted today " " string( time, "hh:mm:ss" ) " " msgText skip.
          output stream logStream close.
        end.
    
      return.
    
    end.
    

    试验台示例:

    /* test logger.p
     */
    
    /* run doLogMsg ( 3, "test a" ).  */
    
    /* logMsg( 3, "test b" ).         */
    
    
    
    function logMsg returns logical ( input msgLevel as integer, input msgText as character ) in super.     /* usually this is in a include file in the procedure header */
    
    publish "logMsg" ( 3, "test 1" ).
    
    run ./logger.p persistent.              /* loads logger.p into memory... */
    
    run setLogName ( "test.log" ).
    
    publish "logMsg" ( 3, "test 2" ).
    
    run doLogMsg ( 3, "test 3" ).
    
    logMsg( 3, "test 4" ).
    
    推荐文章