|
PostgreSQL Source Code git master
|
#include "postgres.h"#include <fcntl.h>#include <limits.h>#include <signal.h>#include <time.h>#include <unistd.h>#include <sys/stat.h>#include "common/file_perm.h"#include "lib/stringinfo.h"#include "libpq/pqsignal.h"#include "miscadmin.h"#include "nodes/pg_list.h"#include "pgstat.h"#include "pgtime.h"#include "port/pg_bitutils.h"#include "postmaster/interrupt.h"#include "postmaster/postmaster.h"#include "postmaster/syslogger.h"#include "storage/dsm.h"#include "storage/fd.h"#include "storage/ipc.h"#include "storage/latch.h"#include "storage/pg_shmem.h"#include "tcop/tcopprot.h"#include "utils/guc.h"#include "utils/memutils.h"#include "utils/ps_status.h"
Go to the source code of this file.
Data Structures | |
| struct | save_buffer |
| struct | SysloggerStartupData |
Macros | |
| #define | READ_BUF_SIZE (2 * PIPE_CHUNK_SIZE) |
| #define | LOGROTATE_SIGNAL_FILE "logrotate" |
| #define | NBUFFER_LISTS 256 |
Functions | |
| static void | process_pipe_input (char *logbuffer, int *bytes_in_logbuffer) |
| static void | flush_pipe_input (char *logbuffer, int *bytes_in_logbuffer) |
| static FILE * | logfile_open (const char *filename, const char *mode, bool allow_errors) |
| static void | logfile_rotate (bool time_based_rotation, int size_rotation_for) |
| static bool | logfile_rotate_dest (bool time_based_rotation, int size_rotation_for, pg_time_t fntime, int target_dest, char **last_file_name, FILE **logFile) |
| static char * | logfile_getname (pg_time_t timestamp, const char *suffix) |
| static void | set_next_rotation_time (void) |
| static void | sigUsr1Handler (SIGNAL_ARGS) |
| static void | update_metainfo_datafile (void) |
| void | SysLoggerMain (const void *startup_data, size_t startup_data_len) |
| int | SysLogger_Start (int child_slot) |
| void | write_syslogger_file (const char *buffer, int count, int destination) |
| bool | CheckLogrotateSignal (void) |
| void | RemoveLogrotateSignalFiles (void) |
Variables | |
| bool | Logging_collector = false |
| int | Log_RotationAge = HOURS_PER_DAY * MINS_PER_HOUR |
| int | Log_RotationSize = 10 * 1024 |
| char * | Log_directory = NULL |
| char * | Log_filename = NULL |
| bool | Log_truncate_on_rotation = false |
| int | Log_file_mode = S_IRUSR | S_IWUSR |
| static pg_time_t | next_rotation_time |
| static bool | pipe_eof_seen = false |
| static bool | rotation_disabled = false |
| static FILE * | syslogFile = NULL |
| static FILE * | csvlogFile = NULL |
| static FILE * | jsonlogFile = NULL |
| NON_EXEC_STATIC pg_time_t | first_syslogger_file_time = 0 |
| static char * | last_sys_file_name = NULL |
| static char * | last_csv_file_name = NULL |
| static char * | last_json_file_name = NULL |
| static List * | buffer_lists [NBUFFER_LISTS] |
| int | syslogPipe [2] = {-1, -1} |
| static volatile sig_atomic_t | rotation_requested = false |
| #define LOGROTATE_SIGNAL_FILE "logrotate" |
Definition at line 63 of file syslogger.c.
| #define NBUFFER_LISTS 256 |
Definition at line 109 of file syslogger.c.
| #define READ_BUF_SIZE (2 * PIPE_CHUNK_SIZE) |
Definition at line 60 of file syslogger.c.
Definition at line 1573 of file syslogger.c.
References fb(), LOGROTATE_SIGNAL_FILE, and stat.
Referenced by process_pm_pmsignal().
Definition at line 1041 of file syslogger.c.
References buf, buffer_lists, fb(), i, lfirst, LOG_DESTINATION_STDERR, NBUFFER_LISTS, pfree(), str, and write_syslogger_file().
Referenced by SysLoggerMain().
Definition at line 1411 of file syslogger.c.
References fb(), filename, len, Log_directory, Log_filename, log_timezone, MAXPGPATH, palloc(), pg_localtime(), pg_strftime(), snprintf, and strlcpy().
Referenced by logfile_rotate_dest(), SysLogger_Start(), and SysLoggerMain().
Definition at line 1218 of file syslogger.c.
References ereport, errcode_for_file_access(), errmsg(), FATAL, fb(), filename, LOG, Log_file_mode, mode, PG_IOLBF, S_IRWXG, S_IRWXO, S_IRWXU, and S_IWUSR.
Referenced by logfile_rotate_dest(), and SysLogger_Start().
Definition at line 1362 of file syslogger.c.
References csvlogFile, fb(), jsonlogFile, last_csv_file_name, last_json_file_name, last_sys_file_name, LOG_DESTINATION_CSVLOG, LOG_DESTINATION_JSONLOG, LOG_DESTINATION_STDERR, logfile_rotate_dest(), next_rotation_time, rotation_requested, set_next_rotation_time(), syslogFile, and update_metainfo_datafile().
Referenced by SysLoggerMain().
|
static |
Definition at line 1263 of file syslogger.c.
References Assert, ereport, errmsg(), fb(), filename, LOG, Log_destination, LOG_DESTINATION_CSVLOG, LOG_DESTINATION_JSONLOG, LOG_DESTINATION_STDERR, Log_truncate_on_rotation, logfile_getname(), logfile_open(), pfree(), and rotation_disabled.
Referenced by logfile_rotate().
Definition at line 878 of file syslogger.c.
References appendBinaryStringInfo(), Assert, buf, buffer_lists, data, fb(), PipeProtoHeader::flags, initStringInfo(), lappend(), PipeProtoHeader::len, lfirst, LOG_DESTINATION_CSVLOG, LOG_DESTINATION_JSONLOG, LOG_DESTINATION_STDERR, NBUFFER_LISTS, PipeProtoHeader::nuls, palloc_object, pfree(), pg_number_of_ones, PipeProtoHeader::pid, PIPE_HEADER_SIZE, PIPE_MAX_PAYLOAD, PIPE_PROTO_DEST_CSVLOG, PIPE_PROTO_DEST_JSONLOG, PIPE_PROTO_DEST_STDERR, PIPE_PROTO_IS_LAST, str, and write_syslogger_file().
Referenced by SysLoggerMain().
Definition at line 1587 of file syslogger.c.
References fb(), and LOGROTATE_SIGNAL_FILE.
Referenced by PostmasterMain(), and process_pm_pmsignal().
Definition at line 1441 of file syslogger.c.
References fb(), Log_RotationAge, log_timezone, next_rotation_time, now(), pg_localtime(), SECS_PER_MINUTE, tm, and pg_tm::tm_gmtoff.
Referenced by logfile_rotate(), and SysLoggerMain().
|
static |
Definition at line 1594 of file syslogger.c.
References MyLatch, rotation_requested, and SetLatch().
Referenced by SysLoggerMain().
Definition at line 592 of file syslogger.c.
References Assert, B_LOGGER, close, csvlogFile, ereport, errcode_for_file_access(), errcode_for_socket_access(), errhint(), errmsg(), FATAL, fb(), fd(), filename, first_syslogger_file_time, jsonlogFile, LOG, Log_destination, LOG_DESTINATION_CSVLOG, LOG_DESTINATION_JSONLOG, Log_directory, logfile_getname(), logfile_open(), Logging_collector, MakePGDirectory(), pfree(), postmaster_child_launch(), redirection_done, STDERR_FILENO, STDOUT_FILENO, syslogFile, and syslogPipe.
Referenced by StartSysLogger().
Definition at line 165 of file syslogger.c.
References AddWaitEventToSet(), Assert, close, ConfigReloadPending, CreateWaitEventSet(), csvlogFile, DEBUG1, DestNone, DEVNULL, EINTR, elog, ereport, errcode_for_socket_access(), errmsg(), errmsg_internal(), WaitEvent::events, FATAL, fb(), fd(), first_syslogger_file_time, flush_pipe_input(), ftello, init_ps_display(), jsonlogFile, last_csv_file_name, last_json_file_name, last_sys_file_name, LOG, Log_destination, LOG_DESTINATION_CSVLOG, LOG_DESTINATION_JSONLOG, LOG_DESTINATION_STDERR, Log_directory, Log_filename, Log_RotationAge, Log_RotationSize, logfile_getname(), logfile_rotate(), MakePGDirectory(), MemoryContextDelete(), MyLatch, MyStartTime, next_rotation_time, now(), pfree(), PGC_SIGHUP, PGINVALID_SOCKET, pipe_eof_seen, PostmasterContext, pqsignal, proc_exit(), process_pipe_input(), ProcessConfigFile(), pstrdup(), read, READ_BUF_SIZE, redirection_done, ResetLatch(), rotation_disabled, rotation_requested, set_next_rotation_time(), SIGALRM, SIGCHLD, SIGHUP, SignalHandlerForConfigReload(), SIGPIPE, SIGQUIT, SIGUSR1, sigUsr1Handler(), SIGUSR2, STDERR_FILENO, STDOUT_FILENO, syslogFile, syslogPipe, UnBlockSig, update_metainfo_datafile(), WaitEventSetWait(), whereToSendOutput, WL_LATCH_SET, and WL_SOCKET_READABLE.
Definition at line 1476 of file syslogger.c.
References ereport, errcode_for_file_access(), errmsg(), fb(), fprintf, last_csv_file_name, last_json_file_name, last_sys_file_name, LOG, Log_destination, LOG_DESTINATION_CSVLOG, LOG_DESTINATION_JSONLOG, LOG_DESTINATION_STDERR, LOG_METAINFO_DATAFILE, LOG_METAINFO_DATAFILE_TMP, PG_IOLBF, and pg_mode_mask.
Referenced by logfile_rotate(), and SysLoggerMain().
Definition at line 1092 of file syslogger.c.
References csvlogFile, fb(), jsonlogFile, LOG_DESTINATION_CSVLOG, LOG_DESTINATION_JSONLOG, logfile, syslogFile, and write_stderr.
Referenced by flush_pipe_input(), process_pipe_input(), send_message_to_server_log(), write_csvlog(), and write_jsonlog().
|
static |
Definition at line 110 of file syslogger.c.
Referenced by flush_pipe_input(), and process_pipe_input().
Definition at line 85 of file syslogger.c.
Referenced by logfile_rotate(), SysLogger_Start(), SysLoggerMain(), and write_syslogger_file().
| NON_EXEC_STATIC pg_time_t first_syslogger_file_time = 0 |
Definition at line 87 of file syslogger.c.
Referenced by SysLogger_Start(), and SysLoggerMain().
Definition at line 86 of file syslogger.c.
Referenced by logfile_rotate(), SysLogger_Start(), SysLoggerMain(), and write_syslogger_file().
Definition at line 89 of file syslogger.c.
Referenced by logfile_rotate(), SysLoggerMain(), and update_metainfo_datafile().
Definition at line 90 of file syslogger.c.
Referenced by logfile_rotate(), SysLoggerMain(), and update_metainfo_datafile().
Definition at line 88 of file syslogger.c.
Referenced by logfile_rotate(), SysLoggerMain(), and update_metainfo_datafile().
Definition at line 73 of file syslogger.c.
Referenced by convert_and_check_filename(), logfile_getname(), pg_ls_logdir(), SysLogger_Start(), and SysLoggerMain().
Definition at line 76 of file syslogger.c.
Referenced by logfile_open(), and show_log_file_mode().
Definition at line 74 of file syslogger.c.
Referenced by logfile_getname(), and SysLoggerMain().
| int Log_RotationAge = HOURS_PER_DAY * MINS_PER_HOUR |
Definition at line 71 of file syslogger.c.
Referenced by set_next_rotation_time(), and SysLoggerMain().
| int Log_RotationSize = 10 * 1024 |
Definition at line 72 of file syslogger.c.
Referenced by SysLoggerMain().
Definition at line 75 of file syslogger.c.
Referenced by logfile_rotate_dest().
Definition at line 70 of file syslogger.c.
Referenced by LaunchMissingBackgroundProcesses(), pg_rotate_logfile(), PostmasterMain(), process_pm_child_exit(), and SysLogger_Start().
|
static |
Definition at line 81 of file syslogger.c.
Referenced by logfile_rotate(), set_next_rotation_time(), and SysLoggerMain().
Definition at line 82 of file syslogger.c.
Referenced by SysLoggerMain().
Definition at line 83 of file syslogger.c.
Referenced by logfile_rotate_dest(), and SysLoggerMain().
|
static |
Definition at line 127 of file syslogger.c.
Referenced by logfile_rotate(), sigUsr1Handler(), and SysLoggerMain().
Definition at line 84 of file syslogger.c.
Referenced by logfile_rotate(), SysLogger_Start(), SysLoggerMain(), and write_syslogger_file().
| int syslogPipe[2] = {-1, -1} |
Definition at line 114 of file syslogger.c.
Referenced by ClosePostmasterPorts(), SysLogger_Start(), and SysLoggerMain().