2020-10-13 19:40:52 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018-2020 WireGuard LLC. All Rights Reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2020-10-17 15:11:34 +02:00
|
|
|
#include "wintun.h"
|
2020-10-31 11:55:26 +01:00
|
|
|
#include <Windows.h>
|
2020-10-13 19:40:52 +02:00
|
|
|
|
2020-10-31 23:08:00 +01:00
|
|
|
extern WINTUN_LOGGER_CALLBACK_FUNC Logger;
|
2020-10-13 19:40:52 +02:00
|
|
|
|
2020-10-17 15:11:34 +02:00
|
|
|
/**
|
|
|
|
* @copydoc WINTUN_SET_LOGGER_FUNC
|
|
|
|
*/
|
|
|
|
void WINAPI
|
2020-10-31 23:08:00 +01:00
|
|
|
WintunSetLogger(_In_ WINTUN_LOGGER_CALLBACK_FUNC NewLogger);
|
2020-10-13 19:40:52 +02:00
|
|
|
|
2020-11-04 12:24:46 +01:00
|
|
|
_Post_equals_last_error_ DWORD
|
|
|
|
LoggerLog(_In_ WINTUN_LOGGER_LEVEL Level, _In_z_ const WCHAR *Function, _In_z_ const WCHAR *LogLine);
|
2020-11-03 12:29:34 +01:00
|
|
|
|
2020-10-13 19:40:52 +02:00
|
|
|
_Post_equals_last_error_ DWORD
|
2020-11-04 12:24:46 +01:00
|
|
|
LoggerError(_In_z_ const WCHAR *Function, _In_z_ const WCHAR *Prefix, _In_ DWORD Error);
|
2020-10-13 19:40:52 +02:00
|
|
|
|
2020-11-01 03:19:21 +01:00
|
|
|
static inline _Post_equals_last_error_ DWORD
|
2020-11-04 12:24:46 +01:00
|
|
|
LoggerLastError(_In_z_ const WCHAR *Function, _In_z_ const WCHAR *Prefix)
|
2020-10-13 19:40:52 +02:00
|
|
|
{
|
2020-11-03 12:29:34 +01:00
|
|
|
DWORD LastError = GetLastError();
|
2020-11-04 12:24:46 +01:00
|
|
|
LoggerError(Prefix, Function, LastError);
|
2020-11-03 12:29:34 +01:00
|
|
|
SetLastError(LastError);
|
|
|
|
return LastError;
|
2020-10-13 19:40:52 +02:00
|
|
|
}
|
|
|
|
|
2020-11-03 11:42:48 +01:00
|
|
|
#define __L(x) L##x
|
|
|
|
#define _L(x) __L(x)
|
2020-11-04 12:24:46 +01:00
|
|
|
#define LOG(lvl, msg) (LoggerLog((lvl), _L(__FUNCTION__), msg))
|
|
|
|
#define LOG_ERROR(msg, err) (LoggerError(_L(__FUNCTION__), msg, (err)))
|
|
|
|
#define LOG_LAST_ERROR(msg) (LoggerLastError(_L(__FUNCTION__), msg))
|