blob: e94068fa988e6f542c904b69f57228a9dbea4f70 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.logging;
import com.yahoo.io.IOUtils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Base64;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
public class LocalDiskLoggerTest {
@TempDir
Path tempDir;
@Test
public void testLocalDiskLogger() throws InterruptedException, IOException {
File logFile = tempDir.resolve("localdisklogger.log").toFile();
LocalDiskLoggerConfig.Builder builder = new LocalDiskLoggerConfig.Builder();
builder.path(logFile.getAbsolutePath());
LocalDiskLogger logger = new LocalDiskLogger(builder.build());
logger.newEntry()
.blob("my entry blob content".getBytes())
.track("my-track")
.send();
logger.deconstruct();
String test = IOUtils.readAll(new FileReader(logFile));
assertTrue(test.contains(Base64.getEncoder().encodeToString("my entry blob content".getBytes())));
assertTrue(test.contains("my-track"));
}
}
|