gooderp18绿色标准版
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

101 Zeilen
2.9KB

  1. /*-------------------------------------------------------------------------
  2. *
  3. * syslogger.h
  4. * Exports from postmaster/syslogger.c.
  5. *
  6. * Copyright (c) 2004-2019, PostgreSQL Global Development Group
  7. *
  8. * src/include/postmaster/syslogger.h
  9. *
  10. *-------------------------------------------------------------------------
  11. */
  12. #ifndef _SYSLOGGER_H
  13. #define _SYSLOGGER_H
  14. #include <limits.h> /* for PIPE_BUF */
  15. /*
  16. * Primitive protocol structure for writing to syslogger pipe(s). The idea
  17. * here is to divide long messages into chunks that are not more than
  18. * PIPE_BUF bytes long, which according to POSIX spec must be written into
  19. * the pipe atomically. The pipe reader then uses the protocol headers to
  20. * reassemble the parts of a message into a single string. The reader can
  21. * also cope with non-protocol data coming down the pipe, though we cannot
  22. * guarantee long strings won't get split apart.
  23. *
  24. * We use non-nul bytes in is_last to make the protocol a tiny bit
  25. * more robust against finding a false double nul byte prologue. But
  26. * we still might find it in the len and/or pid bytes unless we're careful.
  27. */
  28. #ifdef PIPE_BUF
  29. /* Are there any systems with PIPE_BUF > 64K? Unlikely, but ... */
  30. #if PIPE_BUF > 65536
  31. #define PIPE_CHUNK_SIZE 65536
  32. #else
  33. #define PIPE_CHUNK_SIZE ((int) PIPE_BUF)
  34. #endif
  35. #else /* not defined */
  36. /* POSIX says the value of PIPE_BUF must be at least 512, so use that */
  37. #define PIPE_CHUNK_SIZE 512
  38. #endif
  39. typedef struct
  40. {
  41. char nuls[2]; /* always \0\0 */
  42. uint16 len; /* size of this chunk (counts data only) */
  43. int32 pid; /* writer's pid */
  44. char is_last; /* last chunk of message? 't' or 'f' ('T' or
  45. * 'F' for CSV case) */
  46. char data[FLEXIBLE_ARRAY_MEMBER]; /* data payload starts here */
  47. } PipeProtoHeader;
  48. typedef union
  49. {
  50. PipeProtoHeader proto;
  51. char filler[PIPE_CHUNK_SIZE];
  52. } PipeProtoChunk;
  53. #define PIPE_HEADER_SIZE offsetof(PipeProtoHeader, data)
  54. #define PIPE_MAX_PAYLOAD ((int) (PIPE_CHUNK_SIZE - PIPE_HEADER_SIZE))
  55. /* GUC options */
  56. extern bool Logging_collector;
  57. extern int Log_RotationAge;
  58. extern int Log_RotationSize;
  59. extern PGDLLIMPORT char *Log_directory;
  60. extern PGDLLIMPORT char *Log_filename;
  61. extern bool Log_truncate_on_rotation;
  62. extern int Log_file_mode;
  63. extern bool am_syslogger;
  64. #ifndef WIN32
  65. extern int syslogPipe[2];
  66. #else
  67. extern HANDLE syslogPipe[2];
  68. #endif
  69. extern int SysLogger_Start(void);
  70. extern void write_syslogger_file(const char *buffer, int count, int dest);
  71. #ifdef EXEC_BACKEND
  72. extern void SysLoggerMain(int argc, char *argv[]) pg_attribute_noreturn();
  73. #endif
  74. extern bool CheckLogrotateSignal(void);
  75. extern void RemoveLogrotateSignalFiles(void);
  76. /*
  77. * Name of files saving meta-data information about the log
  78. * files currently in use by the syslogger
  79. */
  80. #define LOG_METAINFO_DATAFILE "current_logfiles"
  81. #define LOG_METAINFO_DATAFILE_TMP LOG_METAINFO_DATAFILE ".tmp"
  82. #endif /* _SYSLOGGER_H */
上海开阖软件有限公司 沪ICP备12045867号-1