#include "IZ_log.h"

void IZ_LogHandleFromWS(i32 level, const char* line) {
	switch (level) {
		case LLL_ERR:
			SDL_LogError(SDL_LOG_CATEGORY_ERROR, "%s", line);
			return;
		case LLL_WARN:
			SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "%s", line);
			return;
		case LLL_NOTICE:
			SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "%s", line);
			return;
		case LLL_USER:
		default:
			break;
	}

	SDL_Log("%s", line);
}

void IZ_LogInterceptWSMessages(i32 level) {
	lws_set_log_level(level, IZ_LogHandleFromWS);
}
