| 1 |
/* |
| 2 |
* Logging.h |
| 3 |
* C Interface to log window functions |
| 4 |
* |
| 5 |
* Written by: Ken McLeod, 2026-01-16 |
| 6 |
* Last update: 2026-01-31 |
| 7 |
* |
| 8 |
* This software is provided as-is, with no warranties expressed or implied, |
| 9 |
* under the terms of the BSD 2-Clause License. See separate "LICENSE" file. |
| 10 |
*/ |
| 11 |
|
| 12 |
#ifndef __LOGGING_UTILS__ |
| 13 |
#define __LOGGING_UTILS__ |
| 14 |
|
| 15 |
#include <Types.h> |
| 16 |
#include <TextEdit.h> |
| 17 |
#include <Controls.h> |
| 18 |
#include <Events.h> |
| 19 |
|
| 20 |
/* log levels */ |
| 21 |
#define LOG_ERR 0 /* errors and minimal operation notifications */ |
| 22 |
#define LOG_WARN 1 /* all of the above, plus warning messages */ |
| 23 |
#define LOG_INFO 2 /* all of the above, plus full protocol messages */ |
| 24 |
#define LOG_DEBUG 3 /* print everything, including data received */ |
| 25 |
|
| 26 |
#define LOG_ERR_X (LOG_ERR|0x8000) /* add ERROR: prefix to message */ |
| 27 |
#define LOG_WARN_X (LOG_WARN|0x8000) /* add WARNING: prefix to message */ |
| 28 |
#define LOG_INFO_X (LOG_INFO|0x8000) /* add INFO: prefix to message */ |
| 29 |
#define LOG_DEBUG_X (LOG_DEBUG|0x8000) /* add DEBUG: prefix to message */ |
| 30 |
|
| 31 |
#ifdef __cplusplus |
| 32 |
extern "C" { |
| 33 |
#endif |
| 34 |
|
| 35 |
int LogLevel(void); |
| 36 |
void SetLogLevel(int newLevel); |
| 37 |
|
| 38 |
Boolean InitLogWindow(int logWindowID, WindowPtr *window, |
| 39 |
TEHandle *textTE, ControlHandle *scrollBar); |
| 40 |
|
| 41 |
void UnloadLogWindow(void); |
| 42 |
void UpdateLogWindow(void); |
| 43 |
void ActivateLogWindow(Boolean active); |
| 44 |
void GrowLogWindow(short h, short v); |
| 45 |
void ShowLogWindow(Rect *r); |
| 46 |
void HandleMouseInText(EventRecord *myEvent); |
| 47 |
void AdjustTextScrollBar(void); |
| 48 |
|
| 49 |
void Message(int level, char *mess); |
| 50 |
void MessageWithIntValue(int level, char *mess, long int value); |
| 51 |
void MessageWithQuotedString(int level, char *mess, char *str); |
| 52 |
void MessageWithDataPointer(int level, char *mess, char *data, int dataLen); |
| 53 |
void MessageWithNetAddr(int level, char *mess, short net, char node, char socket); |
| 54 |
void MessageReceivedFromNetAddr(int level, int funcID, Boolean isResp, short net, char node, char socket); |
| 55 |
void MessageSentToNetAddr(int level, int funcID, Boolean isResp, short net, char node, char socket); |
| 56 |
|
| 57 |
#ifdef __cplusplus |
| 58 |
} |
| 59 |
#endif |
| 60 |
|
| 61 |
#endif /* __LOGGING_UTILS__ */ |