diff options
author | David Robillard <d@drobilla.net> | 2020-10-29 18:16:59 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-10-30 10:58:32 +0100 |
commit | f9923d7b76d5c121f06f861273e6caf8a286b19e (patch) | |
tree | b77bfe22b07e269912da6658e75c9eed8f8ca12c | |
parent | caf17373026a9de07ccd72edc282d46486257fb5 (diff) | |
download | pugl-f9923d7b76d5c121f06f861273e6caf8a286b19e.tar.gz pugl-f9923d7b76d5c121f06f861273e6caf8a286b19e.tar.bz2 pugl-f9923d7b76d5c121f06f861273e6caf8a286b19e.zip |
Remove logging API
This was missing from the C++ bindings and barely used anyway, so just remove
it for now in the interests of simplicity and finalizing a stable API.
The information previously logged in the X11 GL backend is now available
programatically, so applications can print the same information portably if
they like.
-rw-r--r-- | bindings/cxx/include/pugl/pugl.hpp | 23 | ||||
-rw-r--r-- | include/pugl/pugl.h | 36 | ||||
-rw-r--r-- | src/implementation.c | 42 | ||||
-rw-r--r-- | src/types.h | 2 | ||||
-rw-r--r-- | src/x11.c | 14 | ||||
-rw-r--r-- | src/x11_gl.c | 17 |
6 files changed, 5 insertions, 129 deletions
diff --git a/bindings/cxx/include/pugl/pugl.hpp b/bindings/cxx/include/pugl/pugl.hpp index 32680cd..bfe0706 100644 --- a/bindings/cxx/include/pugl/pugl.hpp +++ b/bindings/cxx/include/pugl/pugl.hpp @@ -27,7 +27,6 @@ #include <cassert> #include <chrono> #include <cstdint> -#include <functional> #include <memory> #include <stdexcept> #include <type_traits> @@ -236,20 +235,6 @@ static_assert(WorldFlag(PUGL_WORLD_THREADS) == WorldFlag::threads, ""); using WorldFlags = PuglWorldFlags; ///< @copydoc PuglWorldFlags -/// @copydoc PuglLogLevel -enum class LogLevel { - err = PUGL_LOG_LEVEL_ERR, ///< @copydoc PUGL_LOG_LEVEL_ERR - warning = PUGL_LOG_LEVEL_WARNING, ///< @copydoc PUGL_LOG_LEVEL_WARNING - info = PUGL_LOG_LEVEL_INFO, ///< @copydoc PUGL_LOG_LEVEL_INFO - debug = PUGL_LOG_LEVEL_DEBUG, ///< @copydoc PUGL_LOG_LEVEL_DEBUG -}; - -static_assert(LogLevel(PUGL_LOG_LEVEL_DEBUG) == LogLevel::debug, ""); - -/// @copydoc PuglLogFunc -using LogFunc = - std::function<void(World& world, LogLevel level, const char* msg)>; - /** A `std::chrono` compatible clock that uses Pugl time. */ @@ -310,14 +295,6 @@ public: /// @copydoc puglGetNativeWorld void* nativeWorld() { return puglGetNativeWorld(cobj()); } - // TODO: setLogFunc - - Status setLogLevel(const LogLevel level) - { - return static_cast<Status>( - puglSetLogLevel(cobj(), static_cast<PuglLogLevel>(level))); - } - /// @copydoc puglSetClassName Status setClassName(const char* const name) { diff --git a/include/pugl/pugl.h b/include/pugl/pugl.h index 14985b9..7c74b75 100644 --- a/include/pugl/pugl.h +++ b/include/pugl/pugl.h @@ -651,25 +651,6 @@ typedef enum { /// Bitwise OR of #PuglWorldFlag values typedef uint32_t PuglWorldFlags; -/// A log message level, compatible with syslog -typedef enum { - PUGL_LOG_LEVEL_ERR = 3, ///< Error - PUGL_LOG_LEVEL_WARNING = 4, ///< Warning - PUGL_LOG_LEVEL_INFO = 6, ///< Informational message - PUGL_LOG_LEVEL_DEBUG = 7 ///< Debug message -} PuglLogLevel; - -/** - A function called to report log messages. - - @param world The world that produced this log message. - @param level Log level. - @param msg Message string. -*/ -typedef void (*PuglLogFunc)(PuglWorld* world, - PuglLogLevel level, - const char* msg); - /** Create a new world. @@ -711,23 +692,6 @@ PUGL_API void* puglGetNativeWorld(PuglWorld* world); /** - Set the function to call to log a message. - - This will be called to report any log messages generated internally by Pugl - which are enabled according to the log level. -*/ -PUGL_API PuglStatus -puglSetLogFunc(PuglWorld* world, PuglLogFunc logFunc); - -/** - Set the level of log messages to emit. - - Any log messages with a level less than or equal to `level` will be emitted. -*/ -PUGL_API PuglStatus -puglSetLogLevel(PuglWorld* world, PuglLogLevel level); - -/** Set the class name of the application. This is a stable identifier for the application, used as the window diff --git a/src/implementation.c b/src/implementation.c index 74c6aea..da714cb 100644 --- a/src/implementation.c +++ b/src/implementation.c @@ -29,30 +29,6 @@ #include <stdlib.h> #include <string.h> -static const char* -puglLogLevelPrefix(const PuglLogLevel level) -{ - switch (level) { - case PUGL_LOG_LEVEL_ERR: - return "error: "; - case PUGL_LOG_LEVEL_WARNING: - return "warning: "; - case PUGL_LOG_LEVEL_INFO: - case PUGL_LOG_LEVEL_DEBUG: - return ""; - } - - return ""; -} - -static void -puglDefaultLogFunc(PuglWorld* PUGL_UNUSED(world), - PuglLogLevel level, - const char* msg) -{ - fprintf(stderr, "%s%s", puglLogLevelPrefix(level), msg); -} - const char* puglStrerror(const PuglStatus status) { @@ -131,8 +107,6 @@ puglNewWorld(PuglWorldType type, PuglWorldFlags flags) } world->startTime = puglGetTime(world); - world->logFunc = puglDefaultLogFunc; - world->logLevel = PUGL_LOG_LEVEL_INFO; puglSetString(&world->className, "Pugl"); @@ -161,22 +135,6 @@ puglGetWorldHandle(PuglWorld* world) } PuglStatus -puglSetLogFunc(PuglWorld* world, PuglLogFunc logFunc) -{ - world->logFunc = logFunc; - - return PUGL_SUCCESS; -} - -PuglStatus -puglSetLogLevel(PuglWorld* world, PuglLogLevel level) -{ - world->logLevel = level; - - return PUGL_SUCCESS; -} - -PuglStatus puglSetClassName(PuglWorld* const world, const char* const name) { puglSetString(&world->className, name); diff --git a/src/types.h b/src/types.h index e18eb87..a7c029a 100644 --- a/src/types.h +++ b/src/types.h @@ -83,12 +83,10 @@ struct PuglViewImpl { struct PuglWorldImpl { PuglWorldInternals* impl; PuglWorldHandle handle; - PuglLogFunc logFunc; char* className; double startTime; size_t numViews; PuglView** views; - PuglLogLevel logLevel; }; /// Opaque surface used by graphics backend @@ -360,15 +360,11 @@ puglRealize(PuglView* view) // Create input context const XIMStyle im_style = XIMPreeditNothing | XIMStatusNothing; - if (!(impl->xic = XCreateIC(world->impl->xim, - XNInputStyle, im_style, - XNClientWindow, win, - XNFocusWindow, win, - NULL))) { - view->world->logFunc(view->world, - PUGL_LOG_LEVEL_WARNING, - "XCreateID failed\n"); - } + impl->xic = XCreateIC(world->impl->xim, + XNInputStyle, im_style, + XNClientWindow, win, + XNFocusWindow, win, + NULL); #ifdef HAVE_XCURSOR puglDefineCursorShape(view, impl->cursorShape); diff --git a/src/x11_gl.c b/src/x11_gl.c index bab85c6..34ac7e8 100644 --- a/src/x11_gl.c +++ b/src/x11_gl.c @@ -109,23 +109,6 @@ puglX11GlConfigure(PuglView* view) view->hints[PUGL_DOUBLE_BUFFER] = puglX11GlGetAttrib( display, fbc[0], GLX_DOUBLEBUFFER); - char msg[256]; - - snprintf( - msg, - sizeof(msg), - "Using visual 0x%lX: R=%d G=%d B=%d A=%d D=%d DOUBLE=%d SAMPLES=%d\n", - impl->vi->visualid, - puglX11GlGetAttrib(display, fbc[0], GLX_RED_SIZE), - puglX11GlGetAttrib(display, fbc[0], GLX_GREEN_SIZE), - puglX11GlGetAttrib(display, fbc[0], GLX_BLUE_SIZE), - puglX11GlGetAttrib(display, fbc[0], GLX_ALPHA_SIZE), - puglX11GlGetAttrib(display, fbc[0], GLX_DEPTH_SIZE), - puglX11GlGetAttrib(display, fbc[0], GLX_DOUBLEBUFFER), - puglX11GlGetAttrib(display, fbc[0], GLX_SAMPLES)); - - view->world->logFunc(view->world, PUGL_LOG_LEVEL_INFO, msg); - XFree(fbc); return PUGL_SUCCESS; |