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

Logstash module #2624

Merged
merged 1 commit into from
Jul 17, 2022
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 @@ -34,8 +34,6 @@ private GeneratorAction() {}

public static final String MONGOCK = "mongock";

public static final String LOGSTASH = "logstash";

public static final String DUMMY_FEATURE = "dummy-feature";

public static final String USER_AND_AUTHORITY_ENTITIES_POSTGRESQL = "user-and-authority-entities-postgresql";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,20 @@
package tech.jhipster.lite.generator.server.springboot.logging.logstash.application;

import org.springframework.stereotype.Service;
import tech.jhipster.lite.generator.project.domain.Project;
import tech.jhipster.lite.generator.server.springboot.logging.logstash.domain.LogstashService;
import tech.jhipster.lite.generator.server.springboot.logging.logstash.domain.LogstashModuleFactory;
import tech.jhipster.lite.module.domain.JHipsterModule;
import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties;

@Service
public class LogstashApplicationService {

private final LogstashService logstashService;
private final LogstashModuleFactory factory;

public LogstashApplicationService(LogstashService logstashService) {
this.logstashService = logstashService;
public LogstashApplicationService() {
factory = new LogstashModuleFactory();
}

public void init(Project project) {
logstashService.init(project);
}

public void addDependencies(Project project) {
logstashService.addDependencies(project);
}

public void addJavaFiles(Project project) {
logstashService.addJavaFiles(project);
}

public void addProperties(Project project) {
logstashService.addProperties(project);
}

public void addLoggerInConfiguration(Project project) {
logstashService.addLoggerInConfiguration(project);
public JHipsterModule buildModule(JHipsterModuleProperties properties) {
return factory.buildModule(properties);
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package tech.jhipster.lite.generator.server.springboot.logging.logstash.domain;

import static tech.jhipster.lite.module.domain.JHipsterModule.*;

import tech.jhipster.lite.error.domain.Assert;
import tech.jhipster.lite.module.domain.JHipsterModule;
import tech.jhipster.lite.module.domain.JHipsterSource;
import tech.jhipster.lite.module.domain.LogLevel;
import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties;

public class LogstashModuleFactory {

private static final JHipsterSource SOURCE = from("server/springboot/logging/logstash");

private static final String LOGSTASH_SECONDARY = "technical/infrastructure/secondary/logstash";

public JHipsterModule buildModule(JHipsterModuleProperties properties) {
Assert.notNull("properties", properties);

String packagePath = properties.basePackage().path();

//@formatter:off
return moduleBuilder(properties)
.javaDependencies()
.addDependency(groupId("net.logstash.logback"), artifactId("logstash-logback-encoder"), versionSlug("logstash-logback-encoder"))
.and()
.files()
.batch(SOURCE.append("main"), toSrcMainJava().append(packagePath).append(LOGSTASH_SECONDARY))
.template("LogstashTcpConfiguration.java")
.template("LogstashTcpLifeCycle.java")
.template("LogstashTcpProperties.java")
.and()
.batch(SOURCE.append("test"), toSrcTestJava().append(packagePath).append(LOGSTASH_SECONDARY))
.template("LogstashTcpConfigurationIT.java")
.template("LogstashTcpConfigurationTest.java")
.template("LogstashTcpLifeCycleTest.java")
.template("LogstashTcpPropertiesTest.java")
.and()
.and()
.springMainProperties()
.set(propertyKey("application.logging.logstash.tcp.enabled"), propertyValue("false"))
.set(propertyKey("application.logging.logstash.tcp.host"), propertyValue("localhost"))
.set(propertyKey("application.logging.logstash.tcp.port"), propertyValue("5000"))
.set(propertyKey("application.logging.logstash.tcp.ring-buffer-size"), propertyValue("8192"))
.set(propertyKey("application.logging.logstash.tcp.shutdown_grace_period"), propertyValue("PT1M"))
.and()
.springTestLogger("net.logstash.logback", LogLevel.ERROR)
.springTestLogger("org.jboss.logging", LogLevel.WARN)
.build();
//@formatter:on
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package tech.jhipster.lite.generator.server.springboot.logging.logstash.infrastructure.primary;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import tech.jhipster.lite.generator.server.springboot.logging.logstash.application.LogstashApplicationService;
import tech.jhipster.lite.module.domain.properties.JHipsterModulePropertiesDefinition;
import tech.jhipster.lite.module.infrastructure.primary.JHipsterModuleApiDoc;
import tech.jhipster.lite.module.infrastructure.primary.JHipsterModuleResource;

@Configuration
class LogstashModuleConfiguration {

@Bean
JHipsterModuleResource logstashModule(LogstashApplicationService logstash) {
return JHipsterModuleResource
.builder()
.legacyUrl("/api/servers/spring-boot/log-tools/logstash")
.slug("logstash")
.propertiesDefinition(JHipsterModulePropertiesDefinition.builder().addBasePackage().addIndentation().build())
.apiDoc(new JHipsterModuleApiDoc("Spring Boot - Logging", "Add Logstash TCP appender"))
.tags("server", "logstash", "spring", "spring-boot")
.factory(logstash::buildModule);
}
}

This file was deleted.

7 changes: 7 additions & 0 deletions src/test/features/logstash.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Feature: logstash module

Scenario: Should apply logstash module
When I apply "logstash" module to default project with maven file
| packageName | tech.jhipster.chips |
Then I should have files in "src/main/java/tech/jhipster/chips/technical/infrastructure/secondary/logstash"
| LogstashTcpConfiguration.java |
Loading