aboutsummaryrefslogtreecommitdiffstats
path: root/vespalog/src/test/java/com/yahoo/log/LogFileDbTest.java
blob: 4e03849b5b2678a311730ed67a2f8160ef3d0671 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.log;

import java.io.File;
import static com.yahoo.vespa.defaults.Defaults.getDefaults;

import com.yahoo.io.IOUtils;
import org.junit.Test;

import static org.junit.Assert.assertTrue;

/**
 * @author arnej
 */
public class LogFileDbTest {

    @Test
    public void canSave() {
        System.err.println("VH: "+System.getenv("VESPA_HOME"));
        File dir = new File(getDefaults().underVespaHome(LogFileDb.DBDIR));
        assertTrue(!dir.exists() || IOUtils.recursiveDeleteDir(dir));
        System.err.println("using directory: "+dir);
        File extraDir = new File(getDefaults().underVespaHome("logs/extra"));
        assertTrue(!extraDir.exists() || IOUtils.recursiveDeleteDir(extraDir));
        String fn = getDefaults().underVespaHome("logs/extra/foo-bar.log");
        assertTrue(LogFileDb.nowLoggingTo(fn));
        fn = getDefaults().underVespaHome("logs/extra/stamped-1.log");
        assertTrue(LogFileDb.nowLoggingTo(fn));
    }
}