org.cloudfoundry.doppler.LogMessage Java Examples

The following examples show how to use org.cloudfoundry.doppler.LogMessage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServiceInstanceRecentLogsTest.java    From spring-cloud-app-broker with Apache License 2.0 6 votes vote down vote up
@BeforeEach
void setUp() {
	expectedTestMessage = "test message " + UUID.randomUUID();

	RecentLogsRequest request = RecentLogsRequest.builder().applicationId(RecentLogsTestApp.getAppId()).build();
	LogMessage testMessage = LogMessage
		.builder()
		.message(expectedTestMessage)
		.timestamp(Instant.now().toEpochMilli())
		.messageType(MessageType.OUT).build();

	Envelope testEnvelope = Envelope
		.builder()
		.eventType(EventType.LOG_MESSAGE).origin("test")
		.logMessage(testMessage).build();

	given(dopplerClient.recentLogs(request))
		.willReturn(Flux.just(testEnvelope));

	given(cloudFoundryClient.applicationsV2()
		.get(GetApplicationRequest.builder().applicationId(RecentLogsTestApp.getAppId()).build()))
		.willReturn(Mono.just(
			GetApplicationResponse.builder().entity(ApplicationEntity.builder().name("test-app").build()).build()));
}
 
Example #2
Source File: RawApplicationLog.java    From cf-java-client-sap with Apache License 2.0 5 votes vote down vote up
@Override
public ApplicationLog derive() {
    Envelope envelope = getEnvelope();
    LogMessage logMessage = envelope.getLogMessage();
    return ImmutableApplicationLog.builder()
                                  .applicationGuid(logMessage.getApplicationId())
                                  .message(logMessage.getMessage())
                                  .timestamp(fromLogTimestamp(logMessage))
                                  .messageType(fromLogMessageType(logMessage))
                                  .sourceId(logMessage.getSourceInstance())
                                  .sourceName(logMessage.getSourceType())
                                  .build();
}
 
Example #3
Source File: CloudFoundryTaskLauncher.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
@Override
public String getLog(String taskAppName) {
	List<LogMessage> logMessageList = getLogMessage(taskAppName).collectList().block(Duration.ofSeconds(this.deploymentProperties.getApiTimeout()));
	StringBuilder stringBuilder = new StringBuilder();
	for (LogMessage logMessage: logMessageList) {
		stringBuilder.append(logMessage.getMessage() + System.lineSeparator());
	}
	return stringBuilder.toString();
}
 
Example #4
Source File: CloudFoundryAppDeployer.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
@Override
public String getLog(String id) {
	List<LogMessage> logMessageList = getLogMessage(id).collectList().block(Duration.ofSeconds(this.deploymentProperties.getApiTimeout()));
	StringBuilder stringBuilder = new StringBuilder();
	for (LogMessage logMessage: logMessageList) {
		stringBuilder.append(logMessage.getMessage() + System.lineSeparator());
	}
	return stringBuilder.toString();
}
 
Example #5
Source File: RawApplicationLog.java    From cf-java-client-sap with Apache License 2.0 4 votes vote down vote up
private static Date fromLogTimestamp(LogMessage logMessage) {
    return new Date(TimeUnit.NANOSECONDS.toMillis(logMessage.getTimestamp()));
}
 
Example #6
Source File: RawApplicationLog.java    From cf-java-client-sap with Apache License 2.0 4 votes vote down vote up
private static ApplicationLog.MessageType fromLogMessageType(LogMessage logMessage) {
    return logMessage.getMessageType() == MessageType.OUT ? ApplicationLog.MessageType.STDOUT :
            ApplicationLog.MessageType.STDERR;
}
 
Example #7
Source File: CloudFoundryTaskLauncher.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
private Flux<LogMessage> getLogMessage(String taskAppName) {
	logger.info("Fetching log for {}", taskAppName);
	return this.operations.applications().logs(LogsRequest.builder().name(taskAppName).recent(true).build());
}
 
Example #8
Source File: CloudFoundryAppDeployer.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
private Flux<LogMessage> getLogMessage(String deploymentId) {
	logger.info("Fetching log for "+ deploymentId);
	return this.operations.applications().logs(LogsRequest.builder().name(deploymentId).recent(true).build());
}