Search in sources :

Example 21 with Log

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

the class PlatformModule method createPageCache.

protected PageCache createPageCache(FileSystemAbstraction fileSystem, Config config, LogService logging, Tracers tracers) {
    Log pageCacheLog = logging.getInternalLog(PageCache.class);
    ConfiguringPageCacheFactory pageCacheFactory = new ConfiguringPageCacheFactory(fileSystem, config, tracers.pageCacheTracer, tracers.pageCursorTracerSupplier, pageCacheLog);
    PageCache pageCache = pageCacheFactory.getOrCreatePageCache();
    if (config.get(GraphDatabaseSettings.dump_configuration)) {
        pageCacheFactory.dumpConfiguration();
    }
    return pageCache;
}
Also used : Log(org.neo4j.logging.Log) ConfiguringPageCacheFactory(org.neo4j.kernel.impl.pagecache.ConfiguringPageCacheFactory) PageCache(org.neo4j.io.pagecache.PageCache)

Example 22 with Log

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

the class ReflectiveUserFunctionTest method shouldInjectLogging.

@Test
public void shouldInjectLogging() throws KernelException {
    // Given
    Log log = spy(Log.class);
    components.register(Log.class, (ctx) -> log);
    CallableUserFunction function = procedureCompiler.compileFunction(LoggingFunction.class).get(0);
    // When
    function.apply(new BasicContext(), new Object[0]);
    // Then
    verify(log).debug("1");
    verify(log).info("2");
    verify(log).warn("3");
    verify(log).error("4");
}
Also used : CallableUserFunction(org.neo4j.kernel.api.proc.CallableUserFunction) Log(org.neo4j.logging.Log) NullLog(org.neo4j.logging.NullLog) BasicContext(org.neo4j.kernel.api.proc.BasicContext) Test(org.junit.Test)

Example 23 with Log

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

the class ReflectiveUserFunctionTest method shouldSupportFunctionDeprecation.

@Test
public void shouldSupportFunctionDeprecation() throws Throwable {
    // Given
    Log log = mock(Log.class);
    ReflectiveProcedureCompiler procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), components, new ComponentRegistry(), log, ProcedureConfig.DEFAULT);
    // When
    List<CallableUserFunction> funcs = procedureCompiler.compileFunction(FunctionWithDeprecation.class);
    // Then
    verify(log).warn("Use of @UserFunction(deprecatedBy) without @Deprecated in org.neo4j.kernel.impl.proc.badFunc");
    verifyNoMoreInteractions(log);
    for (CallableUserFunction func : funcs) {
        String name = func.signature().name().name();
        func.apply(new BasicContext(), new Object[0]);
        switch(name) {
            case "newFunc":
                assertFalse("Should not be deprecated", func.signature().deprecated().isPresent());
                break;
            case "oldFunc":
            case "badFunc":
                assertTrue("Should be deprecated", func.signature().deprecated().isPresent());
                assertThat(func.signature().deprecated().get(), equalTo("newFunc"));
                break;
            default:
                fail("Unexpected function: " + name);
        }
    }
}
Also used : CallableUserFunction(org.neo4j.kernel.api.proc.CallableUserFunction) Log(org.neo4j.logging.Log) NullLog(org.neo4j.logging.NullLog) BasicContext(org.neo4j.kernel.api.proc.BasicContext) Test(org.junit.Test)

Example 24 with Log

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

the class ReflectiveProcedureTest method shouldLoadWhiteListedProcedure.

@Test
public void shouldLoadWhiteListedProcedure() throws Throwable {
    // Given
    ProcedureConfig config = new ProcedureConfig(Config.defaults().with(genericMap(procedure_whitelist.name(), "org.neo4j.kernel.impl.proc.listCoolPeople")));
    Log log = mock(Log.class);
    ReflectiveProcedureCompiler procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), components, components, log, config);
    // When
    CallableProcedure proc = procedureCompiler.compileProcedure(SingleReadOnlyProcedure.class, Optional.empty(), false).get(0);
    // When
    RawIterator<Object[], ProcedureException> result = proc.apply(new BasicContext(), new Object[0]);
    // Then
    assertEquals(result.next()[0], "Bonnie");
}
Also used : Log(org.neo4j.logging.Log) NullLog(org.neo4j.logging.NullLog) BasicContext(org.neo4j.kernel.api.proc.BasicContext) CallableProcedure(org.neo4j.kernel.api.proc.CallableProcedure) ProcedureException(org.neo4j.kernel.api.exceptions.ProcedureException) Test(org.junit.Test)

Example 25 with Log

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

the class ReflectiveUserAggregationFunctionTest method shouldSupportFunctionDeprecation.

@Test
public void shouldSupportFunctionDeprecation() throws Throwable {
    // Given
    Log log = mock(Log.class);
    ReflectiveProcedureCompiler procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), components, new ComponentRegistry(), log, ProcedureConfig.DEFAULT);
    // When
    List<CallableUserAggregationFunction> funcs = procedureCompiler.compileAggregationFunction(FunctionWithDeprecation.class);
    // Then
    verify(log).warn("Use of @UserAggregationFunction(deprecatedBy) without @Deprecated in org.neo4j.kernel.impl.proc.badFunc");
    verifyNoMoreInteractions(log);
    for (CallableUserAggregationFunction func : funcs) {
        String name = func.signature().name().name();
        func.create(new BasicContext());
        switch(name) {
            case "newFunc":
                assertFalse("Should not be deprecated", func.signature().deprecated().isPresent());
                break;
            case "oldFunc":
            case "badFunc":
                assertTrue("Should be deprecated", func.signature().deprecated().isPresent());
                assertThat(func.signature().deprecated().get(), equalTo("newFunc"));
                break;
            default:
                fail("Unexpected function: " + name);
        }
    }
}
Also used : CallableUserAggregationFunction(org.neo4j.kernel.api.proc.CallableUserAggregationFunction) Log(org.neo4j.logging.Log) NullLog(org.neo4j.logging.NullLog) BasicContext(org.neo4j.kernel.api.proc.BasicContext) Test(org.junit.Test)

Aggregations

Log (org.neo4j.logging.Log)91 Test (org.junit.Test)63 NullLog (org.neo4j.logging.NullLog)29 File (java.io.File)12 LogProvider (org.neo4j.logging.LogProvider)12 IOException (java.io.IOException)9 Config (org.neo4j.kernel.configuration.Config)9 BasicContext (org.neo4j.kernel.api.proc.BasicContext)8 Map (java.util.Map)7 NullLogProvider (org.neo4j.logging.NullLogProvider)7 PageCache (org.neo4j.io.pagecache.PageCache)6 CallableProcedure (org.neo4j.kernel.api.proc.CallableProcedure)6 LogService (org.neo4j.kernel.impl.logging.LogService)6 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)5 Monitors (org.neo4j.kernel.monitoring.Monitors)5 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)4 Before (org.junit.Before)4 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)4 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)4