Skip to content

Commit

Permalink
Remove log4j dependency and debug parameter (#238)
Browse files Browse the repository at this point in the history
Fixes #162
  • Loading branch information
philipp94831 authored Jul 24, 2024
1 parent 8dc843c commit 9b67bc7
Show file tree
Hide file tree
Showing 13 changed files with 6 additions and 46 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ The following configuration options are available:

- `--volatile-group-instance-id`: Whether the group instance id is volatile, i.e., it will change on a Streams shutdown.

- `--debug`: Configure logging to debug

Additionally, the following commands are available:

- `clean`: Reset the Kafka Streams application. Additionally, delete the consumer group and all output and intermediate
Expand Down Expand Up @@ -188,8 +186,6 @@ The following configuration options are available:

- `--extra-output-topics`: Additional named output topics (`String=String>[,<String=String>...]`)

- `--debug`: Configure logging to debug

Additionally, the following commands are available:

- `clean`: Delete all output topics associated with the Kafka Producer application.
Expand Down
4 changes: 0 additions & 4 deletions charts/producer-app-cleanup-job/templates/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ spec:
- name: "{{ .Values.configurationEnvPrefix }}_SCHEMA_REGISTRY_URL"
value: {{ .Values.streams.schemaRegistryUrl | quote }}
{{- end }}
{{- if hasKey .Values "debug" }}
- name: "{{ .Values.configurationEnvPrefix }}_DEBUG"
value: {{ .Values.debug | quote }}
{{- end }}
{{- if hasKey .Values.streams "outputTopic" }}
- name: "{{ .Values.configurationEnvPrefix }}_OUTPUT_TOPIC"
value: {{ .Values.streams.outputTopic | quote }}
Expand Down
2 changes: 0 additions & 2 deletions charts/producer-app-cleanup-job/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ streams:
commandLine: {}
# MY_CLI_PARAM: "foo-bar"

debug: false

env: {}
# MY_ENV_VARIABLE: foo-bar

Expand Down
1 change: 0 additions & 1 deletion charts/producer-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ Alternatively, a YAML file that specifies the values for the parameters can be p
|--------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|
| `configurationEnvPrefix` | Prefix for environment variables to use that should be parsed as command line arguments. | `APP` |
| `commandLine` | Map of command line arguments passed to the producer app. | `{}` |
| `debug` | Configure logging to debug | `false` |
| `env` | Custom environment variables | `{}` |
| `secrets` | Custom secret environment variables. Prefix with `configurationEnvPrefix` in order to pass secrets to command line or prefix with `KAFKA_` to pass secrets to Kafka Streams configuration. E.g., `APP_MY_PARAM` would be passed as `--my-param` and `KAFKA_MAX_POLL_TIMEOUT_MS` would be translated to `max.poll.timeout.ms`. | `{}` |
| `secretRefs` | Inject existing secrets as environment variables. Map key is used as environment variable name. Value consists of secret `name` and `key`. | `{}` |
Expand Down
4 changes: 0 additions & 4 deletions charts/producer-app/templates/pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ spec:
- name: "{{ .Values.configurationEnvPrefix }}_SCHEMA_REGISTRY_URL"
value: {{ .Values.streams.schemaRegistryUrl | quote }}
{{- end }}
{{- if hasKey .Values "debug" }}
- name: "{{ .Values.configurationEnvPrefix }}_DEBUG"
value: {{ .Values.debug | quote }}
{{- end }}
{{- if hasKey .Values.streams "outputTopic" }}
- name: "{{ .Values.configurationEnvPrefix }}_OUTPUT_TOPIC"
value: {{ .Values.streams.outputTopic | quote }}
Expand Down
2 changes: 0 additions & 2 deletions charts/producer-app/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ streams:
commandLine: {}
# MY_CLI_PARAM: "foo-bar"

debug: false

env: {}
# MY_ENV_VARIABLE: foo-bar

Expand Down
4 changes: 0 additions & 4 deletions charts/streams-app-cleanup-job/templates/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ spec:
- name: "{{ .Values.configurationEnvPrefix }}_SCHEMA_REGISTRY_URL"
value: {{ .Values.streams.schemaRegistryUrl | quote }}
{{- end }}
{{- if hasKey .Values "debug" }}
- name: "{{ .Values.configurationEnvPrefix }}_DEBUG"
value: {{ .Values.debug | quote }}
{{- end }}
{{- if and (hasKey .Values.streams "inputTopics") (.Values.streams.inputTopics) }}
- name: "{{ .Values.configurationEnvPrefix }}_INPUT_TOPICS"
value: {{ .Values.streams.inputTopics | join "," | quote }}
Expand Down
2 changes: 0 additions & 2 deletions charts/streams-app-cleanup-job/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ streams:
commandLine: {}
# MY_CLI_PARAM: "foo-bar"

debug: false

env: {}
# MY_ENV_VARIABLE: foo-bar
#
Expand Down
1 change: 0 additions & 1 deletion charts/streams-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ Alternatively, a YAML file that specifies the values for the parameters can be p
|--------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|
| `configurationEnvPrefix` | Prefix for environment variables to use that should be parsed as command line arguments. | `APP` |
| `commandLine` | Map of command line arguments passed to the streams app. | `{}` |
| `debug` | Configure logging to debug | `false` |
| `env` | Custom environment variables | `{}` |
| `secrets` | Custom secret environment variables. Prefix with `configurationEnvPrefix` in order to pass secrets to command line or prefix with `KAFKA_` to pass secrets to Kafka Streams configuration. E.g., `APP_MY_PARAM` would be passed as `--my-param` and `KAFKA_MAX_POLL_TIMEOUT_MS` would be translated to `max.poll.timeout.ms`. | `{}` |
| `secretRefs` | Inject existing secrets as environment variables. Map key is used as environment variable name. Value consists of secret `name` and `key`. | `{}` |
Expand Down
4 changes: 0 additions & 4 deletions charts/streams-app/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,6 @@ spec:
- name: "{{ .Values.configurationEnvPrefix }}_SCHEMA_REGISTRY_URL"
value: {{ .Values.streams.schemaRegistryUrl | quote }}
{{- end }}
{{- if hasKey .Values "debug" }}
- name: "{{ .Values.configurationEnvPrefix }}_DEBUG"
value: {{ .Values.debug | quote }}
{{- end }}
{{- if and (hasKey .Values.streams "inputTopics") (.Values.streams.inputTopics) }}
- name: "{{ .Values.configurationEnvPrefix }}_INPUT_TOPICS"
value: {{ .Values.streams.inputTopics | join "," | quote }}
Expand Down
2 changes: 0 additions & 2 deletions charts/streams-app/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ streams:
commandLine: {}
# MY_CLI_PARAM: "foo-bar"

debug: false

env: {}
# MY_ENV_VARIABLE: foo-bar

Expand Down
5 changes: 2 additions & 3 deletions streams-bootstrap-cli/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ plugins {
dependencies {
api(project(":streams-bootstrap-core"))
api(group = "info.picocli", name = "picocli", version = "4.7.5")
val log4jVersion: String by project
implementation(group = "org.apache.logging.log4j", name = "log4j-core", version = log4jVersion)
implementation(group = "org.apache.logging.log4j", name = "log4j-slf4j2-impl", version = log4jVersion)

val junitVersion: String by project
testRuntimeOnly(group = "org.junit.jupiter", name = "junit-jupiter-engine", version = junitVersion)
Expand All @@ -31,4 +28,6 @@ dependencies {
name = "schema-registry-mock-junit5",
version = fluentKafkaVersion
)
val log4jVersion: String by project
testImplementation(group = "org.apache.logging.log4j", name = "log4j-slf4j2-impl", version = log4jVersion)
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
import lombok.Setter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.config.Configurator;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.ParseResult;
Expand All @@ -56,7 +54,6 @@
* <li>{@link #outputTopic}</li>
* <li>{@link #extraOutputTopics}</li>
* <li>{@link #brokers}</li>
* <li>{@link #debug}</li>
* <li>{@link #schemaRegistryUrl}</li>
* <li>{@link #kafkaConfig}</li>
* </ul>
Expand Down Expand Up @@ -92,8 +89,6 @@ public abstract class KafkaApplication<R extends Runner, CR extends CleanUpRunne
private Map<String, String> extraOutputTopics = emptyMap();
@CommandLine.Option(names = "--brokers", required = true, description = "Broker addresses to connect to")
private String brokers;
@CommandLine.Option(names = "--debug", arity = "0..1", description = "Configure logging to debug")
private boolean debug;
@CommandLine.Option(names = "--schema-registry-url", description = "URL of Schema Registry")
private String schemaRegistryUrl;
@CommandLine.Option(names = "--kafka-config", split = ",", description = "Additional Kafka properties")
Expand Down Expand Up @@ -299,20 +294,16 @@ public final CleanableApp<CR> createCleanableApp() {
protected abstract CA createConfiguredApp(final A app, AppConfiguration<T> configuration);

/**
* Configure application when running in debug mode. By default, Log4j2 log level is configured to debug for
* {@code com.bakdata} and the applications package.
* Called before starting the application, e.g., invoking {@link #run()}
*/
protected void configureDebug() {
Configurator.setLevel("com.bakdata", Level.DEBUG);
Configurator.setLevel(this.getClass().getPackageName(), Level.DEBUG);
protected void onApplicationStart() {
// do nothing by default
}

private void startApplication() {
Runtime.getRuntime().addShutdownHook(new Thread(this::close));
this.onApplicationStart();
log.info("Starting application");
if (this.debug) {
this.configureDebug();
}
log.debug("Starting application: {}", this);
}

Expand Down

0 comments on commit 9b67bc7

Please sign in to comment.