Skip to content

Commit

Permalink
Fixup logging correctly from a dumb mistake.
Browse files Browse the repository at this point in the history
* Accidentally used the format data twice for file/line causing issues with
  logging
* Hard code path to filename on USB stick.
* Make filename a variable so that when settings work is done we will be able
  to reconfigure that one variable for use in path.
  • Loading branch information
Materdaddy committed Aug 16, 2013
1 parent 8c1dc02 commit ad63a7f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions bin/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@
#include <stdarg.h>

FILE *logFile;
const char *filename = "/home/pi/media/fppLog.txt";

static bool verbose = false;
static bool foreground = false;

void _LogWrite(const char *format, char *file, int line, ...)
void _LogWrite(char *file, int line, const char *format, ...)
{
va_list arg;
int done;

if ( verbose )
{
done = fprintf(stdout, "%s:%d:", file, line);
fprintf(stdout, "%s:%d:", file, line);
va_start(arg, format);
done += vfprintf(stdout, format, arg);
vfprintf(stdout, format, arg);
va_end(arg);
}

if ( ! foreground )
{
logFile = fopen("fppdLog.txt", "a");
logFile = fopen(filename, "a");

done = fprintf(logFile, "%s:%d:", file, line);
fprintf(logFile, "%s:%d:", file, line);
va_start(arg, format);
done += fprintf(logFile, format, arg);
fprintf(logFile, format, arg);
va_end(arg);

fclose(logFile);
Expand Down
4 changes: 2 additions & 2 deletions bin/log.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef __LOG_H__
#define __LOG_H__

#define LogWrite(format, args...) _LogWrite("%s:%d:" format, __FILE__, __LINE__, ## args)
#define LogWrite(format, args...) _LogWrite(__FILE__, __LINE__, format, ## args)

void _LogWrite(const char *format, char *file, int line, ...);
void _LogWrite(char *file, int line, const char *format, ...);

#endif //__LOG_H__

0 comments on commit ad63a7f

Please sign in to comment.