#import "RedirectLogsExample.h"
@implementation RedirectLogsExample
- (id)initWithExampleInterface:(ExampleInterface *)exampleInterface {
self = [super initWithExampleInterface:exampleInterface];
self.name = @"RedirectLogs";
self.description = @"Demonstrates how to redirect logs to stdout";
[self.parameters addParameter:PARAMETER_DESTINATION_TOPIC];
return self;
}
userData:(void *)userData {
printf("Log: Category=%s, Level=%s, Msg=%s\n",
}
- (void)run {
[super run];
char binMsg[1024];
[self handleErrorWithReturnCode:rc
errorString:"solClient_log_setCallback()"];
goto notInitialized;
}
[self printToTextView:
@"All logging output is now being redirected to stdout.\n"];
[self handleErrorWithReturnCode:rc
errorString:"solClient_initialize()"];
goto notInitialized;
}
[self setLoggingLevel];
"RedirectLogsExample.m (Copyright 2007-2024 Solace Corporation. All rights reserved.)\n");
[self logCCSMPVersion];
&contextFuncInfo,
sizeof(contextFuncInfo))) !=
SOLCLIENT_OK) {
[self handleErrorWithReturnCode:rc
errorString:"solClient_context_create()"];
goto cleanup;
}
if ((rc = [self
createAndConnectSessionWithContext:context_p
session:&session_p
messageCallback:messageReceivePrintMsgCallback
eventCallback:eventCallback]) !=
[self handleErrorWithReturnCode:
rc errorString:"createAndConnectSessionWithContext:session:"
"messageCallback:eventCallback:userData:"];
goto cleanup;
}
[[self.parameters parameterWithId:PARAMETER_DESTINATION_TOPIC]
.value cStringUsingEncoding:NSASCIIStringEncoding])) !=
[self handleErrorWithReturnCode:rc
errorString:"solClient_session_topicSubscribe()"];
goto sessionConnected;
}
[self handleErrorWithReturnCode:rc errorString:"solClient_msg_alloc()"];
goto sessionConnected;
}
[self handleErrorWithReturnCode:rc
errorString:"solClient_msg_setDeliveryMode()"];
goto sessionConnected;
}
memset((void *)binMsg, 0xab, sizeof(binMsg));
[self
handleErrorWithReturnCode:rc
errorString:"solClient_msg_setBinaryAttachmentPtr()"];
goto sessionConnected;
}
destination.
dest = COMMON_MY_SAMPLE_TOPIC;
msg_p, &destination,
sizeof(destination))) !=
SOLCLIENT_OK) {
[self handleErrorWithReturnCode:rc
errorString:"solClient_msg_setDestination()"];
goto sessionConnected;
}
[self handleErrorWithReturnCode:rc
errorString:"solClient_session_send"];
goto sessionConnected;
}
[self handleErrorWithReturnCode:rc errorString:"solClient_msg_free()"];
goto sessionConnected;
}
[NSThread sleepForTimeInterval:2];
[[self.parameters parameterWithId:PARAMETER_DESTINATION_TOPIC]
.value cStringUsingEncoding:NSASCIIStringEncoding])) !=
[self handleErrorWithReturnCode:rc
errorString:"solClient_session_topicSubscribe()"];
goto sessionConnected;
}
sessionConnected:
[self handleErrorWithReturnCode:rc
errorString:"solClient_session_disconnect()"];
}
cleanup:
[self handleErrorWithReturnCode:rc errorString:"solClient_cleanup()"];
}
notInitialized:
[self cleanup];
}
@end