Mercurial > projects > doodle
diff doodle/core/logging.d @ 58:c63719604adb
Beginnings of creating a rectangle...
author | "David Bryant <bagnose@gmail.com>" |
---|---|
date | Mon, 09 Aug 2010 21:43:24 +0930 |
parents | 0eaf39fda206 |
children | 523269b36711 ab745d8b10e5 |
line wrap: on
line diff
--- a/doodle/core/logging.d Sun Aug 08 22:01:54 2010 +0930 +++ b/doodle/core/logging.d Mon Aug 09 21:43:24 2010 +0930 @@ -3,26 +3,50 @@ private { import std.stdio; import std.typecons; + import std.traits; } public { - void trace(string file = __FILE__, int line = __LINE__)(in string message) { - log(Severity.TRACE, std.string.format("%s(%d): TRACE: %s", right(file, 20), line, message)); + void trace(string file = __FILE__, int line = __LINE__, S...)(S args) { + static assert(S.length > 0); + static assert(isSomeString!(S[0])); + log(Severity.TRACE, + std.string.format("%s(%d): MESSAGE: %s", right(file, 20), line, std.string.format(args))); } - void info(string file = __FILE__, int line = __LINE__)(in string message) { - log(Severity.INFO, std.string.format("%s(%d): INFO: %s", right(file, 20), line, message)); + + void info(string file = __FILE__, int line = __LINE__, S...)(S args) { + static assert(S.length > 0); + static assert(isSomeString!(S[0])); + log(Severity.INFO, + std.string.format("%s(%d): MESSAGE: %s", right(file, 20), line, std.string.format(args))); } - void message(string file = __FILE__, int line = __LINE__)(in string message) { - log(Severity.MESSAGE, std.string.format("%s(%d): MESSAGE: %s", right(file, 20), line, message)); + + void message(string file = __FILE__, int line = __LINE__, S...)(S args) { + static assert(S.length > 0); + static assert(isSomeString!(S[0])); + log(Severity.MESSAGE, + std.string.format("%s(%d): MESSAGE: %s", right(file, 20), line, std.string.format(args))); } - void warning(string file = __FILE__, int line = __LINE__)(in string message) { - log(Severity.WARNING, std.string.format("%s(%d): WARNING: %s", right(file, 20), line, message)); + + void warning(string file = __FILE__, int line = __LINE__, S...)(S args) { + static assert(S.length > 0); + static assert(isSomeString!(S[0])); + log(Severity.WARNING, + std.string.format("%s(%d): MESSAGE: %s", right(file, 20), line, std.string.format(args))); } - void error(string file = __FILE__, int line = __LINE__)(in string message) { - log(Severity.ERROR, std.string.format("%s(%d): ERROR: %s", right(file, 20), line, message)); + + void error(string file = __FILE__, int line = __LINE__, S...)(S args) { + static assert(S.length > 0); + static assert(isSomeString!(S[0])); + log(Severity.ERROR, + std.string.format("%s(%d): MESSAGE: %s", right(file, 20), line, std.string.format(args))); } - void fatal(string file = __FILE__, int line = __LINE__)(in string message) { - log(Severity.FATAL, std.string.format("%s(%d): FATAL: %s", right(file, 20), line, message)); + + void fatal(string file = __FILE__, int line = __LINE__, S...)(S args) { + static assert(S.length > 0); + static assert(isSomeString!(S[0])); + log(Severity.FATAL, + std.string.format("%s(%d): MESSAGE: %s", right(file, 20), line, std.string.format(args))); assert(0); } } @@ -52,9 +76,7 @@ } void log(in Severity severity, in string message) { - write(severityString(severity)); - write(message); - writeln(modifierString(Modifier.RESET)); + writeln(severityString(severity), message, modifierString(Modifier.RESET)); } enum Modifier {