diff --git a/Loggable.C b/Loggable.C index 44f9839..9955023 100644 --- a/Loggable.C +++ b/Loggable.C @@ -24,23 +24,35 @@ #include #include +FILE *Loggable::_fp; + 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 Loggable::log ( const char *module, const char *action, const char *fmt, ... ) { va_list args; - /* FIXME: log all this stuff to someplace meaningful */ - - printf( "%s %s %p ", module, action, _id ); + fprintf( _fp, "%-15s %-8s %p ", module, action, _id ); if ( fmt ) { va_start( args, fmt ); - vfprintf( stdout, fmt, args ); + vfprintf( _fp, fmt, args ); va_end( args ); } - printf( "\n" ); + fprintf( _fp, "\n" ); } diff --git a/Loggable.H b/Loggable.H index 554f4f2..6d5145a 100644 --- a/Loggable.H +++ b/Loggable.H @@ -21,10 +21,12 @@ #pragma once +#include class Loggable { + static FILE *_fp; static int _log_id; private: @@ -32,6 +34,8 @@ private: public: + static bool open ( const char *filename ); + Loggable ( ) { _id = ++_log_id; diff --git a/main.C b/main.C index 3559c85..94083e5 100644 --- a/main.C +++ b/main.C @@ -45,6 +45,7 @@ #include "Tempo_Track.H" #include "Time_Track.H" +#include "Loggable.H" #include "const.h" @@ -109,6 +110,8 @@ main ( int argc, char **argv ) Fl::get_system_colors(); Fl::scheme( "plastic" ); + Loggable::open( "history" ); + timeline = new Timeline( 0, 0, 800, 600, "Timeline" ); // Region *wave = new Region( Clip::from_file( "streambass8.wav" ) );