file: add note on pp_set_dir

CLogger: fix log file opening (now uses VFS path correctly)
ScriptingHost: fix error reporter - no longer does redundant write to
console

This was SVN commit r3246.
This commit is contained in:
janwas 2005-12-14 18:32:02 +00:00
parent 00a15f0ccb
commit 0e40dfc480
4 changed files with 24 additions and 7 deletions

View File

@ -70,6 +70,10 @@ const size_t SECTOR_SIZE = 4096;
// write the given directory path into our buffer and set end/chars_left
// accordingly. <dir> need and should not end with a directory separator.
//
// note: <dir> and the filename set via pp_append_file are separated by
// '/'. this is to allow use on portable paths; the function otherwise
// does not care if paths are relative/portable/absolute.
LibError pp_set_dir(PathPackage* pp, const char* dir)
{
// note: use / instead of DIR_SEP because pp->path is portable.

View File

@ -36,6 +36,10 @@ struct PathPackage
// write the given directory path into our buffer and set end/chars_left
// accordingly. <dir> need and should not end with a directory separator.
//
// note: <dir> and the filename set via pp_append_file are separated by
// '/'. this is to allow use on portable paths; the function otherwise
// does not care if paths are relative/portable/absolute.
extern LibError pp_set_dir(PathPackage* pp, const char* dir);
// append the given filename to the directory established by the last

View File

@ -3,6 +3,7 @@
#include "CLogger.h"
#include "ConfigDB.h"
#include "lib.h"
#include "lib/res/file/file.h"
#include <time.h>
@ -22,7 +23,7 @@ const char* html_header1 = "</H1></P>\n";
const char* html_footer = "</BODY>\n</HTML>\n";
#define MEMORY_BUFFER_SIZE 240
#define MEMORY_BUFFER_SIZE 1000
CLogger::CLogger()
{
@ -33,10 +34,16 @@ CLogger::CLogger()
m_MemoryLogBuffer = (char *)calloc(MEMORY_BUFFER_SIZE, 1);
m_CurrentPosition = m_MemoryLogBuffer;
// current directory is $install_dir/data, we want $install_dir/logs.
m_MainLog.open ("../logs/mainlog.html", ofstream::out | ofstream::trunc);
m_InterestingLog.open ("../logs/interestinglog.html", ofstream::out | ofstream::trunc);
m_MemoryLog.open ("../logs/memorylog.html", ofstream::out | ofstream::trunc);
char N_path[PATH_MAX];
(void)file_make_full_native_path("../logs", N_path);
PathPackage pp;
(void)pp_set_dir(&pp, N_path);
(void)pp_append_file(&pp, "mainlog.html");
m_MainLog.open (pp.path, ofstream::out | ofstream::trunc);
(void)pp_append_file(&pp, "interestinglog.html");
m_InterestingLog.open(pp.path, ofstream::out | ofstream::trunc);
(void)pp_append_file(&pp, "memorylog.html");
m_MemoryLog.open (pp.path, ofstream::out | ofstream::trunc);
//Write Headers for the HTML documents
m_MainLog << html_header0 << "Main log" << html_header1;

View File

@ -413,10 +413,12 @@ void ScriptingHost::ErrorReporter(JSContext* UNUSED(cx), const char* message, JS
if(!message)
message = "No error message available";
// for developer convenience: write to output window so they can
// doubleclick on that line and be taken to the error locus.
debug_printf("%s(%d): %s\n", file, line, message);
if (g_Console)
g_Console->InsertMessage(L"JavaScript Error (%hs, line %d): %hs", file, line, message);
// note: CLogger's LOG already takes care of writing to the console,
// so don't do that here.
LOG(ERROR, LOG_CATEGORY, "JavaScript Error (%s, line %d): %s", file, line, message);
}