Debian Codegraph @

src/gengine/Log.cpp

raw
1 /*
2 * Copyright (C) 2004 Ivo Danihelka ([email protected])
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 */
9 #include "Log.h"
10
11 #include "ExInfo.h"
12
13 #include <stdlib.h>
14 #include <stdio.h>
15
16 int Log::ms_logLevel = LEVEL_INFO;
17 //int Log::ms_logLevel = LEVEL_DEBUG;
18 //-----------------------------------------------------------------
19 /**
20 * Print log info.
21 * @param level priority level
22 * @param file source file
23 * @param line line number in source file
24 * @param info detail info
25 */
26 void
27 Log::log(int level, const char *file, int line,
28 const ExInfo &info) throw()
29 {
30 if (level <= ms_logLevel) {
31 const char *levelName;
32 switch (level) {
33 case LEVEL_DEBUG:
34 levelName = "DEBUG";
35 break;
36 case LEVEL_INFO:
37 levelName = "INFO";
38 break;
39 case LEVEL_WARNING:
40 levelName = "WARNING";
41 break;
42 case LEVEL_ERROR:
43 levelName = "ERROR";
44 break;
45 default:
46 levelName = "UNKNOWN";
47 break;
48 }
49
50 fprintf(stderr, "%s:%d: %s %s\n", file, line, levelName, info.what());
51 }
52 }
53