From f9923d7b76d5c121f06f861273e6caf8a286b19e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 29 Oct 2020 18:16:59 +0100 Subject: 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. --- bindings/cxx/include/pugl/pugl.hpp | 23 --------------------- include/pugl/pugl.h | 36 -------------------------------- src/implementation.c | 42 -------------------------------------- src/types.h | 2 -- src/x11.c | 14 +++++-------- 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 #include #include -#include #include #include #include @@ -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; - /** 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( - puglSetLogLevel(cobj(), static_cast(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. @@ -710,23 +691,6 @@ puglGetWorldHandle(PuglWorld* world); 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. 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 #include -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"); @@ -160,22 +134,6 @@ puglGetWorldHandle(PuglWorld* world) return world->handle; } -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) { 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 diff --git a/src/x11.c b/src/x11.c index 18f8521..b462dd0 100644 --- a/src/x11.c +++ b/src/x11.c @@ -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; -- cgit v1.2.1