Actually write journal to file.

This commit is contained in:
Jonathan Moore Liles 2008-02-22 14:20:44 -06:00
parent d3c62adde2
commit 9640ca934f
3 changed files with 24 additions and 5 deletions

View File

@ -24,23 +24,35 @@
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
FILE *Loggable::_fp;
int Loggable::_log_id = 0; int Loggable::_log_id = 0;
bool
Loggable::open ( const char *filename )
{
if ( ! ( Loggable::_fp = fopen( filename, "a+" ) ) )
{
printf( "Could not open log file for writing!" );
return false;
}
return true;
}
void void
Loggable::log ( const char *module, const char *action, const char *fmt, ... ) Loggable::log ( const char *module, const char *action, const char *fmt, ... )
{ {
va_list args; va_list args;
/* FIXME: log all this stuff to someplace meaningful */ fprintf( _fp, "%-15s %-8s %p ", module, action, _id );
printf( "%s %s %p ", module, action, _id );
if ( fmt ) if ( fmt )
{ {
va_start( args, fmt ); va_start( args, fmt );
vfprintf( stdout, fmt, args ); vfprintf( _fp, fmt, args );
va_end( args ); va_end( args );
} }
printf( "\n" ); fprintf( _fp, "\n" );
} }

View File

@ -21,10 +21,12 @@
#pragma once #pragma once
#include <stdio.h>
class Loggable class Loggable
{ {
static FILE *_fp;
static int _log_id; static int _log_id;
private: private:
@ -32,6 +34,8 @@ private:
public: public:
static bool open ( const char *filename );
Loggable ( ) Loggable ( )
{ {
_id = ++_log_id; _id = ++_log_id;

3
main.C
View File

@ -45,6 +45,7 @@
#include "Tempo_Track.H" #include "Tempo_Track.H"
#include "Time_Track.H" #include "Time_Track.H"
#include "Loggable.H"
#include "const.h" #include "const.h"
@ -109,6 +110,8 @@ main ( int argc, char **argv )
Fl::get_system_colors(); Fl::get_system_colors();
Fl::scheme( "plastic" ); Fl::scheme( "plastic" );
Loggable::open( "history" );
timeline = new Timeline( 0, 0, 800, 600, "Timeline" ); timeline = new Timeline( 0, 0, 800, 600, "Timeline" );
// Region *wave = new Region( Clip::from_file( "streambass8.wav" ) ); // Region *wave = new Region( Clip::from_file( "streambass8.wav" ) );