/* logger.h * * Copyright 2026 Francois Techene * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * Except as contained in this notice, the name(s) of the above copyright * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written * authorization. */ #ifndef LOGGER_H #define LOGGER_H //////////////////////////////////////////////// // Logger setup // #define USE_LOGGER // Comment to disable logs #define LOG_LEVEL DEBUG_LEVEL // NONE_LEVEL, ERROR_LEVEL, WARNING_LEVEL, INFO_LEVEL, DEBUG_LEVEL #define LOG_METHOD CONSOLE_OUT // NONE_OUT, CONSOLE_OUT, FILE_OUT #define LOG_FILE "::logs:output.log" // Change to the path to your log file // requires LOG_METHOD set to FILE_OUT #define CONSOLE_LINES 4 //////////////////////////////////////////////// typedef enum { NONE_LEVEL = 0, ERROR_LEVEL, WARNING_LEVEL, INFO_LEVEL, DEBUG_LEVEL } LogLevel; typedef enum { NONE_OUT = 0, CONSOLE_OUT, FILE_OUT } LogOutputMethod; #ifdef USE_LOGGER // Only load if required. typedef struct _LogConsole { WindowPtr window; TEHandle textArea; ControlHandle vScroll; Rect bounds; Rect origBounds; Rect growBounds; Rect prevBounds; Rect titleBar; Rect bottomBar; Rect view; Rect lowerBtn; Rect clearBtn; Rect closeBtn; Rect zoomBtn; Rect growBtn; int width; int height; int lineHeight; int contentHeight; int nbLines; int scrollPos; int maxScrollPos; int nbOutputLines; } LogConsole; #endif typedef struct _Logger { void (*print) (char* format, ...); void (*log) (char* format, ...); void (*debug) (char* format, ...); void (*info) (char* format, ...); void (*warn) (char* format, ...); void (*error) (char* format, ...); Boolean (*onEvent) (EventRecord event); #ifdef USE_LOGGER // Only load if required. LogConsole console; char* filePath; int outputMethod; int logLevel; char* newLine; #endif } Logger; extern Logger logger; void InitLogger(LogLevel level, LogOutputMethod out, char* file_path); Boolean DoLogEvent(EventRecord event); #endif