Skip to content

Commit

Permalink
add log (#492)
Browse files Browse the repository at this point in the history
|       env              | image_env               | default_value          |
|---------------------|----------------------|-------------|
| logging_collector   | LOGGING_COLLECTOR    | off         |
| log_directory       | LOG_DIRECTORY        | pg_log      |
| log_filename        | LOG_FILENAME         | xxx         |
| log_rotation_age    | LOG_ROTATION_AGE     | 1d          |
| log_rotation_size   | LOG_ROTATION_SIZE    | 100MB       |
| log_truncate_on_rotation | LOG_TRUNCATE_ON_ROTATION | on         |
| log_lock_waits      | LOG_LOCK_WAITS       | on          |
| log_duration        | LOG_DURATION         | on          |
| log_statement       | LOG_STATEMENT        | all         |
| log_min_duration_statement | LOG_MIN_DURATION_STATEMENT | 20        |
| log_connections     | LOG_CONNECTIONS      | on          |
| log_disconnections  | LOG_DISCONNECTS      | on          |
| log_line_prefix     | LOG_LINE_PREFIX      | xx          |
| log_timezone        | LOG_TIMEZONE         | Etc/UTC     |
  • Loading branch information
FunkyPantsSa authored Dec 14, 2024
1 parent 3c742c8 commit 1464732
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
58 changes: 58 additions & 0 deletions scripts/env-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,64 @@ if [ -z "${SSL_KEY_FILE}" ]; then
SSL_KEY_FILE='/etc/ssl/private/ssl-cert-snakeoil.key'
fi

# log
if [ -z "${LOGGING_COLLECTOR}" ]; then
LOGGING_COLLECTOR='off'
fi

if [ -z "${LOG_DIRECTORY}" ]; then
LOG_DIRECTORY='pg_log'
fi

if [ -z "${LOG_FILENAME}" ]; then
LOG_FILENAME='postgresql-%Y-%m-%d_%H%M%S.log'
fi

if [ -z "${LOG_ROTATION_AGE}" ]; then
LOG_ROTATION_AGE='1d'
fi

if [ -z "${LOG_ROTATION_SIZE}" ]; then
LOG_ROTATION_SIZE='100MB'
fi

if [ -z "${LOG_TRUNCATE_ON_ROTATION}" ]; then
LOG_TRUNCATE_ON_ROTATION='on'
fi

if [ -z "${LOG_LOCK_WAITS}" ]; then
LOG_LOCK_WAITS='on'
fi

if [ -z "${LOG_DURATION}" ]; then
LOG_DURATION='on'
fi

if [ -z "${LOG_STATEMENT}" ]; then
LOG_STATEMENT='all'
fi

if [ -z "${LOG_MIN_DURATION_STATEMENT}" ]; then
LOG_MIN_DURATION_STATEMENT='20'
fi

if [ -z "${LOG_CONNECTIONS}" ]; then
LOG_CONNECTIONS='on'
fi

if [ -z "${LOG_DISCONNECTS}" ]; then
LOG_DISCONNECTS='on'
fi

if [ -z "${LOG_LINE_PREFIX}" ]; then
LOG_LINE_PREFIX='%m [%p]: [%l-1] %u@%d '
fi

if [ -z "${LOG_TIMEZONE}" ]; then
LOG_TIMEZONE='Etc/UTC'
fi


# SSL mode
function postgres_ssl_setup() {
if [ -z "${PGSSLMODE}" ]; then
Expand Down
17 changes: 17 additions & 0 deletions scripts/setup-conf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@ cron.database_name = '${SINGLE_DB}'
password_encryption= '${PASSWORD_AUTHENTICATION}'
timezone='${TIMEZONE}'
cron.use_background_workers = on
logging_collector='${LOGGING_COLLECTOR}'
log_directory='${LOG_DIRECTORY}'
log_filename='${LOG_FILENAME}'
log_rotation_age='${LOG_ROTATION_AGE}'
log_rotation_size='${LOG_ROTATION_SIZE}'
log_truncate_on_rotation='${LOG_TRUNCATE_ON_ROTATION}'
log_lock_waits='${LOG_LOCK_WAITS}'
log_duration='${LOG_DURATION}'
log_statement='${LOG_STATEMENT}'
log_min_duration_statement='${LOG_MIN_DURATION_STATEMENT}'
log_connections='${LOG_CONNECTIONS}'
log_disconnections='${LOG_DISCONNECTS}'
log_line_prefix='${LOG_LINE_PREFIX}'
log_timezone='${LOG_TIMEZONE}'
EOF

echo "include 'postgis.conf'" >> "${CONF}"
Expand Down

0 comments on commit 1464732

Please sign in to comment.