Skip to content

Commit

Permalink
Logging fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmichalek committed Oct 9, 2015
1 parent e9bb561 commit 337d819
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
10 changes: 7 additions & 3 deletions symmetric-client-clib/src/common/SymLog.c
Expand Up @@ -58,10 +58,10 @@ char *generateTimestamp() {
void SymLog_log(LogLevel logLevel, const char *functionName, const char *fileName, int lineNumber, const char* message, ...) {
FILE *destination;
if (logLevel <= INFO) {
destination = stdin;
destination = stdout;
}
else {
destination = stdout;
destination = stderr;
}

char* levelDescription = logLevelDescription(logLevel);
Expand All @@ -87,7 +87,11 @@ void SymLog_log(LogLevel logLevel, const char *functionName, const char *fileNam

messageBuffer->append(messageBuffer, "\n");

printf("%s", messageBuffer->toString(messageBuffer));
fprintf(destination, "%s", messageBuffer->toString(messageBuffer));

// stdout may not flush before stderr does.
// Do this to keep log messages more or less in order.
fflush(destination);

messageBuffer->destroy(messageBuffer);
free(logTimestamp);
Expand Down
5 changes: 5 additions & 0 deletions symmetric-client-clib/src/db/SymDialectFactory.c
Expand Up @@ -23,6 +23,11 @@

SymDialect * SymDialectFactory_create(SymDatabasePlatform *platform) {
SymDialect *dialect = NULL;

if (platform == NULL) {
SymLog_error("No Database platform provided. (platform == NULL)");
}

if (strcmp(platform->name, SYM_DATABASE_SQLITE) == 0) {
dialect = (SymDialect *) SymSqliteDialect_new(NULL, platform);
} else {
Expand Down
2 changes: 1 addition & 1 deletion symmetric-client-clib/src/service/DataLoaderService.c
Expand Up @@ -67,7 +67,7 @@ void SymDataLoaderService_loadDataFromRegistration(SymDataLoaderService *this, S

char *registrationUrl = this->parameterService->getRegistrationUrl(this->parameterService);
SymIncomingTransport *transport = this->transportManager->getRegisterTransport(this->transportManager, local, registrationUrl);
SymLog_info("Using registration URL of %s\n", transport->getUrl(transport));
SymLog_info("Using registration URL of %s", transport->getUrl(transport));

SymNode *remote = SymNode_new(NULL);
remote->syncUrl = registrationUrl;
Expand Down

0 comments on commit 337d819

Please sign in to comment.