mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-02 21:02:09 +00:00
[Vendor] update macaron related (#13409)
* Vendor: update gitea.com/macaron/session to a177a270 * make vendor * Vendor: update gitea.com/macaron/macaron to 0db5d458 * make vendor * Vendor: update gitea.com/macaron/cache to 905232fb * make vendor * Vendor: update gitea.com/macaron/i18n to 4ca3dd0c * make vendor * Vendor: update gitea.com/macaron/gzip to efa5e847 * make vendor * Vendor: update gitea.com/macaron/captcha to e8597820 * make vendor
This commit is contained in:
parent
b687707014
commit
70ea2300ca
118 changed files with 14557 additions and 6115 deletions
36
vendor/gitea.com/lunny/log/dbwriter.go
generated
vendored
Normal file
36
vendor/gitea.com/lunny/log/dbwriter.go
generated
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
package log
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"time"
|
||||
)
|
||||
|
||||
type DBWriter struct {
|
||||
db *sql.DB
|
||||
stmt *sql.Stmt
|
||||
content chan []byte
|
||||
}
|
||||
|
||||
func NewDBWriter(db *sql.DB) (*DBWriter, error) {
|
||||
_, err := db.Exec("CREATE TABLE IF NOT EXISTS log (id int, content text, created datetime)")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stmt, err := db.Prepare("INSERT INTO log (content, created) values (?, ?)")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &DBWriter{db, stmt, make(chan []byte, 1000)}, nil
|
||||
}
|
||||
|
||||
func (w *DBWriter) Write(p []byte) (n int, err error) {
|
||||
_, err = w.stmt.Exec(string(p), time.Now())
|
||||
if err == nil {
|
||||
n = len(p)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (w *DBWriter) Close() {
|
||||
w.stmt.Close()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue