Add seconds/microseconds wallclock time to log output, move header includes to inside guard.
svn path=/trunk/netsurf/; revision=10864
This commit is contained in:
parent
02ab2db00f
commit
195c1ea319
25
utils/log.h
25
utils/log.h
|
@ -17,21 +17,34 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "desktop/netsurf.h"
|
|
||||||
|
|
||||||
#ifndef _NETSURF_LOG_H_
|
#ifndef _NETSURF_LOG_H_
|
||||||
#define _NETSURF_LOG_H_
|
#define _NETSURF_LOG_H_
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include "desktop/netsurf.h"
|
||||||
|
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
# define LOG(x) ((void) 0)
|
# define LOG(x) ((void) 0)
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
static inline const char *nslog_gettime(void)
|
||||||
|
{
|
||||||
|
static char buff[32];
|
||||||
|
static struct timeval tv;
|
||||||
|
|
||||||
|
gettimeofday(&tv, NULL);
|
||||||
|
snprintf(buff, sizeof(buff),"(%ld.%ld)", tv.tv_sec, tv.tv_usec);
|
||||||
|
return buff;
|
||||||
|
}
|
||||||
|
|
||||||
# ifdef __GNUC__
|
# ifdef __GNUC__
|
||||||
# define LOG(x) do { if (verbose_log) (printf(__FILE__ " %s %i: ", __PRETTY_FUNCTION__, __LINE__), printf x, fputc('\n', stdout)); } while (0)
|
# define LOG(x) do { if (verbose_log) (printf("%s " __FILE__ " %s %i: ", nslog_gettime(), __PRETTY_FUNCTION__, __LINE__), printf x, fputc('\n', stdout)); } while (0)
|
||||||
|
|
||||||
# elif defined(__CC_NORCROFT)
|
# elif defined(__CC_NORCROFT)
|
||||||
# define LOG(x) do { if (verbose_log) (printf(__FILE__ " %s %i: ", __func__, __LINE__), printf x, fputc('\n', stdout)); } while (0)
|
# define LOG(x) do { if (verbose_log) (printf("%s "__FILE__ " %s %i: ", nslog_gettime(), __func__, __LINE__), printf x, fputc('\n', stdout)); } while (0)
|
||||||
# else
|
# else
|
||||||
# define LOG(x) do { if (verbose_log) (printf(__FILE__ " %i: ", __LINE__), printf x, fputc('\n', stdout)); } while (0)
|
# define LOG(x) do { if (verbose_log) (printf("%s" __FILE__ " %i: ", nslog_gettime(), __LINE__), printf x, fputc('\n', stdout)); } while (0)
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue