Skip to content

Commit

Permalink
Enable CheckStyle Plugin in structured-event-log module (apache#14483)
Browse files Browse the repository at this point in the history
  • Loading branch information
liudezhi2098 authored Feb 28, 2022
1 parent a9fe9ef commit 99fb98b
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 11 deletions.
19 changes: 19 additions & 0 deletions structured-event-log/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,23 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<id>checkstyle</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@Retention(value=RetentionPolicy.RUNTIME)
@Retention(value = RetentionPolicy.RUNTIME)
public @interface EventGroup {
String component();
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public EventResources resource(String key, Object value) {

@Override
public EventResources resource(String key, Supplier<String> value) {
resource(key, (Object)value);
resource(key, (Object) value);
return this;
}

Expand Down Expand Up @@ -77,7 +77,7 @@ public static void forEach(List<Object> list, BiConsumer<String, String> process
String key = String.valueOf(list.get(i));
Object value = list.get(i + 1);
if (value instanceof Supplier) {
value = ((Supplier<?>)value).get();
value = ((Supplier<?>) value).get();
}
process.accept(key, String.valueOf(value));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public interface StructuredEventLog {
/**
* Create a new logger object, from which root events can be created.
*/
public static StructuredEventLog newLogger() {
static StructuredEventLog newLogger() {
return Slf4jStructuredEventLog.INSTANCE;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://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 org.apache.pulsar.structuredeventlog;
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,13 @@
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;

import org.apache.pulsar.structuredeventlog.Event;
import org.apache.pulsar.structuredeventlog.EventGroup;
import org.apache.pulsar.structuredeventlog.EventResources;
import org.apache.pulsar.structuredeventlog.EventResourcesImpl;

import org.slf4j.MDC;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;

class Slf4jEvent implements Event {
private static final ThreadLocal<Map<Object, Logger>> loggersTLS = ThreadLocal.withInitial(() -> new HashMap<>());
Expand Down Expand Up @@ -89,7 +87,7 @@ public Event sampled(Object samplingKey, int duration, TimeUnit unit) {
@Override
public Event resources(EventResources other) {
if (other instanceof EventResourcesImpl) {
this.resources.copyFrom((EventResourcesImpl)other);
this.resources.copyFrom((EventResourcesImpl) other);
}
return this;
}
Expand All @@ -115,7 +113,7 @@ public Event attr(String key, Object value) {

@Override
public Event attr(String key, Supplier<String> value) {
this.attr(key, (Object)value);
this.attr(key, (Object) value);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@
package org.apache.pulsar.structuredeventlog.slf4j;

import java.time.Clock;

import org.apache.pulsar.structuredeventlog.Event;
import org.apache.pulsar.structuredeventlog.EventResources;
import org.apache.pulsar.structuredeventlog.EventResourcesImpl;
import org.apache.pulsar.structuredeventlog.StructuredEventLog;

public class Slf4jStructuredEventLog implements StructuredEventLog {
public static Slf4jStructuredEventLog INSTANCE = new Slf4jStructuredEventLog();
public static final Slf4jStructuredEventLog INSTANCE = new Slf4jStructuredEventLog();
// Visible for testing
Clock clock = Clock.systemUTC();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://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 org.apache.pulsar.structuredeventlog.slf4j;

0 comments on commit 99fb98b

Please sign in to comment.