Skip to content

Commit 0058cbb

Browse files
committed
fix: updated logs to use runContext.logger() and removed unused import
1 parent acc0212 commit 0058cbb

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

src/main/java/io/kestra/plugin/azure/eventhubs/Trigger.java

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,11 @@
1212
import io.swagger.v3.oas.annotations.media.Schema;
1313
import jakarta.validation.constraints.NotNull;
1414
import lombok.*;
15-
import lombok.experimental.SupperBuilder;
1615
import lombok.experimental.SuperBuilder;
17-
18-
1916
import org.slf4j.Logger;
2017
import org.slf4j.LoggerFactory;
2118

22-
19+
import java.lang.reflect.Constructor;
2320
import java.time.Duration;
2421
import java.util.Collections;
2522
import java.util.HashMap;
@@ -62,14 +59,14 @@
6259
description = "If you would like to consume each message from Azure Event Hubs in real-time and create one execution per message, you can use the [io.kestra.plugin.azure.eventhubs.RealtimeTrigger](https://kestra.io/plugins/plugin-azure/triggers/io.kestra.plugin.azure.eventhubs.realtimetrigger) instead."
6360
)
6461

65-
@NoArgsConstructor
6662
@SuperBuilder
63+
@NoArgsConstructor
6764
@ToString
6865
@EqualsAndHashCode
6966
@Getter
7067
public class Trigger extends AbstractTrigger implements EventHubConsumerInterface, EventHubBatchConsumerInterface, PollingTriggerInterface, TriggerOutput<Consume.Output> {
68+
7169

72-
runContext.logger().info("Trigger started");
7370

7471

7572
// TRIGGER'S PROPERTIES
@@ -127,19 +124,28 @@ public class Trigger extends AbstractTrigger implements EventHubConsumerInterfac
127124
* {@inheritDoc}
128125
**/
129126
@Override
130-
public Optional<Execution> evaluate(ConditionContext conditionContext,
131-
TriggerContext context) throws Exception {
132-
RunContext runContext = conditionContext.getRunContext();
127+
public Optional<Execution> evaluate(ConditionContext conditionContext,
128+
TriggerContext context) throws Exception {
133129

134-
final Consume task = new Consume();
135-
final Consume.Output output = task.run(runContext, this);
130+
RunContext runContext = conditionContext.getRunContext();
136131

137-
if (output.getEventsCount() == 0) {
138-
return Optional.empty();
139-
}
132+
// Correct place for logger
133+
runContext.logger().info("Trigger started");
140134

141-
Execution execution = TriggerService.generateExecution(this, conditionContext, context, output);
135+
final Consume task = new Consume();
136+
final Consume.Output output = task.run(runContext, this);
142137

143-
return Optional.of(execution);
138+
if (output.getEventsCount() == 0) {
139+
return Optional.empty();
144140
}
145-
}
141+
142+
Execution execution = TriggerService.generateExecution(
143+
this,
144+
conditionContext,
145+
context,
146+
output
147+
);
148+
149+
return Optional.of(execution);
150+
151+
}

0 commit comments

Comments
 (0)