Uploaded image for project: 'Teiid'
  1. Teiid
  2. TEIID-1632

Provide something like an ECHO statement in the procedure language that can assist a user in debugging their procedure logic

    • Icon: Feature Request Feature Request
    • Resolution: Done
    • Icon: Major Major
    • 7.4.1, 7.5
    • 7.4
    • Server
    • None

      Provide something like an ECHO statement in the procedure language that can assist a user in debugging their procedure logic

            [TEIID-1632] Provide something like an ECHO statement in the procedure language that can assist a user in debugging their procedure logic

            > Just an observation from my first use, I'm not a fan of it.

            It's all a matter of perspective. One could equally assert that littering your procedure or java code with System.outs is not a great idea. At worst you have to go back and remove them and/or convert them into proper logging statements. Perhaps your requirement is for a simpler way to control logging or to have a default logger (org.teiid.console or whatever name makes sense) configured that is already routed to the console: CALL logMsg(msg=>'foo' context=>'org.teiid.console')

            Steven Hawkins added a comment - > Just an observation from my first use, I'm not a fan of it. It's all a matter of perspective. One could equally assert that littering your procedure or java code with System.outs is not a great idea. At worst you have to go back and remove them and/or convert them into proper logging statements. Perhaps your requirement is for a simpler way to control logging or to have a default logger (org.teiid.console or whatever name makes sense) configured that is already routed to the console: CALL logMsg(msg=>'foo' context=>'org.teiid.console')

            Just an observation from my first use, I'm not a fan of it. All I want was to do is output to the console. But in order to get logging to work, I now have to turn on some other logging just to get a statement out. It's all well and good, if I'm adding statements that will remain as part of standard logging. Having to turn on logging defeats the easiness of just writing to System.out. Just my opinion on easy of use.

            Van Halbert (Inactive) added a comment - Just an observation from my first use, I'm not a fan of it. All I want was to do is output to the console. But in order to get logging to work, I now have to turn on some other logging just to get a statement out. It's all well and good, if I'm adding statements that will remain as part of standard logging. Having to turn on logging defeats the easiness of just writing to System.out. Just my opinion on easy of use.

            After more analysis, system procedures worked better - there's no need to change the parser and the implicit cursor is not affected when a procedure does not have a resultset.

            So the procedures SYSADMIN.isLoggable and SYSADMIN.logMsg were added and are covered in the reference. They each have defaults for level and context parameters, so the simplest statement will be:

            CALL logMsg(msg=>'I''m debugging');

            The use of isLoggable looks like:

            IF ((CALL isLoggable('TRACE', 'org.something')))
            BEGIN
            ...

            Steven Hawkins added a comment - After more analysis, system procedures worked better - there's no need to change the parser and the implicit cursor is not affected when a procedure does not have a resultset. So the procedures SYSADMIN.isLoggable and SYSADMIN.logMsg were added and are covered in the reference. They each have defaults for level and context parameters, so the simplest statement will be: CALL logMsg(msg=>'I''m debugging'); The use of isLoggable looks like: IF ((CALL isLoggable('TRACE', 'org.something'))) BEGIN ...

            At this point given our usage of implicit cursoring, a procedure language level enhancement would be most appropriate. Having a procedure or log function would cause the implicit return cursor to be set from that statement.

            So we would have something like:

            OUTPUT LOG [level] [context] message

            The OUTPUT reserved word would be needed to disambiguate the parsing. level could be integral, or the Log4j level mnemonics, or the jre Level mnemonics. it would default to the appropriate debug level. Context would be a string and default to org.teiid.PROCESSOR

            We could make the message expression evaluation contingent upon whether the log will actually be recorded. But we'd probably also have to add a boolean system function for more complicated scenarios:

            IF (isLoggable(level, context))
            BEGIN
            //complex concat of message
            OUTPUT LOG ....
            END

            The logs would then be delivered to the underlying log4j logging system.

            Any thoughts?

            Steven Hawkins added a comment - At this point given our usage of implicit cursoring, a procedure language level enhancement would be most appropriate. Having a procedure or log function would cause the implicit return cursor to be set from that statement. So we would have something like: OUTPUT LOG [level] [context] message The OUTPUT reserved word would be needed to disambiguate the parsing. level could be integral, or the Log4j level mnemonics, or the jre Level mnemonics. it would default to the appropriate debug level. Context would be a string and default to org.teiid.PROCESSOR We could make the message expression evaluation contingent upon whether the log will actually be recorded. But we'd probably also have to add a boolean system function for more complicated scenarios: IF (isLoggable(level, context)) BEGIN //complex concat of message OUTPUT LOG .... END The logs would then be delivered to the underlying log4j logging system. Any thoughts?

            I've had multiple requests/inquiries recently to make procedure debugging easier. Perhaps a logger function that allow the author to place arbitrary logging statements in procedure code and have it be controlled by log level so it can enabled/disabled through configuration.

            Ken Johnson added a comment - I've had multiple requests/inquiries recently to make procedure debugging easier. Perhaps a logger function that allow the author to place arbitrary logging statements in procedure code and have it be controlled by log level so it can enabled/disabled through configuration.

              rhn-engineering-shawkins Steven Hawkins
              van.halbert Van Halbert (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: