Skip to content

Commit

Permalink
Added basic logging to app::parse_args()
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Glover committed Mar 30, 2010
1 parent 36c55df commit 5b42c3a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
31 changes: 21 additions & 10 deletions src/main/adonthell.cc
@@ -1,5 +1,6 @@
/*
Copyright (C) 2003/2004/2005 Kai Sterker <kaisterker@linuxgames.com>
Copyright (C) 2010 Josh Glover <jmglov@jmglov.net>
Part of the Adonthell Project http://adonthell.linuxgames.com
Adonthell is free software; you can redistribute it and/or modify
Expand All @@ -21,6 +22,7 @@
/**
* @file main/adonthell.cc
* @author Kai Sterker <kaisterker@linuxgames.com>
* @author Josh Glover <jmglov@jmglov.net>
*
* @brief The main application class for programs using the Adonthell framework.
*/
Expand Down Expand Up @@ -130,6 +132,18 @@ bool app::init_modules (const u_int16 & modules)
// read command line arguments
void app::parse_args (int & argc, char *argv[])
{
google::InitGoogleLogging(argv[0]);

LOG(INFO) << logging::indent() << "app::parse_args() called";
logging::increment_log_indent_level();

LOG(INFO) << logging::indent()
<< "Program '" << argv[0] << "' has "
<< argc << " args:"
;
for (int i = 1; i < argc; i++)
LOG(INFO) << logging::indent() << "[" << i << "]: '" << argv[i] << "'";

int c;

Argc = argc;
Expand All @@ -140,16 +154,6 @@ void app::parse_args (int & argc, char *argv[])
Userdatadir = "";
Config = "adonthell";

// Initialize Google's logging library.
google::InitGoogleLogging(argv[0]);

LOG(INFO) << "Adonthell starting up!";
LOG(INFO) << " Invoked as: " << argv[0];
for (int i = 1; i < argc; i++)
{
LOG(INFO) << " " << argv[i];
}

// Check for options
while ((c = getopt (argc, argv, "b:c:g:hv")) != -1)
{
Expand Down Expand Up @@ -187,6 +191,13 @@ void app::parse_args (int & argc, char *argv[])
{
Game = argv[argc-1];
}

LOG(INFO) << logging::indent() << "Game: '" << Game << "'";
LOG(INFO) << logging::indent() << "Backend: '" << Backend << "'";
LOG(INFO) << logging::indent() << "Userdatadir: '" << Userdatadir << "'";
LOG(INFO) << logging::indent() << "Config: '" << Config << "'";

logging::decrement_log_indent_level();
}

// initialize the Adonthell framework
Expand Down
3 changes: 1 addition & 2 deletions src/main/adonthell.h
@@ -1,6 +1,4 @@
/*
$Id: adonthell.h,v 1.8 2009/04/18 21:54:58 ksterker Exp $
Copyright (C) 2003/2004 Kai Sterker <kaisterker@linuxgames.com>
Part of the Adonthell Project http://adonthell.linuxgames.com
Expand Down Expand Up @@ -34,6 +32,7 @@

#include "ltdl.h"
#include "base/configuration.h"
#include "base/logging.h"

using std::string;

Expand Down

0 comments on commit 5b42c3a

Please sign in to comment.