Skip to content

Commit

Permalink
libshell|LocalServer: Asking for the error log path
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Mar 21, 2014
1 parent 7d5b388 commit 41e695e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
7 changes: 7 additions & 0 deletions doomsday/libshell/include/de/shell/localserver.h
Expand Up @@ -61,6 +61,13 @@ class LIBSHELL_PUBLIC LocalServer
*/
Link *openLink();

/**
* Reads the path of the error log. This is useful after a failed server start.
*
* @return Native path of the error log.
*/
NativePath errorLogPath() const;

private:
DENG2_PRIVATE(d)
};
Expand Down
25 changes: 19 additions & 6 deletions doomsday/libshell/src/localserver.cpp
Expand Up @@ -26,11 +26,14 @@
namespace de {
namespace shell {

static String const ERROR_LOG_NAME = "doomsday-errors.out";

DENG2_PIMPL_NOREF(LocalServer)
{
Link *link;
duint16 port;
String name;
NativePath userDir;

Instance() : link(0), port(0) {}
};
Expand All @@ -44,19 +47,24 @@ void LocalServer::setName(String const &name)
d->name.replace("\"", "\\\""); // for use on command line
}

void LocalServer::start(duint16 port, String const &gameMode, QStringList additionalOptions,
void LocalServer::start(duint16 port,
String const &gameMode,
QStringList additionalOptions,
NativePath const &runtimePath)
{
d->port = port;

NativePath userDir = runtimePath;
d->userDir = runtimePath;

if(userDir.isEmpty())
if(d->userDir.isEmpty())
{
// Default runtime location.
userDir = DoomsdayInfo::defaultServerRuntimeFolder();
d->userDir = DoomsdayInfo::defaultServerRuntimeFolder();
}

// Get rid of a previous error log in this location.
QDir(d->userDir).remove(ERROR_LOG_NAME);

DENG2_ASSERT(d->link == 0);

CommandLine cmd;
Expand Down Expand Up @@ -122,9 +130,9 @@ void LocalServer::start(duint16 port, String const &gameMode, QStringList additi
#endif

cmd.append("-userdir");
cmd.append(userDir);
cmd.append(d->userDir);
cmd.append("-errors");
cmd.append("doomsday-errors.out");
cmd.append(ERROR_LOG_NAME);
cmd.append("-game");
cmd.append(gameMode);
cmd.append("-cmd");
Expand Down Expand Up @@ -154,5 +162,10 @@ Link *LocalServer::openLink()
return new Link(String("localhost:%1").arg(d->port), 30);
}

NativePath LocalServer::errorLogPath() const
{
return d->userDir / ERROR_LOG_NAME;
}

} // namespace shell
} // namespace de

0 comments on commit 41e695e

Please sign in to comment.