Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.
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
504 changes: 227 additions & 277 deletions libraries/bot-builder/pom.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.microsoft.bot.schema.models.Activity;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.ForkJoinPool;
Expand All @@ -23,7 +23,7 @@ public class TraceTranscriptLogger implements TranscriptLogger {
// https://github.com/FasterXML/jackson-databind/wiki/Serialization-Features
private static ObjectMapper mapper = new ObjectMapper()
.enable(SerializationFeature.INDENT_OUTPUT);
private static final Logger logger = LogManager.getLogger("HelloWorld");
private static final Logger logger = LoggerFactory.getLogger(TraceTranscriptLogger.class);

ForkJoinPool.ForkJoinWorkerThreadFactory factory = new ForkJoinPool.ForkJoinWorkerThreadFactory()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import com.microsoft.bot.schema.models.ActivityTypes;
import com.microsoft.bot.schema.models.ResourceResponse;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;

Expand All @@ -34,8 +34,8 @@ public class TranscriptLoggerMiddleware implements Middleware {
mapper.findAndRegisterModules();
}

private TranscriptLogger logger;
private static final Logger log4j = LogManager.getLogger("BotFx");
private TranscriptLogger transcriptLogger;
private static final Logger logger = LoggerFactory.getLogger(TranscriptLoggerMiddleware.class);

private Queue<Activity> transcript = new ConcurrentLinkedQueue<Activity>();

Expand All @@ -48,7 +48,7 @@ public TranscriptLoggerMiddleware(TranscriptLogger transcriptLogger) {
if (transcriptLogger == null)
throw new NullPointerException("TranscriptLoggerMiddleware requires a ITranscriptLogger implementation. ");

this.logger = transcriptLogger;
this.transcriptLogger = transcriptLogger;

}

Expand Down Expand Up @@ -134,12 +134,12 @@ public void OnTurn(TurnContext context, NextDelegate next) throws Exception {

try {
if (nextDel != null) {
log4j.error(String.format("Transcript logActivity next delegate: %s)", nextDel));
logger.error(String.format("Transcript logActivity next delegate: %s)", nextDel));
nextDel.run();
}
} catch (Exception e) {
e.printStackTrace();
log4j.error(String.format("Transcript logActivity failed with %s (next delegate: %s)", e.toString(), nextDel));
logger.error(String.format("Transcript logActivity failed with %s (next delegate: %s)", e.toString(), nextDel));
throw new RuntimeException(String.format("Transcript logActivity failed with %s", e.getMessage()));

}
Expand Down Expand Up @@ -169,9 +169,9 @@ public void OnTurn(TurnContext context, NextDelegate next) throws Exception {
while (!transcript.isEmpty()) {
Activity activity = transcript.poll();
try {
this.logger.LogActivityAsync(activity);
this.transcriptLogger.LogActivityAsync(activity);
} catch (RuntimeException err) {
log4j.error(String.format("Transcript poll failed : %1$s", err));
logger.error(String.format("Transcript poll failed : %1$s", err));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@
import com.fasterxml.jackson.datatype.joda.JodaModule;
import com.microsoft.bot.builder.adapters.TestAdapter;
import com.microsoft.bot.builder.adapters.TestFlow;
import com.microsoft.bot.builder.dialogs.Dialog;
import com.microsoft.bot.schema.ActivityImpl;
import com.microsoft.bot.schema.models.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.Assert;
import org.junit.Test;

Expand Down Expand Up @@ -99,7 +96,6 @@ public void next() throws Exception {

@Test
public final void Transcript_LogActivities() throws ExecutionException, InterruptedException {
Logger logger = LogManager.getLogger(Dialog.class);
MemoryTranscriptStore transcriptStore = new MemoryTranscriptStore();
TestAdapter adapter = (new TestAdapter()).Use(new TranscriptLoggerMiddleware(transcriptStore));
final String[] conversationId = {null};
Expand Down Expand Up @@ -206,7 +202,7 @@ public void Transcript_LogUpdateActivities() throws InterruptedException, Execut
Assert.assertEquals(4, pagedResult.getItems().length);
Assert.assertEquals("foo", ((Activity)pagedResult.getItems()[0]).text());
Assert.assertEquals( "response", ((Activity)pagedResult.getItems()[1]).text());
// TODO: Fix the following 3 asserts so they work correctly. They succeed in the travis builds and fail in the
// TODO: Fix the following 3 asserts so they work correctly. They succeed in the travis builds and fail in the
// BotBuilder-Java 4.0 master build.
//Assert.assertEquals( "new response", ((Activity)pagedResult.getItems()[2]).text());
//Assert.assertEquals("update", ((Activity)pagedResult.getItems()[3]).text());
Expand Down
Loading