Skip to content

Commit

Permalink
[branch ch52131] Log warning when snitches id is not set (#4)
Browse files Browse the repository at this point in the history
* Log warning when snitches id is not set

* removed unused import
  • Loading branch information
musketyr authored Oct 7, 2021
1 parent 4adb0f5 commit 482e72b
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
package com.agorapulse.micronaut.snitch;

import io.micronaut.context.annotation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.inject.Named;
import javax.inject.Singleton;
Expand All @@ -28,6 +30,8 @@
@Factory
public class DefaultSnitchFactory {

private static final Logger LOGGER = LoggerFactory.getLogger(DefaultSnitchFactory.class);

@EachBean(SnitchJobConfiguration.class)
@Requires(property = "snitches.jobs")
public SnitchService snitchService(SnitchClient client, SnitchJobConfiguration configuration) {
Expand All @@ -49,7 +53,11 @@ public SnitchService defaultSnitchService(SnitchClient client, @Value("${snitche
@Singleton
@Named("default")
@Requires(missingProperty = "snitches.id")
public SnitchService noopSnitchService() {
public SnitchService noopSnitchService(@Value("${snitches.disabled:false}") boolean snitchesDisabled) {
if (!snitchesDisabled) {
LOGGER.warn("Micronaut Snitch is not configured! Please set snitches.id configuration property or set snitches.disabled to true to ignore this warning.");
}

return NoopSnitchService.INSTANCE;
}

Expand Down

0 comments on commit 482e72b

Please sign in to comment.