bzr branch
http://gegoxaren.bato24.eu/bzr/vqdr/trunk
62
by Gustav Hartvigsson
various changes |
1 |
using Posix; |
2 |
||
3 |
||
4 |
/*
|
|
5 |
* Public Domain.
|
|
6 |
*/
|
|
64
by Gustav Hartvigsson
[General] Major refactoring. Utils -> Vee nenaming. |
7 |
|
8 |
namespace Vee { |
|
62
by Gustav Hartvigsson
various changes |
9 |
|
10 |
/** |
|
11 |
* This is a cheap logger, do not use for production code,
|
|
12 |
* it is only for targets where GLib is not available.
|
|
13 |
*
|
|
14 |
* Use GLib's logging capabilities instead.
|
|
15 |
*/
|
|
16 |
public class Logger { |
|
17 |
private const string STR_ERROR = "[ERROR]: "; |
|
18 |
private const string STR_INFO = "[INFO]: "; |
|
19 |
private unowned FILE out_file; |
|
20 |
|
|
21 |
private static Logger logger = null; |
|
22 |
|
|
23 |
public Logger (FILE out_file) { |
|
24 |
this.out_file = out_file; |
|
25 |
} |
|
26 |
|
|
27 |
public static Logger get_default () { |
|
28 |
if (logger == null) { |
|
29 |
Logger.logger = new Logger (Posix.stdout); |
|
30 |
} |
|
31 |
return logger; |
|
32 |
} |
|
33 |
|
|
34 |
public static void set_default (Logger logger) { |
|
35 |
Logger.logger = logger; |
|
36 |
} |
|
37 |
|
|
38 |
public void error (string str, ...) { |
|
39 |
out_file.printf (STR_ERROR); |
|
40 |
out_file.printf (str, va_list()); |
|
41 |
} |
|
42 |
|
|
43 |
public void info (string str, ...) { |
|
44 |
out_file.printf (STR_INFO); |
|
45 |
out_file.printf (str, va_list()); |
|
46 |
} |
|
47 |
|
|
48 |
public static void free_default () { |
|
49 |
Posix.free(Logger.logger); |
|
50 |
} |
|
51 |
} |
|
52 |
}
|