1 /*======================================================================*
2 * Copyright (C) 2008 Light Weight Event System *
3 * All rights reserved. *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
18 * Boston, MA 02110-1301 USA. *
19 *======================================================================*/
31 void log_msg(int level
, const char* fname
, int lineno
, const char* format
, ...) {
35 /* check for illegal logging level */
38 printf ("logging level <= 0\n");
42 /* check for ignored message logging level */
43 if((level
& arg_log_level
) == 0)
49 vsnprintf(buf
, sizeof(buf
), format
, ap
);
52 fprintf(stdout
, "%s:%d : %s", fname
, lineno
, buf
);
55 void log_get_level_string(char* str
, int len
)
59 if ( LOG_MASK_ERROR
& arg_log_level
)
61 strncat(str
, "ERROR ", len
- strlen(str
));
64 if ( LOG_MASK_WARNING
& arg_log_level
)
66 strncat(str
, "WARNING ", len
- strlen(str
));
69 if ( LOG_MASK_INFO
& arg_log_level
)
71 strncat(str
, "INFO ", len
- strlen(str
));
74 if ( LOG_MASK_PROGRESS
& arg_log_level
)
76 strncat(str
, "PROGRESS ", len
- strlen(str
));