forked from fmbiete/pgauditlogtofile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logtofile_vars.h
73 lines (62 loc) · 2.01 KB
/
logtofile_vars.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*-------------------------------------------------------------------------
*
* logtofile_vars.h
* Global variables for logtofile
*
* Copyright (c) 2020-2024, Francisco Miguel Biete Banon
*
* This code is released under the PostgreSQL licence, as given at
* http://www.postgresql.org/about/licence/
*-------------------------------------------------------------------------
*/
#ifndef _LOGTOFILE_VARS_H_
#define _LOGTOFILE_VARS_H_
#include <postgres.h>
#include <datatype/timestamp.h>
#include <miscadmin.h>
#include <pgtime.h>
#include <port/atomics.h>
#include <storage/ipc.h>
#include <storage/lwlock.h>
#include <pthread.h>
// Guc
extern char *guc_pgaudit_ltf_log_directory;
extern char *guc_pgaudit_ltf_log_filename;
extern int guc_pgaudit_ltf_log_rotation_age;
extern bool guc_pgaudit_ltf_log_connections;
extern bool guc_pgaudit_ltf_log_disconnections;
extern int guc_pgaudit_ltf_auto_close_minutes;
// Audit log file handler
extern FILE *pgaudit_ltf_file_handler;
// Background auto-close file handler
extern pg_atomic_flag pgaudit_ltf_autoclose_flag_thread;
extern pthread_t pgaudit_ltf_autoclose_thread;
extern pthread_attr_t pgaudit_ltf_autoclose_thread_attr;
extern Timestamp pgaudit_ltf_autoclose_active_ts;
// Hook log
extern emit_log_hook_type pgaudit_ltf_prev_emit_log_hook;
// Shared Memory types
typedef struct PgAuditLogToFilePrefix
{
char *prefix;
int length;
} PgAuditLogToFilePrefix;
typedef struct pgAuditLogToFileShm
{
LWLock *lock;
PgAuditLogToFilePrefix **prefixes_connection;
size_t num_prefixes_connection;
PgAuditLogToFilePrefix **prefixes_disconnection;
size_t num_prefixes_disconnection;
char filename[MAXPGPATH];
pg_time_t next_rotation_time;
} PgAuditLogToFileShm;
// Shared Memory
extern PgAuditLogToFileShm *pgaudit_ltf_shm;
extern pg_atomic_flag pgaudit_ltf_flag_shutdown;
// Shared Memory - Hook
extern shmem_startup_hook_type pgaudit_ltf_prev_shmem_startup_hook;
#if (PG_VERSION_NUM >= 150000)
extern shmem_request_hook_type pgaudit_ltf_prev_shmem_request_hook;
#endif
#endif