Skip to content

Commit

Permalink
Code format.
Browse files Browse the repository at this point in the history
  • Loading branch information
shibd committed Dec 28, 2022
1 parent 6261445 commit eba8547
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions examples/SampleCustomLoggerCApi.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,19 @@
#include <string.h>
#include <time.h>

char* current_time(){
char *current_time() {
char *time_str = malloc(128);
struct tm *p;
time_t now = time(0);
p=gmtime(&now);
p = gmtime(&now);
strftime(time_str, 128, "%Y-%m-%d %H:%M:%S", p);
return time_str;
}

void custom_logger(pulsar_logger_level_t level, const char *file, int line, const char *message,
void *ctx) {
void custom_logger(pulsar_logger_level_t level, const char *file, int line, const char *message, void *ctx) {
// Control the log level yourself.
if (level >= pulsar_DEBUG) {
char * time_str = current_time();
char *time_str = current_time();
printf("[%s] [%u] [%s] [%d] [%s] \n", time_str, level, file, line, message);
free(time_str);
}
Expand All @@ -49,7 +48,7 @@ int main() {
pulsar_client_configuration_set_memory_limit(conf, 64 * 1024 * 1024);
pulsar_client_t *client = pulsar_client_create("pulsar://localhost:6650", conf);

pulsar_producer_configuration_t* producer_conf = pulsar_producer_configuration_create();
pulsar_producer_configuration_t *producer_conf = pulsar_producer_configuration_create();
pulsar_producer_configuration_set_batching_enabled(producer_conf, 1);
pulsar_producer_t *producer;

Expand All @@ -60,8 +59,8 @@ int main() {
}

for (int i = 0; i < 10; i++) {
const char* data = "my-content";
pulsar_message_t* message = pulsar_message_create();
const char *data = "my-content";
pulsar_message_t *message = pulsar_message_create();
pulsar_message_set_content(message, data, strlen(data));

err = pulsar_producer_send(producer, message);
Expand Down

0 comments on commit eba8547

Please sign in to comment.