From 8474c5d4c0b59e74e2ef001b5033b78d7a99fcad Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sun, 5 May 2019 21:05:27 +0100 Subject: Logging: migrate and provide content interface Migrate the console enums into netsurf/console.h and add support so that contents can raise a message to log to the console. Signed-off-by: Daniel Silverstone --- include/netsurf/browser_window.h | 38 +---------------------- include/netsurf/console.h | 65 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 37 deletions(-) create mode 100644 include/netsurf/console.h (limited to 'include/netsurf') diff --git a/include/netsurf/browser_window.h b/include/netsurf/browser_window.h index 9c6fe7a31..e701aa3a3 100644 --- a/include/netsurf/browser_window.h +++ b/include/netsurf/browser_window.h @@ -30,6 +30,7 @@ #include "utils/errors.h" #include "netsurf/mouse.h" +#include "netsurf/console.h" struct browser_window; struct hlcache_handle; @@ -143,43 +144,6 @@ struct browser_window_features { } form_features; }; -/** - * Sources of messages which end up in the browser window console - */ -typedef enum { - BW_CS_INPUT, /**< Input from the client */ - BW_CS_SCRIPT_ERROR, /**< Error from some running script */ - BW_CS_SCRIPT_CONSOLE, /**< Logging from some running script */ -} browser_window_console_source; - -/** - * Flags for browser window console logging. - * - * It is valid to bitwise-or some of these flags together where indicated. - */ -typedef enum { - /** - * The log entry is foldable. - * - * Set this to indicate that the text should be folded on the first - * newline on display. If this is set but there are no newlines in - * the logged text, the core will unset it before passing on to - * callbacks or storing the log entry. - */ - BW_CS_FLAG_FOLDABLE = 1 << 0, - - /** Logged at the 'log' level, please only use one of the LEVEL flags */ - BW_CS_FLAG_LEVEL_LOG = 0 << 1, - /** Logged at the 'info' level, please use only one of the LEVEL flags */ - BW_CS_FLAG_LEVEL_INFO = 1 << 1, - /** Logged at the 'warn' level, please use only one of the LEVEL flags */ - BW_CS_FLAG_LEVEL_WARN = 2 << 1, - /** Logged at the 'error' level, please use only one of the LEVEL flags */ - BW_CS_FLAG_LEVEL_ERROR = 3 << 1, - /** Mask for the error level to allow easy comparison using the above */ - BW_CS_FLAG_LEVEL_MASK = 3 << 1, -} browser_window_console_flags; - /** * Create and open a new root browser window with the given page. * diff --git a/include/netsurf/console.h b/include/netsurf/console.h new file mode 100644 index 000000000..31ed0e787 --- /dev/null +++ b/include/netsurf/console.h @@ -0,0 +1,65 @@ +/* + * Copyright 2019 Daniel Silverstone + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file + * Browser window console stuff + */ + +#ifndef _NETSURF_CONSOLE_H_ +#define _NETSURF_CONSOLE_H_ + +/** + * Sources of messages which end up in the browser window console + */ +typedef enum { + BW_CS_INPUT, /**< Input from the client */ + BW_CS_SCRIPT_ERROR, /**< Error from some running script */ + BW_CS_SCRIPT_CONSOLE, /**< Logging from some running script */ +} browser_window_console_source; + +/** + * Flags for browser window console logging. + * + * It is valid to bitwise-or some of these flags together where indicated. + */ +typedef enum { + /** + * The log entry is foldable. + * + * Set this to indicate that the text should be folded on the first + * newline on display. If this is set but there are no newlines in + * the logged text, the core will unset it before passing on to + * callbacks or storing the log entry. + */ + BW_CS_FLAG_FOLDABLE = 1 << 0, + + /** Logged at the 'log' level, please only use one of the LEVEL flags */ + BW_CS_FLAG_LEVEL_LOG = 0 << 1, + /** Logged at the 'info' level, please use only one of the LEVEL flags */ + BW_CS_FLAG_LEVEL_INFO = 1 << 1, + /** Logged at the 'warn' level, please use only one of the LEVEL flags */ + BW_CS_FLAG_LEVEL_WARN = 2 << 1, + /** Logged at the 'error' level, please use only one of the LEVEL flags */ + BW_CS_FLAG_LEVEL_ERROR = 3 << 1, + /** Mask for the error level to allow easy comparison using the above */ + BW_CS_FLAG_LEVEL_MASK = 3 << 1, +} browser_window_console_flags; + +#endif /* _NETSURF_CONSOLE_H_ */ + -- cgit v1.2.3