40 lines
1.0 KiB
C++
40 lines
1.0 KiB
C++
/* -----------------------------------------------------------------------------
|
|
GSFramework
|
|
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
|
|
----------------------------------------------------------------------------- */
|
|
|
|
|
|
#include <stdio.h>
|
|
#include "log/file_log.h"
|
|
#include "filesystem/filesystem.h"
|
|
#include "platform.h"
|
|
|
|
using namespace GS;
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
void FileLog::NewLog(const char *log, char entry_level)
|
|
{
|
|
if (FILE *f = fopen(path, initial_write ? "w" : "a"))
|
|
{
|
|
initial_write = false;
|
|
|
|
if (do_timestamp)
|
|
{
|
|
String timestamp = Platform::Get().GetTime().toString() + ": ";
|
|
fwrite(timestamp.c_str(), 1, timestamp.Len(), f);
|
|
}
|
|
|
|
fwrite(log, 1, String::strlen(log), f);
|
|
fclose(f);
|
|
}
|
|
}
|
|
FileLog::FileLog(const char *_path, bool _do_timestamp) : path(_path), do_timestamp(_do_timestamp)
|
|
{
|
|
initial_write = true;
|
|
FILE *f = fopen(path, "w");
|
|
if(f)
|
|
fclose(f);
|
|
}
|
|
//------------------------------------------------------------------------------
|