use of org.neo4j.logging.Logger in project neo4j by neo4j.
the class GraphDatabaseFacadeFactory method initFacade.
/**
* Instantiate a graph database given configuration, dependencies, and a custom implementation of {@link org
* .neo4j.kernel.impl.factory.GraphDatabaseFacade}.
*
* @param storeDir the directory where the Neo4j data store is located
* @param config configuration
* @param dependencies the dependencies required to construct the {@link GraphDatabaseFacade}
* @param graphDatabaseFacade the already created facade which needs initialisation
* @return the initialised {@link GraphDatabaseFacade}
*/
public GraphDatabaseFacade initFacade(File storeDir, Config config, final Dependencies dependencies, final GraphDatabaseFacade graphDatabaseFacade) {
PlatformModule platform = createPlatform(storeDir, config, dependencies, graphDatabaseFacade);
EditionModule edition = editionFactory.apply(platform);
AtomicReference<QueryExecutionEngine> queryEngine = new AtomicReference<>(noEngine());
final DataSourceModule dataSource = createDataSource(platform, edition, queryEngine::get);
Logger msgLog = platform.logging.getInternalLog(getClass()).infoLogger();
CoreAPIAvailabilityGuard coreAPIAvailabilityGuard = edition.coreAPIAvailabilityGuard;
ClassicCoreSPI spi = new ClassicCoreSPI(platform, dataSource, msgLog, coreAPIAvailabilityGuard);
graphDatabaseFacade.init(spi, dataSource.guard, dataSource.threadToTransactionBridge, platform.config);
// Start it
platform.dataSourceManager.addListener(new DataSourceManager.Listener() {
private QueryExecutionEngine engine;
@Override
public void registered(NeoStoreDataSource dataSource) {
if (engine == null) {
engine = QueryEngineProvider.initialize(platform.dependencies, platform.graphDatabaseFacade, dependencies.executionEngines());
}
queryEngine.set(engine);
}
@Override
public void unregistered(NeoStoreDataSource dataSource) {
queryEngine.set(noEngine());
}
});
Throwable error = null;
try {
// Done after create to avoid a redundant
// "database is now unavailable"
enableAvailabilityLogging(platform.availabilityGuard, msgLog);
platform.life.start();
} catch (final Throwable throwable) {
error = new RuntimeException("Error starting " + getClass().getName() + ", " + platform.storeDir, throwable);
} finally {
if (error != null) {
try {
graphDatabaseFacade.shutdown();
} catch (Throwable shutdownError) {
error = Exceptions.withSuppressed(shutdownError, error);
}
}
}
if (error != null) {
msgLog.log("Failed to start database", error);
throw Exceptions.launderedException(error);
}
return graphDatabaseFacade;
}
use of org.neo4j.logging.Logger in project neo4j by neo4j.
the class LoggingListenerTest method shouldBeAbleToListenToMultipleMonitors.
@Test
public void shouldBeAbleToListenToMultipleMonitors() {
// Given
Monitors monitors = new Monitors();
AssertableLogProvider logProvider = new AssertableLogProvider();
InterestingMonitor1 aMonitor = monitors.newMonitor(InterestingMonitor1.class);
InterestingMonitor2 bMonitor = monitors.newMonitor(InterestingMonitor2.class);
Map<Class<?>, Logger> classes = new HashMap<>(2);
classes.put(InterestingMonitor1.class, logProvider.getLog(InterestingMonitor1.class).debugLogger());
classes.put(InterestingMonitor2.class, logProvider.getLog(InterestingMonitor2.class).warnLogger());
LoggingListener listener = new LoggingListener(classes);
monitors.addMonitorListener(listener, listener.predicate);
// When
aMonitor.touch();
bMonitor.touch();
// Then
logProvider.assertExactly(inLog(InterestingMonitor1.class).debug("touch()"), inLog(InterestingMonitor2.class).warn("touch()"));
}
use of org.neo4j.logging.Logger in project neo4j by neo4j.
the class JULBridge method publish.
@Override
public void publish(LogRecord record) {
if (record == null) {
return;
}
String message = getMessage(record);
if (message == null) {
return;
}
String context = record.getLoggerName();
Log log = getLog((context != null) ? context : UNKNOWN_LOGGER_NAME);
Logger logger = getLogger(record, log);
Throwable throwable = record.getThrown();
if (throwable == null) {
logger.log(message);
} else {
logger.log(message, throwable);
}
}
Aggregations