47 if (x->tv_usec < y->tv_usec) {
48 int nsec = (int)(y->tv_usec - x->tv_usec) / 1000000 + 1;
49 y->tv_usec -= 1000000 * nsec;
52 if ((
int)(x->tv_usec - y->tv_usec) > 1000000) {
53 int nsec = (int)(x->tv_usec - y->tv_usec) / 1000000;
54 y->tv_usec += 1000000 * nsec;
60 result->tv_sec = x->tv_sec - y->tv_sec;
61 result->tv_usec = x->tv_usec - y->tv_usec;
64 return x->tv_sec < y->tv_sec;
74 static struct timeval start_tv;
78 struct timeval now_tv;
81 gettimeofday(&start_tv, NULL);
83 gettimeofday(&now_tv, NULL);
87 snprintf(buff,
sizeof(buff),
"(%ld.%06ld)",
88 (
long)tv.tv_sec, (
long)tv.tv_usec);
95NSLOG_DEFINE_CATEGORY(netsurf,
"NetSurf default logging");
96NSLOG_DEFINE_CATEGORY(
llcache,
"Low level cache");
97NSLOG_DEFINE_CATEGORY(
fetch,
"Object fetching");
98NSLOG_DEFINE_CATEGORY(plot,
"Rendering system");
99NSLOG_DEFINE_CATEGORY(schedule,
"Scheduler");
100NSLOG_DEFINE_CATEGORY(
fbtk,
"Framebuffer toolkit");
101NSLOG_DEFINE_CATEGORY(layout,
"Layout");
102NSLOG_DEFINE_CATEGORY(flex,
"Flex");
103NSLOG_DEFINE_CATEGORY(dukky,
"Duktape JavaScript Binding");
104NSLOG_DEFINE_CATEGORY(jserrors,
"JavaScript error messages");
107netsurf_render_log(
void *_ctx,
108 nslog_entry_context_t *ctx,
113 "%s [%s %.*s] %.*s:%i %.*s: ",
115 nslog_short_level_name(ctx->level),
116 ctx->category->namelen,
135 nslog_filter_t *filt = NULL;
137 err = nslog_filter_from_text(filter, &filt);
138 if (err != NSLOG_NO_ERROR) {
139 if (err == NSLOG_NO_MEMORY)
145 err = nslog_filter_set_active(filt, NULL);
146 filt = nslog_filter_unref(filt);
147 if (err != NSLOG_NO_ERROR) {
157nslog_log(
const char *file,
const char *func,
int ln,
const char *format, ...)
169 va_start(ap, format);
195 if (((*pargc) > 1) &&
196 (argv[1][0] ==
'-') &&
197 (argv[1][1] ==
'v') &&
205 for (argcmv = 2; argcmv < (*pargc); argcmv++) {
206 argv[argcmv - 1] = argv[argcmv];
212 }
else if (((*pargc) > 2) &&
213 (argv[1][0] ==
'-') &&
214 (argv[1][1] ==
'V') &&
219 logfile = fopen(argv[2],
"a+");
222 for (argcmv = 3; argcmv < (*pargc); argcmv++) {
223 argv[argcmv - 2] = argv[argcmv];
253 NETSURF_BUILTIN_VERBOSE_FILTER :
257 }
else if (nslog_set_render_callback(netsurf_render_log, NULL) != NSLOG_NO_ERROR) {
260 }
else if (nslog_uncork() != NSLOG_NO_ERROR) {
272 "Failed to extract machine information");
275 "NetSurf on <%s>, node <%s>, release <%s>, version <%s>, machine <%s>",
302 "Finalising logging, please report any further messages");
nserror
Enumeration of error codes.
@ NSERROR_NOSPACE
Insufficient space.
@ NSERROR_NOT_FOUND
Requested item not found.
@ NSERROR_INIT_FAILED
Initialisation failed.
@ NSERROR_INVALID
Invalid data.
@ NSERROR_NOMEM
Memory exhaustion.
static struct llcache_s * llcache
low level cache state
nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv)
Initialise the logging system.
bool verbose_log
flag to enable verbose logging
static const char * nslog_gettime(void)
Obtain a formatted string suitable for prepending to a log message.
nserror nslog_set_filter_by_options(void)
Set the logging filter according to the options.
void nslog_finalise(void)
Shut down the logging system.
static int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y)
Subtract the ‘struct timeval’ values X and Y.
nserror nslog_set_filter(const char *filter)
Set the logging filter.
static FILE * logfile
The stream to which logging is sent.
void nslog_log(const char *file, const char *func, int ln, const char *format,...)
bool() nslog_ensure_t(FILE *fptr)
Ensures the FILE handle is available to write logging to.
#define NSLOG(catname, level, logmsg, args...)
Information for a single fetch.
system information filled in by uname derived from posix spec.
char release[65]
OS release (e.g., "2.6.28")
char nodename[65]
Name within "some implementation-defined network".
char version[65]
OS version.
char machine[65]
Hardware identifier.
char sysname[65]
Operating system name (e.g., "Linux")
BSD style timeval macros.
Option reading and saving interface.
#define nsoption_charp(OPTION)
Get the value of a string option.
int uname(struct utsname *buf)
Get the system information.
Interface to uts API to get name and information about current kernel.
Version information interface.