Added logging option like the maingame to the editor.
Added a new 'paths' log domain that dumps messages about path searches. Added a new --logdomains option that list all defined log domains.
This commit is contained in:
parent
cea8bdc65d
commit
dff41b9695
7 changed files with 63 additions and 9 deletions
|
@ -81,6 +81,9 @@ only warnings and errors, and
|
|||
.B --log-error
|
||||
just errors.
|
||||
.TP
|
||||
.B --logdomains
|
||||
Dumps a list of all log domains and exits.
|
||||
.TP
|
||||
.BR --max-fps
|
||||
the number of frames per second the game can show, the value should be between
|
||||
the 1 and 1000, the default is 50.
|
||||
|
|
|
@ -59,6 +59,19 @@ prints version number and exits.
|
|||
.TP
|
||||
.BR -w , \ --windowed
|
||||
runs the editor in windowed mode.
|
||||
.TP
|
||||
.BR --log-error="domain1,domain2,..." ", " --log-warning="..." ", " --log-info="..."
|
||||
sets the severity level of the debug domains. "all" can be used to match
|
||||
any debug domain.
|
||||
.B --log-info
|
||||
shows all messages,
|
||||
.B --log-warning
|
||||
only warnings and errors, and
|
||||
.B --log-error
|
||||
just errors.
|
||||
.TP
|
||||
.B --logdomains
|
||||
Dumps a list of all log domains and exits.
|
||||
|
||||
.SH AUTHOR
|
||||
Written by David White <davidnwhite@verizon.net>.
|
||||
|
|
|
@ -62,7 +62,11 @@ int main(int argc, char** argv)
|
|||
<< " -v, --version Prints the game's version number and exits\n"
|
||||
<< " --resolution Set the resolution of the window\n"
|
||||
<< " --bpp Set the bits per pixel\n"
|
||||
<< " --datadir Select the data directory to use\n";
|
||||
<< " --datadir Select the data directory to use\n"
|
||||
<< " --log-error=\"domain1,domain2,...\", --log-warning=..., --log-info=...\n"
|
||||
<< " sets the severity level of the debug domains.\n"
|
||||
<< " \"all\" can be used to match any debug domain.\n"
|
||||
<< " --logdomain List defined log domains and exit.\n";
|
||||
return 0;
|
||||
} else if(val == "--version" || val == "-v") {
|
||||
std::cout << "Battle for Wesnoth "
|
||||
|
@ -138,6 +142,34 @@ int main(int argc, char** argv)
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
} else if (val.substr(0, 6) == "--log-") {
|
||||
size_t p = val.find('=');
|
||||
if (p == std::string::npos) {
|
||||
std::cerr << "unknown option: " << val << '\n';
|
||||
return 0;
|
||||
}
|
||||
std::string s = val.substr(6, p - 6);
|
||||
int severity;
|
||||
if (s == "error") severity = 0;
|
||||
else if (s == "warning") severity = 1;
|
||||
else if (s == "info") severity = 2;
|
||||
else {
|
||||
std::cerr << "unknown debug level: " << s << '\n';
|
||||
return 0;
|
||||
}
|
||||
while (p != std::string::npos) {
|
||||
size_t q = val.find(',', p + 1);
|
||||
s = val.substr(p + 1, q == std::string::npos ? q : q - (p + 1));
|
||||
if (!lg::set_log_domain_severity(s, severity)) {
|
||||
std::cerr << "unknown debug domain: " << s << '\n';
|
||||
return 0;
|
||||
}
|
||||
p = q;
|
||||
}
|
||||
} else if(val == "--logdomains") {
|
||||
// domain list is hardcoded here because I don't grok
|
||||
// C++ well enough to add a log class hook to get it.
|
||||
std::cerr << "general, ai, config, display, engine, network, filesystem, audio. paths\n";
|
||||
} else if(val[0] == '-') {
|
||||
std::cerr << "unknown option: " << val << "\n";
|
||||
return 0;
|
||||
|
|
|
@ -1071,22 +1071,22 @@ const std::vector<std::string>& get_binary_paths(const std::string& type)
|
|||
std::string get_binary_file_location(const std::string& type, const std::string& filename)
|
||||
{
|
||||
const std::vector<std::string>& paths = get_binary_paths(type);
|
||||
//std::cerr << "Looking for " << filename << " in '.' ";
|
||||
LOG_STREAM(info, paths) << "Looking for " << filename << " in '.'\n";
|
||||
if(file_exists(filename) || is_directory(filename)) {
|
||||
//std::cerr << "\n";
|
||||
LOG_STREAM(info, paths) << " Found at " << filename << "\n";
|
||||
return filename;
|
||||
}
|
||||
|
||||
for(std::vector<std::string>::const_iterator i = paths.begin(); i != paths.end(); ++i) {
|
||||
const std::string file = *i + filename;
|
||||
//std::cerr << "'" << *i << "' ";
|
||||
LOG_STREAM(info, paths) << " Checking " << *i << "\n";
|
||||
if(file_exists(file) || is_directory(file)) {
|
||||
//std::cerr << "\n";
|
||||
LOG_STREAM(info, paths) << " Found at " << file << "\n";
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
//std::cerr << "\n";
|
||||
LOG_STREAM(info, paths) << " " << filename << " not found.\n";
|
||||
return "";
|
||||
}
|
||||
|
||||
|
|
|
@ -1656,6 +1656,7 @@ static int play_game(int argc, char** argv)
|
|||
<< " --log-error=\"domain1,domain2,...\", --log-warning=..., --log-info=...\n"
|
||||
<< " sets the severity level of the debug domains.\n"
|
||||
<< " \"all\" can be used to match any debug domain.\n"
|
||||
<< " --logdomain List defined log domains and exit.\n"
|
||||
<< " --nocache disables caching of game data.\n"
|
||||
<< " --validcache assume that cache is valid (dangerous)\n"
|
||||
<< " --nosound runs the game without sounds and music.\n"
|
||||
|
@ -1724,6 +1725,10 @@ static int play_game(int argc, char** argv)
|
|||
}
|
||||
p = q;
|
||||
}
|
||||
} else if(val == "--logdomains") {
|
||||
// domain list is hardcoded here because I don't grok
|
||||
// C++ well enough to add a log class hook to get it.
|
||||
std::cerr << "general, ai, config, display, engine, network, filesystem, audio. paths\n";
|
||||
} else if(val == "--compress" || val == "--decompress") {
|
||||
if(argc != arg+3) {
|
||||
std::cerr << "format of " << val << " command: " << val << " <input file> <output file>\n";
|
||||
|
|
|
@ -50,8 +50,9 @@ namespace lg {
|
|||
void timestamps(bool t) { timestamp = t; }
|
||||
|
||||
logger err("error", 0), warn("warning", 1), info("info", 2);
|
||||
log_domain general("general"), ai("ai"), config("config"), display("display"), engine("engine"),
|
||||
network("network"), filesystem("filesystem"), audio("audio");
|
||||
log_domain general("general"), ai("ai"), config("config"), display("display"),
|
||||
engine("engine"), network("network"), filesystem("filesystem"),
|
||||
audio("audio"), paths("paths");
|
||||
|
||||
log_domain::log_domain(char const *name) : domain_(log_domains.size())
|
||||
{
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
void timestamps(bool);
|
||||
|
||||
extern logger err, warn, info;
|
||||
extern log_domain general, ai, config, display, engine, network, filesystem, audio;
|
||||
extern log_domain general, ai, config, display, engine, network, filesystem, audio, paths;
|
||||
|
||||
class scope_logger
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue