Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: analytics logs no longer shown #656

Merged
merged 3 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.smeup.rpgparser.interpreter
Expand Down Expand Up @@ -67,6 +68,12 @@ interface InterpreterCore {
fun optimizedIntExpression(expression: Expression): () -> Long
fun enterCondition(index: Value, end: Value, downward: Boolean): Boolean
fun increment(dataDefinition: AbstractDataDefinition, amount: Long): Value
/***
* This method is called when the interpretation of the first program of the stack is ended
* There is no warranty that this method is called unless you use:
* com.smeup.rpgparser.execution.CommandLineProgram.singleCall
* methods
*/
fun onInterpretationEnd()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class ProgramInterpreter(val systemInterface: SystemInterface) {
MainExecutionContext.getProgramStack().push(rpgProgram)
rpgProgram.execute(systemInterface = systemInterface, params = initialValues)
MainExecutionContext.getProgramStack().pop()
if (MainExecutionContext.getProgramStack().isEmpty()) {
rpgProgram.intepreterCore.onInterpretationEnd()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.smeup.rpgparser.interpreter
Expand Down Expand Up @@ -176,10 +177,6 @@ class RpgProgram(val cu: CompilationUnit, val name: String = "<UNNAMED RPG PROGR
logHandlers.renderLog(LazyLogEntry.produceStatement(logSource, "INTERPRETATION", "END"))
logHandlers.renderLog(LazyLogEntry.producePerformanceAndUpdateAnalytics(logSource, ProgramUsageType.Interpretation, "INTERPRETATION", elapsed))
}
if (MainExecutionContext.getProgramStack().isEmpty()) {
interpreter.onInterpretationEnd()
}

return changedInitialValues
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.smeup.rpgparser.logging
Expand Down Expand Up @@ -293,4 +294,21 @@ class LoggingTest : AbstractTest() {
null
)
}

/**
* Test if analytics logs are overwritten through the setting of [com.smeup.rpgparser.execution.JarikoCallback.logInfo]
* */
@Test
fun analyticsChannelLogInfo() {
val configuration = Configuration()
var logInfCalled = false
configuration.jarikoCallback.logInfo = { _, _ ->
logInfCalled = true
}
val systemInterface = JavaSystemInterface(configuration = configuration).apply {
loggingConfiguration = consoleLoggingConfiguration(LogChannel.ANALYTICS)
}
executePgm(programName = "HELLO", configuration = configuration, systemInterface = systemInterface)
assertTrue(logInfCalled, "logInfo never called")
}
}