#include "abi.h"
#include <stdarg.h>
#include <stdio.h>

void
gcSystemLog(GCPluginInterface interface, GCLogLevel level, const char* message, ...)
{
    if (level > interface->logLevel)
        return;

    va_list args;
    va_start(args, message);

    char buffer[1000];
    if (vsnprintf(buffer, sizeof(buffer), message, args) > 0)
        interface->logSystemCallback(interface->ctx, level, buffer);
    va_end(args);
}

void
gcAuditLog(GCPluginInterface interface, const char* message, ...)
{
    va_list args;
    va_start(args, message);

    char buffer[1000];
    if (vsnprintf(buffer, sizeof(buffer), message, args) > 0)
        interface->logAuditCallback(interface->ctx, message);

    va_end(args);
}

void
gcReleaseDatapointValue(GCPluginInterface interface, GCDatapointValue dataValue)
{
    interface->releaseDatapointValueCallback(dataValue);
}

bool
gcPublishDatapointValue(GCPluginInterface interface, GCDatapointValue dataValue)
{
    return interface->publishDatapointValueCallback(interface->ctx, dataValue);
}
