logswan

Fast Web log analyzer using probabilistic data structures
Log | Files | Refs | README | LICENSE

commit a294bd207b569f011674e66ebbd5298511f7ee47
parent 50decd63ff138730a893330dc0ac2bc92a0f4ab0
Author: Frederic Cambus <fcambus@users.sourceforge.net>
Date:   Sun,  8 Nov 2015 23:43:51 +0100

Output JSON data to stdout instead of creating a new file

Diffstat:
Msrc/logswan.c | 16++--------------
1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/src/logswan.c b/src/logswan.c @@ -55,7 +55,7 @@ int statusCode; int hour; struct stat logFileSize; -FILE *logFile, *jsonFile; +FILE *logFile; const char *errstr; @@ -114,16 +114,6 @@ int main (int argc, char *argv[]) { return EXIT_FAILURE; } - /* Create output file */ - int outputLen = strlen(intputFile) + 6; - char *outputFile = malloc(outputLen); - snprintf(outputFile, outputLen, "%s%s", intputFile, ".json"); - - if (!(jsonFile = fopen(outputFile, "w"))) { - perror("Can't create output file"); - return EXIT_FAILURE; - } - while (fgets(lineBuffer, LINE_MAX_LENGTH, logFile) != NULL) { /* Parse and tokenize line */ parseLine(&parsedLine, lineBuffer); @@ -236,9 +226,7 @@ int main (int argc, char *argv[]) { fprintf(stderr, "Processed %" PRIu64 " lines in %f seconds\n", results.processedLines, results.runtime); fclose(logFile); - fputs(output(results), jsonFile); - printf("Created file : %s\n", outputFile); - fclose(jsonFile); + fputs(output(results), stdout); GeoIP_delete(geoip); GeoIP_delete(geoipv6);