Search in sources :

Example 56 with Log

use of org.neo4j.logging.Log in project neo4j by neo4j.

the class HttpHeaderUtilsTest method defaultValueWhenCustomTransactionTimeoutNotSpecified.

@Test
void defaultValueWhenCustomTransactionTimeoutNotSpecified() {
    Log log = logProvider.getLog(HttpServletRequest.class);
    long transactionTimeout = getTransactionTimeout(request, log);
    assertEquals(0, transactionTimeout, "Transaction timeout not specified.");
    assertThat(logProvider).doesNotHaveAnyLogs();
}
Also used : Log(org.neo4j.logging.Log) Test(org.junit.jupiter.api.Test)

Example 57 with Log

use of org.neo4j.logging.Log in project neo4j by neo4j.

the class IndexSamplingControllerFactory method createIndexRecoveryCondition.

private RecoveryCondition createIndexRecoveryCondition(final LogProvider logProvider, final TokenNameLookup tokenNameLookup) {
    return new RecoveryCondition() {

        private final Log log = logProvider.getLog(IndexSamplingController.class);

        @Override
        public boolean test(IndexDescriptor descriptor) {
            IndexSample indexSample = indexStatisticsStore.indexSample(descriptor.getId());
            long samples = indexSample.sampleSize();
            long size = indexSample.indexSize();
            boolean empty = (samples == 0) || (size == 0);
            if (empty) {
                log.debug("Recovering index sampling for index %s", descriptor.schema().userDescription(tokenNameLookup));
            }
            return empty;
        }
    };
}
Also used : IndexSample(org.neo4j.kernel.api.index.IndexSample) Log(org.neo4j.logging.Log) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor)

Example 58 with Log

use of org.neo4j.logging.Log in project neo4j by neo4j.

the class ServerUserLogTest method logShouldRotateWhenConfigured.

@Test
void logShouldRotateWhenConfigured() throws Exception {
    // given
    NeoBootstrapper neoBootstrapper = getServerBootstrapper();
    Path dir = homeDir.homePath();
    Log logBeforeStart = neoBootstrapper.getLog();
    int maxArchives = 4;
    // when
    try {
        Map<String, String> configOverrides = stringMap(store_user_log_to_stdout.name(), FALSE, store_user_log_rotation_threshold.name(), "16", store_user_log_max_archives.name(), Integer.toString(maxArchives));
        configOverrides.putAll(connectorsConfig());
        int returnCode = neoBootstrapper.start(dir, configOverrides);
        // then
        assertEquals(OK, returnCode);
        assertThat(neoBootstrapper.getLog()).isNotSameAs(logBeforeStart);
        assertTrue(neoBootstrapper.isRunning());
        // when we forcibly log some more stuff
        do {
            neoBootstrapper.getLog().info("testing 123. This string should contain more than 16 bytes\n");
            Thread.sleep(2000);
        } while (allUserLogFiles(dir).size() <= 4);
    } finally {
        // stop the server so that resources are released and test teardown isn't flaky
        neoBootstrapper.stop();
    }
    // then no exceptions are thrown and
    assertThat(getStdOut()).isEmpty();
    assertTrue(Files.exists(getUserLogFileLocation(dir)));
    assertThat(readUserLogFile(dir)).isNotEmpty();
    List<String> userLogFiles = allUserLogFiles(dir);
    assertThat(userLogFiles).contains("neo4j.log", "neo4j.log.1", "neo4j.log.2", "neo4j.log.3", "neo4j.log.4");
    assertEquals(maxArchives + 1, userLogFiles.size());
}
Also used : Path(java.nio.file.Path) Log(org.neo4j.logging.Log) Test(org.junit.jupiter.api.Test)

Example 59 with Log

use of org.neo4j.logging.Log in project neo4j by neo4j.

the class ServerUserLogTest method shouldLogToStdOutByDefault.

@Test
void shouldLogToStdOutByDefault() {
    // given
    NeoBootstrapper neoBootstrapper = getServerBootstrapper();
    Path dir = homeDir.homePath();
    Log logBeforeStart = neoBootstrapper.getLog();
    // when
    try {
        int returnCode = neoBootstrapper.start(dir, connectorsConfig());
        // then no exceptions are thrown and
        assertThat(getStdOut()).isNotEmpty();
        assertFalse(Files.exists(getUserLogFileLocation(dir)));
        // then no exceptions are thrown and
        assertEquals(OK, returnCode);
        assertTrue(neoBootstrapper.isRunning());
        assertThat(neoBootstrapper.getLog()).isNotSameAs(logBeforeStart);
        assertThat(getStdOut()).isNotEmpty();
        assertThat(getStdOut()).anyMatch(s -> s.contains("Started."));
    } finally {
        // stop the server so that resources are released and test teardown isn't flaky
        neoBootstrapper.stop();
    }
    assertFalse(Files.exists(getUserLogFileLocation(dir)));
}
Also used : Path(java.nio.file.Path) Log(org.neo4j.logging.Log) Test(org.junit.jupiter.api.Test)

Example 60 with Log

use of org.neo4j.logging.Log in project neo4j by neo4j.

the class CommunityWebContainerBuilder method build.

public TestWebContainer build() throws IOException {
    checkState(dataDir != null || !persistent, "Must specify path");
    final Path configFile = createConfigFiles();
    Log log = logProvider.getLog(getClass());
    Config config = Config.newBuilder().setDefaults(GraphDatabaseSettings.SERVER_DEFAULTS).fromFile(configFile).build();
    config.setLogger(log);
    return new TestWebContainer(build(config));
}
Also used : Path(java.nio.file.Path) Log(org.neo4j.logging.Log) SslPolicyConfig(org.neo4j.configuration.ssl.SslPolicyConfig) Config(org.neo4j.configuration.Config)

Aggregations

Log (org.neo4j.logging.Log)164 Test (org.junit.Test)60 NullLog (org.neo4j.logging.NullLog)53 Test (org.junit.jupiter.api.Test)50 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)24 Path (java.nio.file.Path)20 LogProvider (org.neo4j.logging.LogProvider)15 File (java.io.File)13 IOException (java.io.IOException)12 Map (java.util.Map)12 Config (org.neo4j.kernel.configuration.Config)10 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)10 PageCache (org.neo4j.io.pagecache.PageCache)9 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)8 NullLogProvider (org.neo4j.logging.NullLogProvider)7 HashMap (java.util.HashMap)6 Config (org.neo4j.configuration.Config)6 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)6 BasicContext (org.neo4j.kernel.api.proc.BasicContext)6 CallableProcedure (org.neo4j.kernel.api.procedure.CallableProcedure)6