use of org.neo4j.kernel.monitoring.Monitors in project neo4j by neo4j.
the class LoggingListenerTest method shouldBeAbleToOutputMultipleMethodArguments.
@Test
public void shouldBeAbleToOutputMultipleMethodArguments() {
// Given
Monitors monitors = new Monitors();
AssertableLogProvider logProvider = new AssertableLogProvider();
InterestingMonitor2 aMonitor = monitors.newMonitor(InterestingMonitor2.class);
LoggingListener listener = new LoggingListener(Collections.<Class<?>, Logger>singletonMap(InterestingMonitor2.class, logProvider.getLog(InterestingMonitor2.class).debugLogger()));
monitors.addMonitorListener(listener, listener.predicate);
// When
aMonitor.doubleTouch("APA", 42);
// Then
logProvider.assertExactly(inLog(InterestingMonitor2.class).debug("doubleTouch(String:APA,int:42)"));
}
use of org.neo4j.kernel.monitoring.Monitors 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.kernel.monitoring.Monitors in project neo4j by neo4j.
the class MonitorLoggingAcceptanceTest method shouldBeAbleToLoadPropertiesFromAFile.
@Test
public void shouldBeAbleToLoadPropertiesFromAFile() throws InterruptedException {
AssertableLogProvider logProvider = new AssertableLogProvider();
GraphDatabaseAPI dbAPI = (GraphDatabaseAPI) new TestGraphDatabaseFactory().setInternalLogProvider(logProvider).newImpermanentDatabase();
Monitors monitors = dbAPI.getDependencyResolver().resolveDependency(Monitors.class);
AMonitor aMonitor = monitors.newMonitor(AMonitor.class);
aMonitor.doStuff();
logProvider.assertAtLeastOnce(inLog(AMonitor.class).warn("doStuff()"));
}
use of org.neo4j.kernel.monitoring.Monitors in project neo4j by neo4j.
the class CommunityServerBuilder method build.
public CommunityNeoServer build() throws IOException {
if (dataDir == null && persistent) {
throw new IllegalStateException("Must specify path");
}
final Optional<File> configFile = buildBefore();
Log log = logProvider.getLog(getClass());
Config config = ConfigLoader.loadServerConfig(configFile);
config.setLogger(log);
return build(configFile, config, GraphDatabaseDependencies.newDependencies().userLogProvider(logProvider).monitors(new Monitors()));
}
Aggregations