unit Chilkat.Log;

{
  Pascal wrapper for Chilkat Log.
  Auto-generated by PascalWrapperGenerator -- do not edit manually.
}

{$IFDEF FPC}
  {$MODE DELPHI}
{$ENDIF}

interface

uses
  SysUtils,
  Chilkat.Base;

type

  { TLog wraps CkLog via the C bridge layer. }
  TLog = class(TChilkatBase)
  private
    function  GetLastErrorHtml: string;
    function  GetLastErrorText: string;
    function  GetLastErrorXml: string;
    function  GetVersion: string;
    function  GetDebugLogFilePath: string;
    procedure SetDebugLogFilePath(AValue: string);
    function  GetVerboseLogging: Boolean;
    procedure SetVerboseLogging(AValue: Boolean);
    function  GetLastMethodSuccess: Boolean;
    procedure SetLastMethodSuccess(AValue: Boolean);
  public
    constructor Create;
    destructor  Destroy; override;

    property LastErrorHtml: string read GetLastErrorHtml;
    property LastErrorText: string read GetLastErrorText;
    property LastErrorXml: string read GetLastErrorXml;
    property Version: string read GetVersion;
    property DebugLogFilePath: string read GetDebugLogFilePath write SetDebugLogFilePath;
    property VerboseLogging: Boolean read GetVerboseLogging write SetVerboseLogging;
    property LastMethodSuccess: Boolean read GetLastMethodSuccess write SetLastMethodSuccess;

    procedure Clear(const initialTag: string);
    procedure EnterContext(const tag: string);
    procedure LeaveContext;
    procedure LogData(const tag: string; const message: string);
    procedure LogDataMax(const tag: string; const message: string; maxNumChars: Integer);
    procedure LogDateTime(const tag: string; gmt: Boolean);
    procedure LogError(const message: string);
    procedure LogInfo(const message: string);
    procedure LogInt(const tag: string; value: Integer);
    procedure LogInt64(const tag: string; value: Int64);
    procedure LogTimestamp(const tag: string);
    procedure LogDataHex2(const tag: string; pByteData: Pointer; szByteData: LongWord);
    procedure LogDataBase64_2(const tag: string; pByteData: Pointer; szByteData: LongWord);
    procedure LogHash2(const tag: string; const hashAlg: string; pByteData: Pointer; szByteData: LongWord);
  end;

implementation

uses
  CkDllLoader,
  Chilkat.Utils;

{ ---- C bridge function pointer types ---- }
type
  TCkLog_Create  = function(): Pointer; cdecl;
  TCkLog_Dispose = procedure(handle: Pointer); cdecl;
  TCkLog_get_LastErrorHtml = function(handle: Pointer): PAnsiChar; cdecl;
  TCkLog_get_LastErrorText = function(handle: Pointer): PAnsiChar; cdecl;
  TCkLog_get_LastErrorXml = function(handle: Pointer): PAnsiChar; cdecl;
  TCkLog_get_Version = function(handle: Pointer): PAnsiChar; cdecl;
  TCkLog_get_DebugLogFilePath = function(handle: Pointer): PAnsiChar; cdecl;
  TCkLog_put_DebugLogFilePath = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkLog_get_VerboseLogging = function(handle: Pointer): LongBool; cdecl;
  TCkLog_put_VerboseLogging = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkLog_get_LastMethodSuccess = function(handle: Pointer): LongBool; cdecl;
  TCkLog_put_LastMethodSuccess = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkLog_Clear = procedure(handle: Pointer; initialTag: PAnsiChar); cdecl;
  TCkLog_EnterContext = procedure(handle: Pointer; tag: PAnsiChar); cdecl;
  TCkLog_LeaveContext = procedure(handle: Pointer); cdecl;
  TCkLog_LogData = procedure(handle: Pointer; tag: PAnsiChar; message: PAnsiChar); cdecl;
  TCkLog_LogDataMax = procedure(handle: Pointer; tag: PAnsiChar; message: PAnsiChar; maxNumChars: Integer); cdecl;
  TCkLog_LogDateTime = procedure(handle: Pointer; tag: PAnsiChar; gmt: LongBool); cdecl;
  TCkLog_LogError = procedure(handle: Pointer; message: PAnsiChar); cdecl;
  TCkLog_LogInfo = procedure(handle: Pointer; message: PAnsiChar); cdecl;
  TCkLog_LogInt = procedure(handle: Pointer; tag: PAnsiChar; value: Integer); cdecl;
  TCkLog_LogInt64 = procedure(handle: Pointer; tag: PAnsiChar; value: Int64); cdecl;
  TCkLog_LogTimestamp = procedure(handle: Pointer; tag: PAnsiChar); cdecl;
  TCkLog_LogDataHex2 = procedure(handle: Pointer; tag: PAnsiChar; pByteData: Pointer; szByteData: LongWord); cdecl;
  TCkLog_LogDataBase64_2 = procedure(handle: Pointer; tag: PAnsiChar; pByteData: Pointer; szByteData: LongWord); cdecl;
  TCkLog_LogHash2 = procedure(handle: Pointer; tag: PAnsiChar; hashAlg: PAnsiChar; pByteData: Pointer; szByteData: LongWord); cdecl;

{ ---- C bridge function pointer variables ---- }
var
  CkLog_Create:  TCkLog_Create  = nil;
  CkLog_Dispose: TCkLog_Dispose = nil;
  CkLog_get_LastErrorHtml: TCkLog_get_LastErrorHtml = nil;
  CkLog_get_LastErrorText: TCkLog_get_LastErrorText = nil;
  CkLog_get_LastErrorXml: TCkLog_get_LastErrorXml = nil;
  CkLog_get_Version: TCkLog_get_Version = nil;
  CkLog_get_DebugLogFilePath: TCkLog_get_DebugLogFilePath = nil;
  CkLog_put_DebugLogFilePath: TCkLog_put_DebugLogFilePath = nil;
  CkLog_get_VerboseLogging: TCkLog_get_VerboseLogging = nil;
  CkLog_put_VerboseLogging: TCkLog_put_VerboseLogging = nil;
  CkLog_get_LastMethodSuccess: TCkLog_get_LastMethodSuccess = nil;
  CkLog_put_LastMethodSuccess: TCkLog_put_LastMethodSuccess = nil;
  CkLog_Clear: TCkLog_Clear = nil;
  CkLog_EnterContext: TCkLog_EnterContext = nil;
  CkLog_LeaveContext: TCkLog_LeaveContext = nil;
  CkLog_LogData: TCkLog_LogData = nil;
  CkLog_LogDataMax: TCkLog_LogDataMax = nil;
  CkLog_LogDateTime: TCkLog_LogDateTime = nil;
  CkLog_LogError: TCkLog_LogError = nil;
  CkLog_LogInfo: TCkLog_LogInfo = nil;
  CkLog_LogInt: TCkLog_LogInt = nil;
  CkLog_LogInt64: TCkLog_LogInt64 = nil;
  CkLog_LogTimestamp: TCkLog_LogTimestamp = nil;
  CkLog_LogDataHex2: TCkLog_LogDataHex2 = nil;
  CkLog_LogDataBase64_2: TCkLog_LogDataBase64_2 = nil;
  CkLog_LogHash2: TCkLog_LogHash2 = nil;

constructor TLog.Create;
begin
  inherited Create;
  FHandle := CkLog_Create();
end;

destructor TLog.Destroy;
begin
  if FHandle <> nil then
    CkLog_Dispose(FHandle);
  FHandle := nil;
  inherited;
end;

function TLog.GetLastErrorHtml: string;
begin
  Result := CkToStr(CkLog_get_LastErrorHtml(FHandle));
end;

function TLog.GetLastErrorText: string;
begin
  Result := CkToStr(CkLog_get_LastErrorText(FHandle));
end;

function TLog.GetLastErrorXml: string;
begin
  Result := CkToStr(CkLog_get_LastErrorXml(FHandle));
end;

function TLog.GetVersion: string;
begin
  Result := CkToStr(CkLog_get_Version(FHandle));
end;

function TLog.GetDebugLogFilePath: string;
begin
  Result := CkToStr(CkLog_get_DebugLogFilePath(FHandle));
end;

procedure TLog.SetDebugLogFilePath(AValue: string);
begin
  CkLog_put_DebugLogFilePath(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TLog.GetVerboseLogging: Boolean;
begin
  Result := Boolean(CkLog_get_VerboseLogging(FHandle));
end;

procedure TLog.SetVerboseLogging(AValue: Boolean);
begin
  CkLog_put_VerboseLogging(FHandle, LongBool(AValue));
end;

function TLog.GetLastMethodSuccess: Boolean;
begin
  Result := Boolean(CkLog_get_LastMethodSuccess(FHandle));
end;

procedure TLog.SetLastMethodSuccess(AValue: Boolean);
begin
  CkLog_put_LastMethodSuccess(FHandle, LongBool(AValue));
end;

procedure TLog.Clear(const initialTag: string);
begin
  CkLog_Clear(FHandle, PAnsiChar(StrToCk(initialTag)));
end;

procedure TLog.EnterContext(const tag: string);
begin
  CkLog_EnterContext(FHandle, PAnsiChar(StrToCk(tag)));
end;

procedure TLog.LeaveContext;
begin
  CkLog_LeaveContext(FHandle);
end;

procedure TLog.LogData(const tag: string; const message: string);
begin
  CkLog_LogData(FHandle, PAnsiChar(StrToCk(tag)), PAnsiChar(StrToCk(message)));
end;

procedure TLog.LogDataMax(const tag: string; const message: string; maxNumChars: Integer);
begin
  CkLog_LogDataMax(FHandle, PAnsiChar(StrToCk(tag)), PAnsiChar(StrToCk(message)), maxNumChars);
end;

procedure TLog.LogDateTime(const tag: string; gmt: Boolean);
begin
  CkLog_LogDateTime(FHandle, PAnsiChar(StrToCk(tag)), LongBool(gmt));
end;

procedure TLog.LogError(const message: string);
begin
  CkLog_LogError(FHandle, PAnsiChar(StrToCk(message)));
end;

procedure TLog.LogInfo(const message: string);
begin
  CkLog_LogInfo(FHandle, PAnsiChar(StrToCk(message)));
end;

procedure TLog.LogInt(const tag: string; value: Integer);
begin
  CkLog_LogInt(FHandle, PAnsiChar(StrToCk(tag)), value);
end;

procedure TLog.LogInt64(const tag: string; value: Int64);
begin
  CkLog_LogInt64(FHandle, PAnsiChar(StrToCk(tag)), value);
end;

procedure TLog.LogTimestamp(const tag: string);
begin
  CkLog_LogTimestamp(FHandle, PAnsiChar(StrToCk(tag)));
end;

procedure TLog.LogDataHex2(const tag: string; pByteData: Pointer; szByteData: LongWord);
begin
  CkLog_LogDataHex2(FHandle, PAnsiChar(StrToCk(tag)), pByteData, szByteData);
end;

procedure TLog.LogDataBase64_2(const tag: string; pByteData: Pointer; szByteData: LongWord);
begin
  CkLog_LogDataBase64_2(FHandle, PAnsiChar(StrToCk(tag)), pByteData, szByteData);
end;

procedure TLog.LogHash2(const tag: string; const hashAlg: string; pByteData: Pointer; szByteData: LongWord);
begin
  CkLog_LogHash2(FHandle, PAnsiChar(StrToCk(tag)), PAnsiChar(StrToCk(hashAlg)), pByteData, szByteData);
end;

initialization
  Chilkat_GetProcedureAddress(CkLog_Create,  'CkLog_Create');
  Chilkat_GetProcedureAddress(CkLog_Dispose, 'CkLog_Dispose');
  Chilkat_GetProcedureAddress(CkLog_get_LastErrorHtml, 'CkLog_get_LastErrorHtml');
  Chilkat_GetProcedureAddress(CkLog_get_LastErrorText, 'CkLog_get_LastErrorText');
  Chilkat_GetProcedureAddress(CkLog_get_LastErrorXml, 'CkLog_get_LastErrorXml');
  Chilkat_GetProcedureAddress(CkLog_get_Version, 'CkLog_get_Version');
  Chilkat_GetProcedureAddress(CkLog_get_DebugLogFilePath, 'CkLog_get_DebugLogFilePath');
  Chilkat_GetProcedureAddress(CkLog_put_DebugLogFilePath, 'CkLog_put_DebugLogFilePath');
  Chilkat_GetProcedureAddress(CkLog_get_VerboseLogging, 'CkLog_get_VerboseLogging');
  Chilkat_GetProcedureAddress(CkLog_put_VerboseLogging, 'CkLog_put_VerboseLogging');
  Chilkat_GetProcedureAddress(CkLog_get_LastMethodSuccess, 'CkLog_get_LastMethodSuccess');
  Chilkat_GetProcedureAddress(CkLog_put_LastMethodSuccess, 'CkLog_put_LastMethodSuccess');
  Chilkat_GetProcedureAddress(CkLog_Clear, 'CkLog_Clear');
  Chilkat_GetProcedureAddress(CkLog_EnterContext, 'CkLog_EnterContext');
  Chilkat_GetProcedureAddress(CkLog_LeaveContext, 'CkLog_LeaveContext');
  Chilkat_GetProcedureAddress(CkLog_LogData, 'CkLog_LogData');
  Chilkat_GetProcedureAddress(CkLog_LogDataMax, 'CkLog_LogDataMax');
  Chilkat_GetProcedureAddress(CkLog_LogDateTime, 'CkLog_LogDateTime');
  Chilkat_GetProcedureAddress(CkLog_LogError, 'CkLog_LogError');
  Chilkat_GetProcedureAddress(CkLog_LogInfo, 'CkLog_LogInfo');
  Chilkat_GetProcedureAddress(CkLog_LogInt, 'CkLog_LogInt');
  Chilkat_GetProcedureAddress(CkLog_LogInt64, 'CkLog_LogInt64');
  Chilkat_GetProcedureAddress(CkLog_LogTimestamp, 'CkLog_LogTimestamp');
  Chilkat_GetProcedureAddress(CkLog_LogDataHex2, 'CkLog_LogDataHex2');
  Chilkat_GetProcedureAddress(CkLog_LogDataBase64_2, 'CkLog_LogDataBase64_2');
  Chilkat_GetProcedureAddress(CkLog_LogHash2, 'CkLog_LogHash2');

end.
