@ -31,6 +31,7 @@
# include "timeline.h"
# include "timeline.h"
# include "compositor.h"
# include "compositor.h"
# include "file-util.h"
struct timeline_log {
struct timeline_log {
clock_t clk_id ;
clock_t clk_id ;
@ -45,31 +46,25 @@ static struct timeline_log timeline_ = { CLOCK_MONOTONIC, NULL, 0 };
static int
static int
weston_timeline_do_open ( void )
weston_timeline_do_open ( void )
{
{
time_t t ;
const char * prefix = " weston-timeline- " ;
struct tm * tmp ;
const char * suffix = " .log " ;
char fname [ 1000 ] ;
char fname [ 1000 ] ;
int ret ;
t = time ( NULL ) ;
timeline_ . file = file_create_dated ( prefix , suffix ,
tmp = localtime ( & t ) ;
fname , sizeof ( fname ) ) ;
if ( ! tmp ) {
if ( ! timeline_ . file ) {
weston_log ( " Conversion to local time failed, "
const char * msg ;
" cannot open timeline log file. \n " ) ;
return - 1 ;
}
ret = strftime ( fname , sizeof ( fname ) ,
switch ( errno ) {
" weston-timeline-%F_%H-%M-%S.log " , tmp ) ;
case ETIME :
if ( ret = = 0 ) {
msg = " failure in datetime formatting " ;
weston_log ( " Time formatting failed, "
break ;
" cannot open timeline log file. \n " ) ;
default :
return - 1 ;
msg = strerror ( errno ) ;
}
}
timeline_ . file = fopen ( fname , " w " ) ;
weston_log ( " Cannot open '%s*%s' for writing: %s \n " ,
if ( ! timeline_ . file ) {
prefix , suffix , msg ) ;
weston_log ( " Cannot open '%s' for writing: %s \n " ,
fname , strerror ( errno ) ) ;
return - 1 ;
return - 1 ;
}
}