mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-02-24 18:34:27 +03:00
Log to stderr
svn path=/trunk/netsurf/; revision=11983
This commit is contained in:
parent
0fd2523f5f
commit
0c7c722e23
15
utils/log.c
15
utils/log.c
@ -20,6 +20,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
#include "desktop/netsurf.h"
|
||||
@ -45,3 +46,17 @@ const char *nslog_gettime(void)
|
||||
snprintf(buff, sizeof(buff),"(%ld.%ld)", (long)tv.tv_sec, (long)tv.tv_usec);
|
||||
return buff;
|
||||
}
|
||||
|
||||
void nslog_log(const char *format, ...)
|
||||
{
|
||||
if (verbose_log) {
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
|
||||
vfprintf(stderr, format, ap);
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
|
||||
|
20
utils/log.h
20
utils/log.h
@ -28,15 +28,27 @@
|
||||
#else
|
||||
|
||||
extern const char *nslog_gettime(void);
|
||||
extern void nslog_log(const char *format, ...);
|
||||
|
||||
# ifdef __GNUC__
|
||||
# define LOG(x) do { if (verbose_log) (printf("%s " __FILE__ " %s %i: ", nslog_gettime(), __PRETTY_FUNCTION__, __LINE__), printf x, fputc('\n', stdout)); } while (0)
|
||||
|
||||
# define LOG_FN __PRETTY_FUNCTION__
|
||||
# define LOG_LN __LINE__
|
||||
# elif defined(__CC_NORCROFT)
|
||||
# define LOG(x) do { if (verbose_log) (printf("%s "__FILE__ " %s %i: ", nslog_gettime(), __func__, __LINE__), printf x, fputc('\n', stdout)); } while (0)
|
||||
# define LOG_FN __func__
|
||||
# define LOG_LN __LINE__
|
||||
# else
|
||||
# define LOG(x) do { if (verbose_log) (printf("%s" __FILE__ " %i: ", nslog_gettime(), __LINE__), printf x, fputc('\n', stdout)); } while (0)
|
||||
# define LOG_FN ""
|
||||
# define LOG_LN __LINE__
|
||||
# endif
|
||||
|
||||
#define LOG(x) \
|
||||
do { \
|
||||
nslog_log("%s " __FILE__ " %s %i: ", \
|
||||
nslog_gettime(), LOG_FN, LOG_LN); \
|
||||
nslog_log x; \
|
||||
nslog_log("\n"); \
|
||||
} while(0)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user