File: alog-facilities-pgsql.ads

## Documentation

Table of Contents
Class Inheritance Tree

1.     --

2.     --  Copyright (c) 2008-2009,

3.     --  Reto Buerki, Adrian-Ken Rueegsegger

4.     --

5.     --  This file is part of Alog.

6.     --

7.     --  Alog is free software; you can redistribute it and/or modify

8.     --  it under the terms of the GNU Lesser General Public License as published

9.     --  by the Free Software Foundation; either version 2.1 of the License, or

10.     --  (at your option) any later version.

11.     --

12.     --  Alog is distributed in the hope that it will be useful,

13.     --  but WITHOUT ANY WARRANTY; without even the implied warranty of

14.     --  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

15.     --  GNU Lesser General Public License for more details.

16.     --

17.     --  You should have received a copy of the GNU Lesser General Public License

18.     --  along with Alog; if not, write to the Free Software

19.     --  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,

20.     --  MA  02110-1301  USA

21.     --

23.     with APQ.PostgreSQL.Client;

25.     --  PGSQL facility. Used to log to a Postgresql database.

26.     package Alog.Facilities.PgsqlTo API docTo specTo body is

28.        type InstanceTo API docTo body is new Alog.Facilities.InstanceTo API docTo specTo body with private;

29.        --  PGSQL logging facility.

31.        type Handle is access all InstanceTo API docTo specTo body;

33.        overriding

34.        procedure SetupTo API docTo body (FacilityTo API docTo body : in out InstanceTo API docTo specTo body);

35.        --  Implementation of Setup-procedure.

37.        overriding

38.        procedure TeardownTo API docTo body (FacilityTo API docTo body : in out InstanceTo API docTo specTo body);

39.        --  Implementation of Teardown-procedure.

41.        procedure Set_Host_NameTo API docTo body (FacilityTo API docTo body : in out InstanceTo API docTo specTo body; Hostname : String);

42.        --  Set hostname of database server.

44.        function Get_Host_NameTo API docTo body (FacilityTo API docTo body : InstanceTo API docTo specTo body) return String;

45.        --  Get hostname of database server.

47.        procedure Set_Host_AddressTo API docTo body (FacilityTo API docTo body : in out InstanceTo API docTo specTo body; Address : String);

48.        --  Set ip address of database server.

50.        procedure Set_Host_PortTo API docTo body (FacilityTo API docTo body : in out InstanceTo API docTo specTo body; Port : Natural);

51.        --  Set port of database server.

53.        function Get_Host_PortTo API docTo body (FacilityTo API docTo body : InstanceTo API docTo specTo body) return Natural;

54.        --  Get port of database server.

56.        procedure Set_SQL_TraceTo API docTo body

57.          (FacilityTo API docTo body : in out InstanceTo API docTo specTo body;

58.           Filename :        String;

59.           ModeTo API docTo body     :        APQ.Trace_Mode_Type);

60.        --  Set SQL trace parameters.

62.        procedure Toggle_SQL_TraceTo API docTo body

63.          (FacilityTo API docTo body : in out InstanceTo API docTo specTo body;

64.           State    :        Boolean);

65.        --  Toggles tracing of SQL statements.

67.        function Is_SQL_TraceTo API docTo body (FacilityTo API docTo body : InstanceTo API docTo specTo body) return Boolean;

68.        --  Tells whether sql tracing is enabled.

70.        procedure Set_DB_NameTo API docTo body (FacilityTo API docTo body : in out InstanceTo API docTo specTo body; DB_Name : String);

71.        --  Set name of database.

73.        function Get_DB_NameTo API docTo body (FacilityTo API docTo body : InstanceTo API docTo specTo body) return String;

74.        --  Get name of database.

76.        procedure Set_Table_NameTo API docTo body (FacilityTo API docTo body : in out InstanceTo API docTo specTo body; Table_Name : String);

77.        --  Set name of database table.

79.        function Get_Table_NameTo API docTo body (FacilityTo API docTo body : InstanceTo API docTo specTo body) return String;

80.        --  Get name of database table.

82.        procedure Set_Level_Column_NameTo API docTo body

83.          (FacilityTo API docTo body    : in out InstanceTo API docTo specTo body;

84.           Column_Name : String);

85.        --  Set name of log level column.

87.        function Get_Level_Column_NameTo API docTo body (FacilityTo API docTo body : InstanceTo API docTo specTo body) return String;

88.        --  Get name of log level column.

90.        procedure Set_Timestamp_Column_NameTo API docTo body

91.          (FacilityTo API docTo body    : in out InstanceTo API docTo specTo body;

92.           Column_Name : String);

93.        --  Set name of log level column.

95.        function Get_Timestamp_Column_NameTo API docTo body (FacilityTo API docTo body : InstanceTo API docTo specTo body) return String;

96.        --  Get name of timestamp column.

98.        procedure Set_Message_Column_NameTo API docTo body

99.          (FacilityTo API docTo body    : in out InstanceTo API docTo specTo body;

100.           Column_Name : String);

101.        --  Set name of log message column.

103.        function Get_Message_Column_NameTo API docTo body (FacilityTo API docTo body : InstanceTo API docTo specTo body) return String;

104.        --  Get name of log message column.

106.        procedure Set_CredentialsTo API docTo body

107.          (FacilityTo API docTo body : in out InstanceTo API docTo specTo body;

108.           Username :        String;

109.           Password :        String);

110.        --  Set credentials for the database connection.

112.        function Get_CredentialsTo API docTo body (FacilityTo API docTo body : InstanceTo API docTo specTo body) return String;

113.        --  Get credentials of database connection. Only the username is returned.

115.        procedure Close_ConnectionTo API docTo body (FacilityTo API docTo body : in out InstanceTo API docTo specTo body);

116.        --  Close open database connection.

118.     private

120.        overriding

121.        procedure Write

122.          (Facility : InstanceTo API docTo specTo body;

123.           Level    : Log_LevelTo API docTo spec := Info;

124.           Msg      : String);

125.        --  Implementation of the Write procedure for PGSQL.

127.        type Log_SQL_Table is tagged record

128.           Name             : Unbounded_String := To_Unbounded_String ("alog");

129.           Level_Column     : Unbounded_String := To_Unbounded_String ("level");

130.           Timestamp_Column : Unbounded_String := To_Unbounded_String ("timestamp");

131.           Message_Column   : Unbounded_String := To_Unbounded_String ("message");

132.        end record;

133.        --  Holds Table/Column name information.

135.        type InstanceTo API docTo spec is new Alog.Facilities.InstanceTo API docTo specTo body with record

136.           Log_Connection   : APQ.PostgreSQL.Client.Connection_Type;

137.           --  Database connection used for logging.

139.           Trace_Filename   : Unbounded_String :=

140.             To_Unbounded_String ("./trace.sql");

141.           Trace_Mode       :  APQ.Trace_Mode_Type := APQ.Trace_APQ;

142.           --  SQL trace parameters

144.           Log_Table        : Log_SQL_Table;

145.           --  Table to insert messages

146.        end record;

148.     end Alog.Facilities.PgsqlTo API docTo specTo body;