taoensso.timbre.appenders.community.postgresql

JDBC PostgreSQL database appender.
Requires <https://github.com/clojure/java.jdbc>,
         <https://github.com/swaldman/c3p0>.

conn

clj

connect

clj

(connect config)

default-pool-spec

clj

ensure-conn

clj

(ensure-conn config)

log-message

clj

(log-message config data)

pgsql-appender

clj

(pgsql-appender db-config)
Returns a JDBC PostgreSQL appender.
(pglog-appender {:server {:host "127.0.0.1" :port 5432}})

SQL ddl script for table creation and rollback
----------------------------------------------

```
CREATE TABLE IF NOT EXISTS logs (
    log_id bigserial primary key,
    instant timestamp NOT NULL,
    level varchar(20) NOT NULL,
    namespace varchar(50) NOT NULL,
    hostname varchar(30) NOT NULL,
    content text NOT NULL,
    error text NOT NULL
);

DROP TABLE IF EXISTS logs;
```

To automate database migration
------------------------------

* Using Migratus + Leiningen (in profiles.clj):
  :database-url "postgresql://<db_username>:<db_password>@<db_servername>:<db_port>/<db_schema>"

* Using Boot + Ragtime (in build.boot):
  ragtime {:driver-class "org.postgresql.Driver"
           :database (str "jdbc:postgresql://<dbserver_name>:<db_port>/"
                          "<db_schema>"
                          "?user=<db_usernmae>"
                          "&password=<db_password>")})

pool

clj

(pool spec)