log: migrate to unknwon.dev/clog/v2 (#5927)

* Add unknwon.dev/clog/v2

* Update all places
pull/5932/head
ᴜɴᴋɴᴡᴏɴ 2020-02-20 02:25:02 +08:00 committed by GitHub
parent 422a206484
commit 1c09373b4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
71 changed files with 583 additions and 506 deletions

View File

@ -113,14 +113,14 @@ admin_password = Password
confirm_password = Confirm Password confirm_password = Confirm Password
admin_email = Admin Email admin_email = Admin Email
install_gogs = Install Gogs install_gogs = Install Gogs
test_git_failed = Fail to test 'git' command: %v test_git_failed = Failed to test 'git' command: %v
sqlite3_not_available = Your release version does not support SQLite3, please download the official binary version from %s, NOT the gobuild version. sqlite3_not_available = Your release version does not support SQLite3, please download the official binary version from %s, NOT the gobuild version.
invalid_db_setting = Database setting is not correct: %v invalid_db_setting = Database setting is not correct: %v
invalid_repo_path = Repository root path is invalid: %v invalid_repo_path = Repository root path is invalid: %v
run_user_not_match = Run user isn't the current user: %s -> %s run_user_not_match = Run user isn't the current user: %s -> %s
smtp_host_missing_port = SMTP Host port missing from address. smtp_host_missing_port = SMTP Host port missing from address.
invalid_smtp_from = SMTP From field is invalid: %v invalid_smtp_from = SMTP From field is invalid: %v
save_config_failed = Fail to save configuration: %v save_config_failed = Failed to save configuration: %v
invalid_admin_setting = Admin account setting is invalid: %v invalid_admin_setting = Admin account setting is invalid: %v
install_success = Welcome! We're glad that you chose Gogs, have fun and take care. install_success = Welcome! We're glad that you chose Gogs, have fun and take care.
invalid_log_root_path = Log root path is invalid: %v invalid_log_root_path = Log root path is invalid: %v
@ -1231,7 +1231,7 @@ config.mailer_subject_prefix = Subject Prefix
config.mailer_host = Host config.mailer_host = Host
config.mailer_user = User config.mailer_user = User
config.send_test_mail = Send Test Email config.send_test_mail = Send Test Email
config.test_mail_failed = Fail to send test email to '%s': %v config.test_mail_failed = Failed to send test email to '%s': %v
config.test_mail_sent = Test email has been sent to '%s'. config.test_mail_sent = Test email has been sent to '%s'.
config.oauth_config = OAuth Configuration config.oauth_config = OAuth Configuration

8
go.mod
View File

@ -6,7 +6,7 @@ require (
github.com/bgentry/speakeasy v0.1.0 // indirect github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/denisenkom/go-mssqldb v0.0.0-20191001013358-cfbb681360f0 github.com/denisenkom/go-mssqldb v0.0.0-20191001013358-cfbb681360f0
github.com/editorconfig/editorconfig-core-go/v2 v2.2.1 github.com/editorconfig/editorconfig-core-go/v2 v2.2.1
github.com/fatih/color v1.7.0 // indirect github.com/fatih/color v1.9.0 // indirect
github.com/go-macaron/binding v1.0.1 github.com/go-macaron/binding v1.0.1
github.com/go-macaron/cache v0.0.0-20190810181446-10f7c57e2196 github.com/go-macaron/cache v0.0.0-20190810181446-10f7c57e2196
github.com/go-macaron/captcha v0.0.0-20190813234938-24f40749f36d github.com/go-macaron/captcha v0.0.0-20190813234938-24f40749f36d
@ -30,8 +30,7 @@ require (
github.com/klauspost/compress v1.8.6 // indirect github.com/klauspost/compress v1.8.6 // indirect
github.com/klauspost/cpuid v1.2.1 // indirect github.com/klauspost/cpuid v1.2.1 // indirect
github.com/lib/pq v1.2.0 github.com/lib/pq v1.2.0
github.com/mattn/go-colorable v0.1.4 // indirect github.com/mattn/go-isatty v0.0.12 // indirect
github.com/mattn/go-isatty v0.0.10 // indirect
github.com/mattn/go-runewidth v0.0.4 // indirect github.com/mattn/go-runewidth v0.0.4 // indirect
github.com/mattn/go-sqlite3 v1.11.0 github.com/mattn/go-sqlite3 v1.11.0
github.com/mcuadros/go-version v0.0.0-20190830083331-035f6764e8d2 github.com/mcuadros/go-version v0.0.0-20190830083331-035f6764e8d2
@ -56,14 +55,15 @@ require (
github.com/urfave/cli v1.22.1 github.com/urfave/cli v1.22.1
golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6 golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6
golang.org/x/net v0.0.0-20191014212845-da9a3fd4c582 golang.org/x/net v0.0.0-20191014212845-da9a3fd4c582
golang.org/x/sys v0.0.0-20200219091948-cb0a6d8edb6c // indirect
golang.org/x/text v0.3.2 golang.org/x/text v0.3.2
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect
gopkg.in/clog.v1 v1.2.0
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
gopkg.in/ini.v1 v1.52.0 gopkg.in/ini.v1 v1.52.0
gopkg.in/ldap.v2 v2.5.1 gopkg.in/ldap.v2 v2.5.1
gopkg.in/macaron.v1 v1.3.4 gopkg.in/macaron.v1 v1.3.4
unknwon.dev/clog/v2 v2.1.0
xorm.io/builder v0.3.6 xorm.io/builder v0.3.6
xorm.io/core v0.7.2 xorm.io/core v0.7.2
xorm.io/xorm v0.8.0 xorm.io/xorm v0.8.0

29
go.sum
View File

@ -13,6 +13,7 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ= github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
@ -43,6 +44,8 @@ github.com/editorconfig/editorconfig-core-go/v2 v2.2.1/go.mod h1:6XDmqAZsQu8ikS+
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
@ -69,6 +72,7 @@ github.com/go-macaron/toolbox v0.0.0-20190813233741-94defb8383c6/go.mod h1:YFNJ/
github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA= github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA=
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:9wScpmSP5A3Bk8V3XHWUcJmYTh+ZnlHVyc+A4oZYS3Y=
github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:56xuuqnHyryaerycW3BfssRdxQstACi0Epw/yC5E2xM= github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:56xuuqnHyryaerycW3BfssRdxQstACi0Epw/yC5E2xM=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
@ -82,6 +86,7 @@ github.com/gogs/go-gogs-client v0.0.0-20200128182646-c69cb7680fd4 h1:C7NryI/RQhs
github.com/gogs/go-gogs-client v0.0.0-20200128182646-c69cb7680fd4/go.mod h1:fR6z1Ie6rtF7kl/vBYMfgD5/G5B1blui7z426/sj2DU= github.com/gogs/go-gogs-client v0.0.0-20200128182646-c69cb7680fd4/go.mod h1:fR6z1Ie6rtF7kl/vBYMfgD5/G5B1blui7z426/sj2DU=
github.com/gogs/go-libravatar v0.0.0-20191106065024-33a75213d0a0 h1:K02vod+sn3M1OOkdqi2tPxN2+xESK4qyITVQ3JkGEv4= github.com/gogs/go-libravatar v0.0.0-20191106065024-33a75213d0a0 h1:K02vod+sn3M1OOkdqi2tPxN2+xESK4qyITVQ3JkGEv4=
github.com/gogs/go-libravatar v0.0.0-20191106065024-33a75213d0a0/go.mod h1:Zas3BtO88pk1cwUfEYlvnl/CRwh0ybDxRWSwRjG8I3w= github.com/gogs/go-libravatar v0.0.0-20191106065024-33a75213d0a0/go.mod h1:Zas3BtO88pk1cwUfEYlvnl/CRwh0ybDxRWSwRjG8I3w=
github.com/gogs/minwinsvc v0.0.0-20170301035411-95be6356811a h1:8DZwxETOVWIinYxDK+i6L+rMb7eGATGaakD6ZucfHVk=
github.com/gogs/minwinsvc v0.0.0-20170301035411-95be6356811a/go.mod h1:TUIZ+29jodWQ8Gk6Pvtg4E09aMsc3C/VLZiVYfUhWQU= github.com/gogs/minwinsvc v0.0.0-20170301035411-95be6356811a/go.mod h1:TUIZ+29jodWQ8Gk6Pvtg4E09aMsc3C/VLZiVYfUhWQU=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
@ -96,6 +101,7 @@ github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8l
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY= github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
@ -107,11 +113,13 @@ github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OI
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c h1:7lF+Vz0LqiRidnzC1Oq86fpX1q/iEv2KJdrCtttYjT4=
github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/issue9/assert v1.3.1 h1:L8pRpbnzMIPFJqrMKR/oG03uWrtVeZyYBpI2U2Jx1JE=
github.com/issue9/assert v1.3.1/go.mod h1:9Ger+iz8X7r1zMYYwEhh++2wMGWcNN2oVI+zIQXxcio= github.com/issue9/assert v1.3.1/go.mod h1:9Ger+iz8X7r1zMYYwEhh++2wMGWcNN2oVI+zIQXxcio=
github.com/issue9/identicon v1.0.1 h1:pCDfjMDM6xWK0Chxo8Lif+ST/nOEtmXgMITgV1YA9Og= github.com/issue9/identicon v1.0.1 h1:pCDfjMDM6xWK0Chxo8Lif+ST/nOEtmXgMITgV1YA9Og=
github.com/issue9/identicon v1.0.1/go.mod h1:UKNVkUFI68RPz/RlLhsAr1aX6bBSaYEWRHVfdjrMUmk= github.com/issue9/identicon v1.0.1/go.mod h1:UKNVkUFI68RPz/RlLhsAr1aX6bBSaYEWRHVfdjrMUmk=
@ -132,8 +140,10 @@ github.com/klauspost/cpuid v1.2.1 h1:vJi+O/nMdFt0vqm8NZBI6wzALWdA2X+egi0ogNyrC/w
github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0= github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0=
@ -145,9 +155,13 @@ github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVc
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10= github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10=
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y= github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/mattn/go-sqlite3 v1.11.0 h1:LDdKkqtYlom37fkvqs8rMPFKAMe8+SgjbwZ6ex1/A/Q=
github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
@ -162,6 +176,7 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/msteinert/pam v0.0.0-20190215180659-f29b9f28d6f9 h1:ZivaaKmjs9q90zi6I4gTLW6tbVGtlBjellr3hMYaly0=
github.com/msteinert/pam v0.0.0-20190215180659-f29b9f28d6f9/go.mod h1:np1wUFZ6tyoke22qDJZY40URn9Ae51gX7ljIWXN5TJs= github.com/msteinert/pam v0.0.0-20190215180659-f29b9f28d6f9/go.mod h1:np1wUFZ6tyoke22qDJZY40URn9Ae51gX7ljIWXN5TJs=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
@ -208,6 +223,7 @@ github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNue
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca h1:NugYot0LIVPxTvN8n+Kvkn6TrbMyxQiuvKdEwFdR9vI=
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca/go.mod h1:uugorj2VCxiV1x+LzaIdVa9b4S4qGAcH6cbhh4qVxOU= github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca/go.mod h1:uugorj2VCxiV1x+LzaIdVa9b4S4qGAcH6cbhh4qVxOU=
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
@ -249,6 +265,7 @@ github.com/unknwon/paginater v0.0.0-20170405233947-45e5d631308e h1:Qf3QQl/zmEbWD
github.com/unknwon/paginater v0.0.0-20170405233947-45e5d631308e/go.mod h1:TBwoao3Q4Eb/cp+dHbXDfRTrZSsj/k7kLr2j1oWRWC0= github.com/unknwon/paginater v0.0.0-20170405233947-45e5d631308e/go.mod h1:TBwoao3Q4Eb/cp+dHbXDfRTrZSsj/k7kLr2j1oWRWC0=
github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY= github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs=
github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0= github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
@ -297,7 +314,12 @@ golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191010194322-b09406accb47 h1:/XfQ9z7ib8eEJX2hdgFTZJ/ntt0swNk5oYBziWeTCvY=
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200219091948-cb0a6d8edb6c h1:jceGD5YNJGgGMkJz79agzOln1K9TaZUjv5ird16qniQ=
golang.org/x/sys v0.0.0-20200219091948-cb0a6d8edb6c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
@ -316,6 +338,7 @@ google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMt
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.6.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.6.1 h1:QzqyMA1tlu6CgqCDUtU9V+ZKhLFT2dkJuANu5QaxI3I=
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
@ -323,15 +346,15 @@ google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRn
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk= gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d h1:TxyelI5cVkbREznMhfzycHdkp5cLA7DpE+GKjSslYhM= gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d h1:TxyelI5cVkbREznMhfzycHdkp5cLA7DpE+GKjSslYhM=
gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw=
gopkg.in/bufio.v1 v1.0.0-20140618132640-567b2bfa514e h1:wGA78yza6bu/mWcc4QfBuIEHEtc06xdiU0X8sY36yUU= gopkg.in/bufio.v1 v1.0.0-20140618132640-567b2bfa514e h1:wGA78yza6bu/mWcc4QfBuIEHEtc06xdiU0X8sY36yUU=
gopkg.in/bufio.v1 v1.0.0-20140618132640-567b2bfa514e/go.mod h1:xsQCaysVCudhrYTfzYWe577fCe7Ceci+6qjO2Rdc0Z4= gopkg.in/bufio.v1 v1.0.0-20140618132640-567b2bfa514e/go.mod h1:xsQCaysVCudhrYTfzYWe577fCe7Ceci+6qjO2Rdc0Z4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/clog.v1 v1.2.0 h1:BHfwHRNQy497iBNsRBassPixSAxRbn2z5KVkdBFbwxc=
gopkg.in/clog.v1 v1.2.0/go.mod h1:L6fgdpdhFgKX4eGuDvt+N6X2GwZE160NRrIHzvaF8ZM=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE= gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE=
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw= gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw=
@ -352,6 +375,8 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
unknwon.dev/clog/v2 v2.1.0 h1:4iXteBnL9ESvxoNkiaWx4UTU6yEgEmDxFaMANyiq4b8=
unknwon.dev/clog/v2 v2.1.0/go.mod h1:zvUlyibDHI4mykYdWyWje2G9nF/nBzfDOqRo2my4mWc=
xorm.io/builder v0.3.6 h1:ha28mQ2M+TFx96Hxo+iq6tQgnkC9IZkM6D8w9sKHHF8= xorm.io/builder v0.3.6 h1:ha28mQ2M+TFx96Hxo+iq6tQgnkC9IZkM6D8w9sKHHF8=
xorm.io/builder v0.3.6/go.mod h1:LEFAPISnRzG+zxaxj2vPicRwz67BdhFreKg8yv8/TgU= xorm.io/builder v0.3.6/go.mod h1:LEFAPISnRzG+zxaxj2vPicRwz67BdhFreKg8yv8/TgU=
xorm.io/core v0.7.2 h1:mEO22A2Z7a3fPaZMk6gKL/jMD80iiyNwRrX5HOv3XLw= xorm.io/core v0.7.2 h1:mEO22A2Z7a3fPaZMk6gKL/jMD80iiyNwRrX5HOv3XLw=

View File

@ -11,7 +11,7 @@ import (
"os" "os"
"github.com/urfave/cli" "github.com/urfave/cli"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/cmd" "gogs.io/gogs/internal/cmd"
"gogs.io/gogs/internal/setting" "gogs.io/gogs/internal/setting"
@ -39,6 +39,6 @@ func main() {
cmd.Restore, cmd.Restore,
} }
if err := app.Run(os.Args); err != nil { if err := app.Run(os.Args); err != nil {
log.Fatal(2, "Failed to run: %v", err) log.Fatal("Failed to start application: %v", err)
} }
} }

File diff suppressed because one or more lines are too long

View File

@ -2432,7 +2432,7 @@ func repoView_fileTmpl() (*asset, error) {
return nil, err return nil, err
} }
info := bindataFileInfo{name: "repo/view_file.tmpl", size: 4983, mode: os.FileMode(0644), modTime: time.Unix(1571173927, 0)} info := bindataFileInfo{name: "repo/view_file.tmpl", size: 4983, mode: os.FileMode(0644), modTime: time.Unix(1582133193, 0)}
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa2, 0x6f, 0xd7, 0xaa, 0xde, 0x42, 0x19, 0xb3, 0x6e, 0xe6, 0x56, 0xa5, 0x78, 0x70, 0xda, 0x65, 0x6, 0xf7, 0x52, 0xa7, 0x53, 0x56, 0xec, 0xcb, 0x8e, 0x59, 0x94, 0x0, 0x44, 0x4b, 0xb5, 0x23}} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa2, 0x6f, 0xd7, 0xaa, 0xde, 0x42, 0x19, 0xb3, 0x6e, 0xe6, 0x56, 0xa5, 0x78, 0x70, 0xda, 0x65, 0x6, 0xf7, 0x52, 0xa7, 0x53, 0x56, 0xec, 0xcb, 0x8e, 0x59, 0x94, 0x0, 0x44, 0x4b, 0xb5, 0x23}}
return a, nil return a, nil
} }

View File

@ -10,8 +10,8 @@ import (
"github.com/go-macaron/session" "github.com/go-macaron/session"
gouuid "github.com/satori/go.uuid" gouuid "github.com/satori/go.uuid"
log "gopkg.in/clog.v1"
"gopkg.in/macaron.v1" "gopkg.in/macaron.v1"
log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/db" "gogs.io/gogs/internal/db"
"gogs.io/gogs/internal/db/errors" "gogs.io/gogs/internal/db/errors"
@ -52,13 +52,13 @@ func SignedInID(c *macaron.Context, sess session.Store) (_ int64, isTokenAuth bo
t, err := db.GetAccessTokenBySHA(tokenSHA) t, err := db.GetAccessTokenBySHA(tokenSHA)
if err != nil { if err != nil {
if !db.IsErrAccessTokenNotExist(err) && !db.IsErrAccessTokenEmpty(err) { if !db.IsErrAccessTokenNotExist(err) && !db.IsErrAccessTokenEmpty(err) {
log.Error(2, "GetAccessTokenBySHA: %v", err) log.Error("GetAccessTokenBySHA: %v", err)
} }
return 0, false return 0, false
} }
t.Updated = time.Now() t.Updated = time.Now()
if err = db.UpdateAccessToken(t); err != nil { if err = db.UpdateAccessToken(t); err != nil {
log.Error(2, "UpdateAccessToken: %v", err) log.Error("UpdateAccessToken: %v", err)
} }
return t.UID, true return t.UID, true
} }
@ -71,7 +71,7 @@ func SignedInID(c *macaron.Context, sess session.Store) (_ int64, isTokenAuth bo
if id, ok := uid.(int64); ok { if id, ok := uid.(int64); ok {
if _, err := db.GetUserByID(id); err != nil { if _, err := db.GetUserByID(id); err != nil {
if !errors.IsUserNotExist(err) { if !errors.IsUserNotExist(err) {
log.Error(2, "GetUserByID: %v", err) log.Error("GetUserByID: %v", err)
} }
return 0, false return 0, false
} }
@ -96,7 +96,7 @@ func SignedInUser(ctx *macaron.Context, sess session.Store) (_ *db.User, isBasic
u, err := db.GetUserByName(webAuthUser) u, err := db.GetUserByName(webAuthUser)
if err != nil { if err != nil {
if !errors.IsUserNotExist(err) { if !errors.IsUserNotExist(err) {
log.Error(2, "GetUserByName: %v", err) log.Error("GetUserByName: %v", err)
return nil, false, false return nil, false, false
} }
@ -110,7 +110,7 @@ func SignedInUser(ctx *macaron.Context, sess session.Store) (_ *db.User, isBasic
} }
if err = db.CreateUser(u); err != nil { if err = db.CreateUser(u); err != nil {
// FIXME: should I create a system notice? // FIXME: should I create a system notice?
log.Error(2, "CreateUser: %v", err) log.Error("CreateUser: %v", err)
return nil, false, false return nil, false, false
} else { } else {
return u, false, false return u, false, false
@ -131,7 +131,7 @@ func SignedInUser(ctx *macaron.Context, sess session.Store) (_ *db.User, isBasic
u, err := db.UserLogin(uname, passwd, -1) u, err := db.UserLogin(uname, passwd, -1)
if err != nil { if err != nil {
if !errors.IsUserNotExist(err) { if !errors.IsUserNotExist(err) {
log.Error(2, "UserLogin: %v", err) log.Error("UserLogin: %v", err)
} }
return nil, false, false return nil, false, false
} }
@ -144,7 +144,7 @@ func SignedInUser(ctx *macaron.Context, sess session.Store) (_ *db.User, isBasic
u, err := db.GetUserByID(uid) u, err := db.GetUserByID(uid)
if err != nil { if err != nil {
log.Error(2, "GetUserByID: %v", err) log.Error("GetUserByID: %v", err)
return nil, false, false return nil, false, false
} }
return u, false, isTokenAuth return u, false, isTokenAuth

View File

@ -11,8 +11,8 @@ import (
"fmt" "fmt"
"strings" "strings"
log "gopkg.in/clog.v1"
"gopkg.in/ldap.v2" "gopkg.in/ldap.v2"
log "unknwon.dev/clog/v2"
) )
type SecurityProtocol int type SecurityProtocol int
@ -130,7 +130,7 @@ func (ls *Source) findUserDN(l *ldap.Conn, name string) (string, bool) {
userDN := sr.Entries[0].DN userDN := sr.Entries[0].DN
if userDN == "" { if userDN == "" {
log.Error(2, "LDAP: Search was successful, but found no DN!") log.Error("LDAP: Search was successful, but found no DN!")
return "", false return "", false
} }
@ -183,7 +183,7 @@ func (ls *Source) SearchEntry(name, passwd string, directBind bool) (string, str
} }
l, err := dial(ls) l, err := dial(ls)
if err != nil { if err != nil {
log.Error(2, "LDAP connect failed for '%s': %v", ls.Host, err) log.Error("LDAP connect failed for '%s': %v", ls.Host, err)
return "", "", "", "", false, false return "", "", "", "", false, false
} }
defer l.Close() defer l.Close()
@ -229,7 +229,7 @@ func (ls *Source) SearchEntry(name, passwd string, directBind bool) (string, str
sr, err := l.Search(search) sr, err := l.Search(search)
if err != nil { if err != nil {
log.Error(2, "LDAP: User search failed: %v", err) log.Error("LDAP: User search failed: %v", err)
return "", "", "", "", false, false return "", "", "", "", false, false
} else if len(sr.Entries) < 1 { } else if len(sr.Entries) < 1 {
if directBind { if directBind {
@ -266,7 +266,7 @@ func (ls *Source) SearchEntry(name, passwd string, directBind bool) (string, str
srg, err := l.Search(groupSearch) srg, err := l.Search(groupSearch)
if err != nil { if err != nil {
log.Error(2, "LDAP: Group search failed: %v", err) log.Error("LDAP: Group search failed: %v", err)
return "", "", "", "", false, false return "", "", "", "", false, false
} else if len(srg.Entries) < 1 { } else if len(srg.Entries) < 1 {
log.Trace("LDAP: Group search returned no entries") log.Trace("LDAP: Group search returned no entries")
@ -308,7 +308,7 @@ func (ls *Source) SearchEntry(name, passwd string, directBind bool) (string, str
sr, err = l.Search(search) sr, err = l.Search(search)
if err != nil { if err != nil {
log.Error(2, "LDAP: Admin search failed: %v", err) log.Error("LDAP: Admin search failed: %v", err)
} else if len(sr.Entries) < 1 { } else if len(sr.Entries) < 1 {
log.Trace("LDAP: Admin search returned no entries") log.Trace("LDAP: Admin search returned no entries")
} else { } else {

View File

@ -144,7 +144,7 @@ func runCreateUser(c *cli.Context) error {
setting.CustomConf = c.String("config") setting.CustomConf = c.String("config")
} }
setting.NewContext() setting.Init()
db.LoadConfigs() db.LoadConfigs()
db.SetEngine() db.SetEngine()
@ -168,7 +168,7 @@ func adminDashboardOperation(operation func() error, successMessage string) func
setting.CustomConf = c.String("config") setting.CustomConf = c.String("config")
} }
setting.NewContext() setting.Init()
db.LoadConfigs() db.LoadConfigs()
db.SetEngine() db.SetEngine()

View File

@ -14,8 +14,8 @@ import (
"github.com/unknwon/cae/zip" "github.com/unknwon/cae/zip"
"github.com/unknwon/com" "github.com/unknwon/com"
"github.com/urfave/cli" "github.com/urfave/cli"
log "gopkg.in/clog.v1"
"gopkg.in/ini.v1" "gopkg.in/ini.v1"
log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/db" "gogs.io/gogs/internal/db"
"gogs.io/gogs/internal/setting" "gogs.io/gogs/internal/setting"
@ -47,17 +47,17 @@ func runBackup(c *cli.Context) error {
if c.IsSet("config") { if c.IsSet("config") {
setting.CustomConf = c.String("config") setting.CustomConf = c.String("config")
} }
setting.NewContext() setting.Init()
db.LoadConfigs() db.LoadConfigs()
db.SetEngine() db.SetEngine()
tmpDir := c.String("tempdir") tmpDir := c.String("tempdir")
if !com.IsExist(tmpDir) { if !com.IsExist(tmpDir) {
log.Fatal(0, "'--tempdir' does not exist: %s", tmpDir) log.Fatal("'--tempdir' does not exist: %s", tmpDir)
} }
rootDir, err := ioutil.TempDir(tmpDir, "gogs-backup-") rootDir, err := ioutil.TempDir(tmpDir, "gogs-backup-")
if err != nil { if err != nil {
log.Fatal(0, "Fail to create backup root directory '%s': %v", rootDir, err) log.Fatal("Failed to create backup root directory '%s': %v", rootDir, err)
} }
log.Info("Backup root directory: %s", rootDir) log.Info("Backup root directory: %s", rootDir)
@ -68,7 +68,7 @@ func runBackup(c *cli.Context) error {
metadata.Section("").Key("DATE_TIME").SetValue(time.Now().String()) metadata.Section("").Key("DATE_TIME").SetValue(time.Now().String())
metadata.Section("").Key("GOGS_VERSION").SetValue(setting.AppVersion) metadata.Section("").Key("GOGS_VERSION").SetValue(setting.AppVersion)
if err = metadata.SaveTo(metaFile); err != nil { if err = metadata.SaveTo(metaFile); err != nil {
log.Fatal(0, "Fail to save metadata '%s': %v", metaFile, err) log.Fatal("Failed to save metadata '%s': %v", metaFile, err)
} }
archiveName := path.Join(c.String("target"), c.String("archive-name")) archiveName := path.Join(c.String("target"), c.String("archive-name"))
@ -76,25 +76,25 @@ func runBackup(c *cli.Context) error {
z, err := zip.Create(archiveName) z, err := zip.Create(archiveName)
if err != nil { if err != nil {
log.Fatal(0, "Fail to create backup archive '%s': %v", archiveName, err) log.Fatal("Failed to create backup archive '%s': %v", archiveName, err)
} }
if err = z.AddFile(_ARCHIVE_ROOT_DIR+"/metadata.ini", metaFile); err != nil { if err = z.AddFile(_ARCHIVE_ROOT_DIR+"/metadata.ini", metaFile); err != nil {
log.Fatal(0, "Fail to include 'metadata.ini': %v", err) log.Fatal("Failed to include 'metadata.ini': %v", err)
} }
// Database // Database
dbDir := path.Join(rootDir, "db") dbDir := path.Join(rootDir, "db")
if err = db.DumpDatabase(dbDir); err != nil { if err = db.DumpDatabase(dbDir); err != nil {
log.Fatal(0, "Fail to dump database: %v", err) log.Fatal("Failed to dump database: %v", err)
} }
if err = z.AddDir(_ARCHIVE_ROOT_DIR+"/db", dbDir); err != nil { if err = z.AddDir(_ARCHIVE_ROOT_DIR+"/db", dbDir); err != nil {
log.Fatal(0, "Fail to include 'db': %v", err) log.Fatal("Failed to include 'db': %v", err)
} }
// Custom files // Custom files
if !c.Bool("database-only") { if !c.Bool("database-only") {
if err = z.AddDir(_ARCHIVE_ROOT_DIR+"/custom", setting.CustomPath); err != nil { if err = z.AddDir(_ARCHIVE_ROOT_DIR+"/custom", setting.CustomPath); err != nil {
log.Fatal(0, "Fail to include 'custom': %v", err) log.Fatal("Failed to include 'custom': %v", err)
} }
} }
@ -107,7 +107,7 @@ func runBackup(c *cli.Context) error {
} }
if err = z.AddDir(path.Join(_ARCHIVE_ROOT_DIR+"/data", dir), dirPath); err != nil { if err = z.AddDir(path.Join(_ARCHIVE_ROOT_DIR+"/data", dir), dirPath); err != nil {
log.Fatal(0, "Fail to include 'data': %v", err) log.Fatal("Failed to include 'data': %v", err)
} }
} }
} }
@ -117,21 +117,21 @@ func runBackup(c *cli.Context) error {
reposDump := path.Join(rootDir, "repositories.zip") reposDump := path.Join(rootDir, "repositories.zip")
log.Info("Dumping repositories in '%s'", setting.RepoRootPath) log.Info("Dumping repositories in '%s'", setting.RepoRootPath)
if err = zip.PackTo(setting.RepoRootPath, reposDump, true); err != nil { if err = zip.PackTo(setting.RepoRootPath, reposDump, true); err != nil {
log.Fatal(0, "Fail to dump repositories: %v", err) log.Fatal("Failed to dump repositories: %v", err)
} }
log.Info("Repositories dumped to: %s", reposDump) log.Info("Repositories dumped to: %s", reposDump)
if err = z.AddFile(_ARCHIVE_ROOT_DIR+"/repositories.zip", reposDump); err != nil { if err = z.AddFile(_ARCHIVE_ROOT_DIR+"/repositories.zip", reposDump); err != nil {
log.Fatal(0, "Fail to include 'repositories.zip': %v", err) log.Fatal("Failed to include 'repositories.zip': %v", err)
} }
} }
if err = z.Close(); err != nil { if err = z.Close(); err != nil {
log.Fatal(0, "Fail to save backup archive '%s': %v", archiveName, err) log.Fatal("Failed to save backup archive '%s': %v", archiveName, err)
} }
os.RemoveAll(rootDir) os.RemoveAll(rootDir)
log.Info("Backup succeed! Archive is located at: %s", archiveName) log.Info("Backup succeed! Archive is located at: %s", archiveName)
log.Shutdown() log.Stop()
return nil return nil
} }

View File

@ -16,7 +16,7 @@ import (
"github.com/unknwon/com" "github.com/unknwon/com"
"github.com/urfave/cli" "github.com/urfave/cli"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"github.com/gogs/git-module" "github.com/gogs/git-module"
@ -129,7 +129,7 @@ func runHookPreReceive(c *cli.Context) error {
output, err := git.NewCommand("rev-list", "--max-count=1", oldCommitID, "^"+newCommitID). output, err := git.NewCommand("rev-list", "--max-count=1", oldCommitID, "^"+newCommitID).
RunInDir(db.RepoPath(os.Getenv(db.ENV_REPO_OWNER_NAME), os.Getenv(db.ENV_REPO_NAME))) RunInDir(db.RepoPath(os.Getenv(db.ENV_REPO_OWNER_NAME), os.Getenv(db.ENV_REPO_NAME)))
if err != nil { if err != nil {
fail("Internal error", "Fail to detect force push: %v", err) fail("Internal error", "Failed to detect force push: %v", err)
} else if len(output) > 0 { } else if len(output) > 0 {
fail(fmt.Sprintf("Branch '%s' is protected from force push", branchName), "") fail(fmt.Sprintf("Branch '%s' is protected from force push", branchName), "")
} }
@ -151,7 +151,7 @@ func runHookPreReceive(c *cli.Context) error {
hookCmd.Stdin = buf hookCmd.Stdin = buf
hookCmd.Stderr = os.Stderr hookCmd.Stderr = os.Stderr
if err := hookCmd.Run(); err != nil { if err := hookCmd.Run(); err != nil {
fail("Internal error", "Fail to execute custom pre-receive hook: %v", err) fail("Internal error", "Failed to execute custom pre-receive hook: %v", err)
} }
return nil return nil
} }
@ -185,7 +185,7 @@ func runHookUpdate(c *cli.Context) error {
hookCmd.Stdin = os.Stdin hookCmd.Stdin = os.Stdin
hookCmd.Stderr = os.Stderr hookCmd.Stderr = os.Stderr
if err := hookCmd.Run(); err != nil { if err := hookCmd.Run(); err != nil {
fail("Internal error", "Fail to execute custom pre-receive hook: %v", err) fail("Internal error", "Failed to execute custom pre-receive hook: %v", err)
} }
return nil return nil
} }
@ -229,7 +229,7 @@ func runHookPostReceive(c *cli.Context) error {
RepoName: os.Getenv(db.ENV_REPO_NAME), RepoName: os.Getenv(db.ENV_REPO_NAME),
} }
if err := db.PushUpdate(options); err != nil { if err := db.PushUpdate(options); err != nil {
log.Error(2, "PushUpdate: %v", err) log.Error("PushUpdate: %v", err)
} }
// Ask for running deliver hook and test pull request tasks // Ask for running deliver hook and test pull request tasks
@ -245,10 +245,10 @@ func runHookPostReceive(c *cli.Context) error {
if err == nil { if err == nil {
resp.Body.Close() resp.Body.Close()
if resp.StatusCode/100 != 2 { if resp.StatusCode/100 != 2 {
log.Error(2, "Fail to trigger task: not 2xx response code") log.Error("Failed to trigger task: not 2xx response code")
} }
} else { } else {
log.Error(2, "Fail to trigger task: %v", err) log.Error("Failed to trigger task: %v", err)
} }
} }
@ -268,7 +268,7 @@ func runHookPostReceive(c *cli.Context) error {
hookCmd.Stdin = buf hookCmd.Stdin = buf
hookCmd.Stderr = os.Stderr hookCmd.Stderr = os.Stderr
if err := hookCmd.Run(); err != nil { if err := hookCmd.Run(); err != nil {
fail("Internal error", "Fail to execute custom post-receive hook: %v", err) fail("Internal error", "Failed to execute custom post-receive hook: %v", err)
} }
return nil return nil
} }

View File

@ -58,7 +58,7 @@ func runImportLocale(c *cli.Context) error {
setting.CustomConf = c.String("config") setting.CustomConf = c.String("config")
} }
setting.NewContext() setting.Init()
now := time.Now() now := time.Now()

View File

@ -12,8 +12,8 @@ import (
"github.com/unknwon/cae/zip" "github.com/unknwon/cae/zip"
"github.com/unknwon/com" "github.com/unknwon/com"
"github.com/urfave/cli" "github.com/urfave/cli"
log "gopkg.in/clog.v1"
"gopkg.in/ini.v1" "gopkg.in/ini.v1"
log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/db" "gogs.io/gogs/internal/db"
"gogs.io/gogs/internal/setting" "gogs.io/gogs/internal/setting"
@ -48,12 +48,12 @@ func runRestore(c *cli.Context) error {
tmpDir := c.String("tempdir") tmpDir := c.String("tempdir")
if !com.IsExist(tmpDir) { if !com.IsExist(tmpDir) {
log.Fatal(0, "'--tempdir' does not exist: %s", tmpDir) log.Fatal("'--tempdir' does not exist: %s", tmpDir)
} }
log.Info("Restore backup from: %s", c.String("from")) log.Info("Restore backup from: %s", c.String("from"))
if err := zip.ExtractTo(c.String("from"), tmpDir); err != nil { if err := zip.ExtractTo(c.String("from"), tmpDir); err != nil {
log.Fatal(0, "Failed to extract backup archive: %v", err) log.Fatal("Failed to extract backup archive: %v", err)
} }
archivePath := path.Join(tmpDir, _ARCHIVE_ROOT_DIR) archivePath := path.Join(tmpDir, _ARCHIVE_ROOT_DIR)
defer os.RemoveAll(archivePath) defer os.RemoveAll(archivePath)
@ -61,22 +61,22 @@ func runRestore(c *cli.Context) error {
// Check backup version // Check backup version
metaFile := path.Join(archivePath, "metadata.ini") metaFile := path.Join(archivePath, "metadata.ini")
if !com.IsExist(metaFile) { if !com.IsExist(metaFile) {
log.Fatal(0, "File 'metadata.ini' is missing") log.Fatal("File 'metadata.ini' is missing")
} }
metadata, err := ini.Load(metaFile) metadata, err := ini.Load(metaFile)
if err != nil { if err != nil {
log.Fatal(0, "Failed to load metadata '%s': %v", metaFile, err) log.Fatal("Failed to load metadata '%s': %v", metaFile, err)
} }
backupVersion := metadata.Section("").Key("GOGS_VERSION").MustString("999.0") backupVersion := metadata.Section("").Key("GOGS_VERSION").MustString("999.0")
if version.Compare(setting.AppVersion, backupVersion, "<") { if version.Compare(setting.AppVersion, backupVersion, "<") {
log.Fatal(0, "Current Gogs version is lower than backup version: %s < %s", setting.AppVersion, backupVersion) log.Fatal("Current Gogs version is lower than backup version: %s < %s", setting.AppVersion, backupVersion)
} }
formatVersion := metadata.Section("").Key("VERSION").MustInt() formatVersion := metadata.Section("").Key("VERSION").MustInt()
if formatVersion == 0 { if formatVersion == 0 {
log.Fatal(0, "Failed to determine the backup format version from metadata '%s': %s", metaFile, "VERSION is not presented") log.Fatal("Failed to determine the backup format version from metadata '%s': %s", metaFile, "VERSION is not presented")
} }
if formatVersion != _CURRENT_BACKUP_FORMAT_VERSION { if formatVersion != _CURRENT_BACKUP_FORMAT_VERSION {
log.Fatal(0, "Backup format version found is %d but this binary only supports %d\nThe last known version that is able to import your backup is %s", log.Fatal("Backup format version found is %d but this binary only supports %d\nThe last known version that is able to import your backup is %s",
formatVersion, _CURRENT_BACKUP_FORMAT_VERSION, lastSupportedVersionOfFormat[formatVersion]) formatVersion, _CURRENT_BACKUP_FORMAT_VERSION, lastSupportedVersionOfFormat[formatVersion])
} }
@ -86,29 +86,29 @@ func runRestore(c *cli.Context) error {
if c.IsSet("config") { if c.IsSet("config") {
setting.CustomConf = c.String("config") setting.CustomConf = c.String("config")
} else if !com.IsExist(configFile) { } else if !com.IsExist(configFile) {
log.Fatal(0, "'--config' is not specified and custom config file is not found in backup") log.Fatal("'--config' is not specified and custom config file is not found in backup")
} else { } else {
setting.CustomConf = configFile setting.CustomConf = configFile
} }
setting.NewContext() setting.Init()
db.LoadConfigs() db.LoadConfigs()
db.SetEngine() db.SetEngine()
// Database // Database
dbDir := path.Join(archivePath, "db") dbDir := path.Join(archivePath, "db")
if err = db.ImportDatabase(dbDir, c.Bool("verbose")); err != nil { if err = db.ImportDatabase(dbDir, c.Bool("verbose")); err != nil {
log.Fatal(0, "Failed to import database: %v", err) log.Fatal("Failed to import database: %v", err)
} }
// Custom files // Custom files
if !c.Bool("database-only") { if !c.Bool("database-only") {
if com.IsExist(setting.CustomPath) { if com.IsExist(setting.CustomPath) {
if err = os.Rename(setting.CustomPath, setting.CustomPath+".bak"); err != nil { if err = os.Rename(setting.CustomPath, setting.CustomPath+".bak"); err != nil {
log.Fatal(0, "Failed to backup current 'custom': %v", err) log.Fatal("Failed to backup current 'custom': %v", err)
} }
} }
if err = os.Rename(path.Join(archivePath, "custom"), setting.CustomPath); err != nil { if err = os.Rename(path.Join(archivePath, "custom"), setting.CustomPath); err != nil {
log.Fatal(0, "Failed to import 'custom': %v", err) log.Fatal("Failed to import 'custom': %v", err)
} }
} }
@ -125,11 +125,11 @@ func runRestore(c *cli.Context) error {
dirPath := path.Join(setting.AppDataPath, dir) dirPath := path.Join(setting.AppDataPath, dir)
if com.IsExist(dirPath) { if com.IsExist(dirPath) {
if err = os.Rename(dirPath, dirPath+".bak"); err != nil { if err = os.Rename(dirPath, dirPath+".bak"); err != nil {
log.Fatal(0, "Failed to backup current 'data': %v", err) log.Fatal("Failed to backup current 'data': %v", err)
} }
} }
if err = os.Rename(srcPath, dirPath); err != nil { if err = os.Rename(srcPath, dirPath); err != nil {
log.Fatal(0, "Failed to import 'data': %v", err) log.Fatal("Failed to import 'data': %v", err)
} }
} }
} }
@ -138,11 +138,11 @@ func runRestore(c *cli.Context) error {
reposPath := path.Join(archivePath, "repositories.zip") reposPath := path.Join(archivePath, "repositories.zip")
if !c.Bool("exclude-repos") && !c.Bool("database-only") && com.IsExist(reposPath) { if !c.Bool("exclude-repos") && !c.Bool("database-only") && com.IsExist(reposPath) {
if err := zip.ExtractTo(reposPath, path.Dir(setting.RepoRootPath)); err != nil { if err := zip.ExtractTo(reposPath, path.Dir(setting.RepoRootPath)); err != nil {
log.Fatal(0, "Failed to extract 'repositories.zip': %v", err) log.Fatal("Failed to extract 'repositories.zip': %v", err)
} }
} }
log.Info("Restore succeed!") log.Info("Restore succeed!")
log.Shutdown() log.Stop()
return nil return nil
} }

View File

@ -14,7 +14,7 @@ import (
"github.com/unknwon/com" "github.com/unknwon/com"
"github.com/urfave/cli" "github.com/urfave/cli"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/db" "gogs.io/gogs/internal/db"
"gogs.io/gogs/internal/db/errors" "gogs.io/gogs/internal/db/errors"
@ -42,7 +42,7 @@ func fail(userMessage, logMessage string, args ...interface{}) {
if !setting.ProdMode { if !setting.ProdMode {
fmt.Fprintf(os.Stderr, logMessage+"\n", args...) fmt.Fprintf(os.Stderr, logMessage+"\n", args...)
} }
log.Fatal(3, logMessage, args...) log.Fatal(logMessage, args...)
} }
os.Exit(1) os.Exit(1)
@ -55,13 +55,14 @@ func setup(c *cli.Context, logPath string, connectDB bool) {
setting.CustomConf = c.GlobalString("config") setting.CustomConf = c.GlobalString("config")
} }
setting.NewContext() setting.Init()
level := log.TRACE level := log.LevelTrace
if setting.ProdMode { if setting.ProdMode {
level = log.ERROR level = log.LevelError
} }
log.New(log.FILE, log.FileConfig{
err := log.NewFile(log.FileConfig{
Level: level, Level: level,
Filename: filepath.Join(setting.LogRootPath, logPath), Filename: filepath.Join(setting.LogRootPath, logPath),
FileRotationConfig: log.FileRotationConfig{ FileRotationConfig: log.FileRotationConfig{
@ -70,7 +71,11 @@ func setup(c *cli.Context, logPath string, connectDB bool) {
MaxDays: 3, MaxDays: 3,
}, },
}) })
log.Delete(log.CONSOLE) // Remove primary logger if err != nil {
log.Fatal("Failed to init file logger: %v", err)
return
}
log.Remove(log.DefaultConsoleName) // Remove the primary logger
if !connectDB { if !connectDB {
return return
@ -156,7 +161,7 @@ func runServ(c *cli.Context) error {
if errors.IsUserNotExist(err) { if errors.IsUserNotExist(err) {
fail("Repository owner does not exist", "Unregistered owner: %s", ownerName) fail("Repository owner does not exist", "Unregistered owner: %s", ownerName)
} }
fail("Internal error", "Fail to get repository owner '%s': %v", ownerName, err) fail("Internal error", "Failed to get repository owner '%s': %v", ownerName, err)
} }
repo, err := db.GetRepositoryByName(owner.ID, repoName) repo, err := db.GetRepositoryByName(owner.ID, repoName)
@ -164,7 +169,7 @@ func runServ(c *cli.Context) error {
if errors.IsRepoNotExist(err) { if errors.IsRepoNotExist(err) {
fail(_ACCESS_DENIED_MESSAGE, "Repository does not exist: %s/%s", owner.Name, repoName) fail(_ACCESS_DENIED_MESSAGE, "Repository does not exist: %s/%s", owner.Name, repoName)
} }
fail("Internal error", "Fail to get repository: %v", err) fail("Internal error", "Failed to get repository: %v", err)
} }
repo.Owner = owner repo.Owner = owner
@ -196,12 +201,12 @@ func runServ(c *cli.Context) error {
} else { } else {
user, err = db.GetUserByKeyID(key.ID) user, err = db.GetUserByKeyID(key.ID)
if err != nil { if err != nil {
fail("Internal error", "Fail to get user by key ID '%d': %v", key.ID, err) fail("Internal error", "Failed to get user by key ID '%d': %v", key.ID, err)
} }
mode, err := db.UserAccessMode(user.ID, repo) mode, err := db.UserAccessMode(user.ID, repo)
if err != nil { if err != nil {
fail("Internal error", "Fail to check access: %v", err) fail("Internal error", "Failed to check access: %v", err)
} }
if mode < requestMode { if mode < requestMode {
@ -265,7 +270,7 @@ func runServ(c *cli.Context) error {
gitCmd.Stdin = os.Stdin gitCmd.Stdin = os.Stdin
gitCmd.Stderr = os.Stderr gitCmd.Stderr = os.Stderr
if err = gitCmd.Run(); err != nil { if err = gitCmd.Run(); err != nil {
fail("Internal error", "Fail to execute git command: %v", err) fail("Internal error", "Failed to execute git command: %v", err)
} }
return nil return nil

View File

@ -26,8 +26,8 @@ import (
"github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/unknwon/com" "github.com/unknwon/com"
"github.com/urfave/cli" "github.com/urfave/cli"
log "gopkg.in/clog.v1"
"gopkg.in/macaron.v1" "gopkg.in/macaron.v1"
log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/assets/conf" "gogs.io/gogs/internal/assets/conf"
"gogs.io/gogs/internal/assets/public" "gogs.io/gogs/internal/assets/public"
@ -119,7 +119,7 @@ func newMacaron() *macaron.Macaron {
localeNames, err := conf.AssetDir("conf/locale") localeNames, err := conf.AssetDir("conf/locale")
if err != nil { if err != nil {
log.Fatal(4, "Fail to list locale files: %v", err) log.Fatal("Failed to list locale files: %v", err)
} }
localFiles := make(map[string][]byte) localFiles := make(map[string][]byte)
for _, name := range localeNames { for _, name := range localeNames {
@ -741,15 +741,15 @@ func runWeb(c *cli.Context) error {
// FIXME: add proper implementation of signal capture on all protocols // FIXME: add proper implementation of signal capture on all protocols
// execute this on SIGTERM or SIGINT: listener.Close() // execute this on SIGTERM or SIGINT: listener.Close()
if err = os.Chmod(listenAddr, os.FileMode(setting.UnixSocketPermission)); err != nil { if err = os.Chmod(listenAddr, os.FileMode(setting.UnixSocketPermission)); err != nil {
log.Fatal(4, "Failed to set permission of unix socket: %v", err) log.Fatal("Failed to set permission of unix socket: %v", err)
} }
err = http.Serve(listener, m) err = http.Serve(listener, m)
default: default:
log.Fatal(4, "Invalid protocol: %s", setting.Protocol) log.Fatal("Invalid protocol: %s", setting.Protocol)
} }
if err != nil { if err != nil {
log.Fatal(4, "Failed to start server: %v", err) log.Fatal("Failed to start server: %v", err)
} }
return nil return nil

View File

@ -10,8 +10,8 @@ import (
"strings" "strings"
"github.com/unknwon/paginater" "github.com/unknwon/paginater"
log "gopkg.in/clog.v1"
"gopkg.in/macaron.v1" "gopkg.in/macaron.v1"
log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/setting" "gogs.io/gogs/internal/setting"
) )
@ -39,7 +39,7 @@ func (c *APIContext) Error(status int, title string, obj interface{}) {
} }
if status == http.StatusInternalServerError { if status == http.StatusInternalServerError {
log.Error(3, "%s: %s", title, message) log.Error("%s: %s", title, message)
} }
c.JSON(status, map[string]string{ c.JSON(status, map[string]string{

View File

@ -17,8 +17,8 @@ import (
"github.com/go-macaron/i18n" "github.com/go-macaron/i18n"
"github.com/go-macaron/session" "github.com/go-macaron/session"
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1"
"gopkg.in/macaron.v1" "gopkg.in/macaron.v1"
log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/auth" "gogs.io/gogs/internal/auth"
"gogs.io/gogs/internal/db" "gogs.io/gogs/internal/db"
@ -173,7 +173,7 @@ func (c *Context) Handle(status int, msg string, err error) {
c.Data["Title"] = "Page Not Found" c.Data["Title"] = "Page Not Found"
case http.StatusInternalServerError: case http.StatusInternalServerError:
c.Data["Title"] = "Internal Server Error" c.Data["Title"] = "Internal Server Error"
log.Error(3, "%s: %v", msg, err) log.Error("%s: %v", msg, err)
if !setting.ProdMode || (c.IsLogged && c.User.IsAdmin) { if !setting.ProdMode || (c.IsLogged && c.User.IsAdmin) {
c.Data["ErrorMsg"] = err c.Data["ErrorMsg"] = err
} }

View File

@ -9,7 +9,7 @@ import (
"path" "path"
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/markup" "gogs.io/gogs/internal/markup"
"gogs.io/gogs/internal/setting" "gogs.io/gogs/internal/setting"
@ -26,14 +26,14 @@ func (c *Context) renderNoticeBanner() {
f, err := os.Open(fpath) f, err := os.Open(fpath)
if err != nil { if err != nil {
log.Error(2, "Failed to open file %q: %v", fpath, err) log.Error("Failed to open file %q: %v", fpath, err)
return return
} }
defer f.Close() defer f.Close()
fi, err := f.Stat() fi, err := f.Stat()
if err != nil { if err != nil {
log.Error(2, "Failed to stat file %q: %v", fpath, err) log.Error("Failed to stat file %q: %v", fpath, err)
return return
} }
@ -48,7 +48,7 @@ func (c *Context) renderNoticeBanner() {
buf := make([]byte, maxSize) buf := make([]byte, maxSize)
n, err := f.Read(buf) n, err := f.Read(buf)
if err != nil { if err != nil {
log.Error(2, "Failed to read file %q: %v", fpath, err) log.Error("Failed to read file %q: %v", fpath, err)
return return
} }
buf = buf[:n] buf = buf[:n]

View File

@ -7,7 +7,7 @@ package cron
import ( import (
"time" "time"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"github.com/gogs/cron" "github.com/gogs/cron"
@ -25,7 +25,7 @@ func NewContext() {
if setting.Cron.UpdateMirror.Enabled { if setting.Cron.UpdateMirror.Enabled {
entry, err = c.AddFunc("Update mirrors", setting.Cron.UpdateMirror.Schedule, db.MirrorUpdate) entry, err = c.AddFunc("Update mirrors", setting.Cron.UpdateMirror.Schedule, db.MirrorUpdate)
if err != nil { if err != nil {
log.Fatal(2, "Cron.(update mirrors): %v", err) log.Fatal("Cron.(update mirrors): %v", err)
} }
if setting.Cron.UpdateMirror.RunAtStart { if setting.Cron.UpdateMirror.RunAtStart {
entry.Prev = time.Now() entry.Prev = time.Now()
@ -36,7 +36,7 @@ func NewContext() {
if setting.Cron.RepoHealthCheck.Enabled { if setting.Cron.RepoHealthCheck.Enabled {
entry, err = c.AddFunc("Repository health check", setting.Cron.RepoHealthCheck.Schedule, db.GitFsck) entry, err = c.AddFunc("Repository health check", setting.Cron.RepoHealthCheck.Schedule, db.GitFsck)
if err != nil { if err != nil {
log.Fatal(2, "Cron.(repository health check): %v", err) log.Fatal("Cron.(repository health check): %v", err)
} }
if setting.Cron.RepoHealthCheck.RunAtStart { if setting.Cron.RepoHealthCheck.RunAtStart {
entry.Prev = time.Now() entry.Prev = time.Now()
@ -47,7 +47,7 @@ func NewContext() {
if setting.Cron.CheckRepoStats.Enabled { if setting.Cron.CheckRepoStats.Enabled {
entry, err = c.AddFunc("Check repository statistics", setting.Cron.CheckRepoStats.Schedule, db.CheckRepoStats) entry, err = c.AddFunc("Check repository statistics", setting.Cron.CheckRepoStats.Schedule, db.CheckRepoStats)
if err != nil { if err != nil {
log.Fatal(2, "Cron.(check repository statistics): %v", err) log.Fatal("Cron.(check repository statistics): %v", err)
} }
if setting.Cron.CheckRepoStats.RunAtStart { if setting.Cron.CheckRepoStats.RunAtStart {
entry.Prev = time.Now() entry.Prev = time.Now()
@ -58,7 +58,7 @@ func NewContext() {
if setting.Cron.RepoArchiveCleanup.Enabled { if setting.Cron.RepoArchiveCleanup.Enabled {
entry, err = c.AddFunc("Repository archive cleanup", setting.Cron.RepoArchiveCleanup.Schedule, db.DeleteOldRepositoryArchives) entry, err = c.AddFunc("Repository archive cleanup", setting.Cron.RepoArchiveCleanup.Schedule, db.DeleteOldRepositoryArchives)
if err != nil { if err != nil {
log.Fatal(2, "Cron.(repository archive cleanup): %v", err) log.Fatal("Cron.(repository archive cleanup): %v", err)
} }
if setting.Cron.RepoArchiveCleanup.RunAtStart { if setting.Cron.RepoArchiveCleanup.RunAtStart {
entry.Prev = time.Now() entry.Prev = time.Now()

View File

@ -7,7 +7,7 @@ package db
import ( import (
"fmt" "fmt"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/db/errors" "gogs.io/gogs/internal/db/errors"
) )
@ -111,7 +111,7 @@ func (u *User) GetRepositoryAccesses() (map[*Repository]AccessMode, error) {
repo, err := GetRepositoryByID(access.RepoID) repo, err := GetRepositoryByID(access.RepoID)
if err != nil { if err != nil {
if errors.IsRepoNotExist(err) { if errors.IsRepoNotExist(err) {
log.Error(2, "GetRepositoryByID: %v", err) log.Error("GetRepositoryByID: %v", err)
continue continue
} }
return nil, err return nil, err

View File

@ -13,7 +13,7 @@ import (
"github.com/json-iterator/go" "github.com/json-iterator/go"
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"xorm.io/xorm" "xorm.io/xorm"
"github.com/gogs/git-module" "github.com/gogs/git-module"
@ -160,7 +160,7 @@ func (a *Action) GetIssueTitle() string {
index := com.StrTo(a.GetIssueInfos()[0]).MustInt64() index := com.StrTo(a.GetIssueInfos()[0]).MustInt64()
issue, err := GetIssueByIndex(a.RepoID, index) issue, err := GetIssueByIndex(a.RepoID, index)
if err != nil { if err != nil {
log.Error(4, "GetIssueByIndex: %v", err) log.Error("GetIssueByIndex: %v", err)
return "500 when get issue" return "500 when get issue"
} }
return issue.Title return issue.Title
@ -170,7 +170,7 @@ func (a *Action) GetIssueContent() string {
index := com.StrTo(a.GetIssueInfos()[0]).MustInt64() index := com.StrTo(a.GetIssueInfos()[0]).MustInt64()
issue, err := GetIssueByIndex(a.RepoID, index) issue, err := GetIssueByIndex(a.RepoID, index)
if err != nil { if err != nil {
log.Error(4, "GetIssueByIndex: %v", err) log.Error("GetIssueByIndex: %v", err)
return "500 when get issue" return "500 when get issue"
} }
return issue.Content return issue.Content
@ -305,7 +305,7 @@ func (push *PushCommits) AvatarLink(email string) string {
if err != nil { if err != nil {
push.avatars[email] = tool.AvatarLink(email) push.avatars[email] = tool.AvatarLink(email)
if !errors.IsUserNotExist(err) { if !errors.IsUserNotExist(err) {
log.Error(4, "GetUserByEmail: %v", err) log.Error("GetUserByEmail: %v", err)
} }
} else { } else {
push.avatars[email] = u.RelAvatarLink() push.avatars[email] = u.RelAvatarLink()
@ -490,7 +490,7 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
// Only update issues via commits when internal issue tracker is enabled // Only update issues via commits when internal issue tracker is enabled
if repo.EnableIssues && !repo.EnableExternalTracker { if repo.EnableIssues && !repo.EnableExternalTracker {
if err = UpdateIssuesCommit(pusher, repo, opts.Commits.Commits); err != nil { if err = UpdateIssuesCommit(pusher, repo, opts.Commits.Commits); err != nil {
log.Error(2, "UpdateIssuesCommit: %v", err) log.Error("UpdateIssuesCommit: %v", err)
} }
} }
} }

View File

@ -11,7 +11,7 @@ import (
"time" "time"
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"xorm.io/xorm" "xorm.io/xorm"
"gogs.io/gogs/internal/tool" "gogs.io/gogs/internal/tool"
@ -75,7 +75,7 @@ func RemoveAllWithNotice(title, path string) {
desc := fmt.Sprintf("%s [%s]: %v", title, path, err) desc := fmt.Sprintf("%s [%s]: %v", title, path, err)
log.Warn(desc) log.Warn(desc)
if err = CreateRepositoryNotice(desc); err != nil { if err = CreateRepositoryNotice(desc); err != nil {
log.Error(2, "CreateRepositoryNotice: %v", err) log.Error("CreateRepositoryNotice: %v", err)
} }
} }
} }

View File

@ -10,7 +10,7 @@ import (
"time" "time"
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"xorm.io/xorm" "xorm.io/xorm"
api "github.com/gogs/go-gogs-client" api "github.com/gogs/go-gogs-client"
@ -180,7 +180,7 @@ func (cmt *Comment) mailParticipants(e Engine, opType ActionType, issue *Issue)
issue.Content = fmt.Sprintf("Reopened #%d", issue.Index) issue.Content = fmt.Sprintf("Reopened #%d", issue.Index)
} }
if err = mailIssueCommentToParticipants(issue, cmt.Poster, mentions); err != nil { if err = mailIssueCommentToParticipants(issue, cmt.Poster, mentions); err != nil {
log.Error(2, "mailIssueCommentToParticipants: %v", err) log.Error("mailIssueCommentToParticipants: %v", err)
} }
return nil return nil
@ -282,10 +282,10 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
// Notify watchers for whatever action comes in, ignore if no action type. // Notify watchers for whatever action comes in, ignore if no action type.
if act.OpType > 0 { if act.OpType > 0 {
if err = notifyWatchers(e, act); err != nil { if err = notifyWatchers(e, act); err != nil {
log.Error(2, "notifyWatchers: %v", err) log.Error("notifyWatchers: %v", err)
} }
if err = comment.mailParticipants(e, act.OpType, opts.Issue); err != nil { if err = comment.mailParticipants(e, act.OpType, opts.Issue); err != nil {
log.Error(2, "MailParticipants: %v", err) log.Error("MailParticipants: %v", err)
} }
} }
@ -356,7 +356,7 @@ func CreateIssueComment(doer *User, repo *Repository, issue *Issue, content stri
Repository: repo.APIFormat(nil), Repository: repo.APIFormat(nil),
Sender: doer.APIFormat(), Sender: doer.APIFormat(),
}); err != nil { }); err != nil {
log.Error(2, "PrepareWebhooks [comment_id: %d]: %v", comment.ID, err) log.Error("PrepareWebhooks [comment_id: %d]: %v", comment.ID, err)
} }
return comment, nil return comment, nil
@ -465,7 +465,7 @@ func UpdateComment(doer *User, c *Comment, oldContent string) (err error) {
} }
if err = c.Issue.LoadAttributes(); err != nil { if err = c.Issue.LoadAttributes(); err != nil {
log.Error(2, "Issue.LoadAttributes [issue_id: %d]: %v", c.IssueID, err) log.Error("Issue.LoadAttributes [issue_id: %d]: %v", c.IssueID, err)
} else if err = PrepareWebhooks(c.Issue.Repo, HOOK_EVENT_ISSUE_COMMENT, &api.IssueCommentPayload{ } else if err = PrepareWebhooks(c.Issue.Repo, HOOK_EVENT_ISSUE_COMMENT, &api.IssueCommentPayload{
Action: api.HOOK_ISSUE_COMMENT_EDITED, Action: api.HOOK_ISSUE_COMMENT_EDITED,
Issue: c.Issue.APIFormat(), Issue: c.Issue.APIFormat(),
@ -478,7 +478,7 @@ func UpdateComment(doer *User, c *Comment, oldContent string) (err error) {
Repository: c.Issue.Repo.APIFormat(nil), Repository: c.Issue.Repo.APIFormat(nil),
Sender: doer.APIFormat(), Sender: doer.APIFormat(),
}); err != nil { }); err != nil {
log.Error(2, "PrepareWebhooks [comment_id: %d]: %v", c.ID, err) log.Error("PrepareWebhooks [comment_id: %d]: %v", c.ID, err)
} }
return nil return nil
@ -516,11 +516,11 @@ func DeleteCommentByID(doer *User, id int64) error {
_, err = DeleteAttachmentsByComment(comment.ID, true) _, err = DeleteAttachmentsByComment(comment.ID, true)
if err != nil { if err != nil {
log.Error(2, "Failed to delete attachments by comment[%d]: %v", comment.ID, err) log.Error("Failed to delete attachments by comment[%d]: %v", comment.ID, err)
} }
if err = comment.Issue.LoadAttributes(); err != nil { if err = comment.Issue.LoadAttributes(); err != nil {
log.Error(2, "Issue.LoadAttributes [issue_id: %d]: %v", comment.IssueID, err) log.Error("Issue.LoadAttributes [issue_id: %d]: %v", comment.IssueID, err)
} else if err = PrepareWebhooks(comment.Issue.Repo, HOOK_EVENT_ISSUE_COMMENT, &api.IssueCommentPayload{ } else if err = PrepareWebhooks(comment.Issue.Repo, HOOK_EVENT_ISSUE_COMMENT, &api.IssueCommentPayload{
Action: api.HOOK_ISSUE_COMMENT_DELETED, Action: api.HOOK_ISSUE_COMMENT_DELETED,
Issue: comment.Issue.APIFormat(), Issue: comment.Issue.APIFormat(),
@ -528,7 +528,7 @@ func DeleteCommentByID(doer *User, id int64) error {
Repository: comment.Issue.Repo.APIFormat(nil), Repository: comment.Issue.Repo.APIFormat(nil),
Sender: doer.APIFormat(), Sender: doer.APIFormat(),
}); err != nil { }); err != nil {
log.Error(2, "PrepareWebhooks [comment_id: %d]: %v", comment.ID, err) log.Error("PrepareWebhooks [comment_id: %d]: %v", comment.ID, err)
} }
return nil return nil
} }

View File

@ -10,7 +10,7 @@ import (
"time" "time"
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"xorm.io/xorm" "xorm.io/xorm"
api "github.com/gogs/go-gogs-client" api "github.com/gogs/go-gogs-client"
@ -231,7 +231,7 @@ func (issue *Issue) sendLabelUpdatedWebhook(doer *User) {
if issue.IsPull { if issue.IsPull {
err = issue.PullRequest.LoadIssue() err = issue.PullRequest.LoadIssue()
if err != nil { if err != nil {
log.Error(2, "LoadIssue: %v", err) log.Error("LoadIssue: %v", err)
return return
} }
err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{ err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
@ -251,7 +251,7 @@ func (issue *Issue) sendLabelUpdatedWebhook(doer *User) {
}) })
} }
if err != nil { if err != nil {
log.Error(2, "PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err) log.Error("PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err)
} }
} }
@ -346,7 +346,7 @@ func (issue *Issue) ClearLabels(doer *User) (err error) {
if issue.IsPull { if issue.IsPull {
err = issue.PullRequest.LoadIssue() err = issue.PullRequest.LoadIssue()
if err != nil { if err != nil {
log.Error(2, "LoadIssue: %v", err) log.Error("LoadIssue: %v", err)
return return
} }
err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{ err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
@ -366,7 +366,7 @@ func (issue *Issue) ClearLabels(doer *User) (err error) {
}) })
} }
if err != nil { if err != nil {
log.Error(2, "PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err) log.Error("PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err)
} }
return nil return nil
@ -503,7 +503,7 @@ func (issue *Issue) ChangeStatus(doer *User, repo *Repository, isClosed bool) (e
err = PrepareWebhooks(repo, HOOK_EVENT_ISSUES, apiIssues) err = PrepareWebhooks(repo, HOOK_EVENT_ISSUES, apiIssues)
} }
if err != nil { if err != nil {
log.Error(2, "PrepareWebhooks [is_pull: %v, is_closed: %v]: %v", issue.IsPull, isClosed, err) log.Error("PrepareWebhooks [is_pull: %v, is_closed: %v]: %v", issue.IsPull, isClosed, err)
} }
return nil return nil
@ -545,7 +545,7 @@ func (issue *Issue) ChangeTitle(doer *User, title string) (err error) {
}) })
} }
if err != nil { if err != nil {
log.Error(2, "PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err) log.Error("PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err)
} }
return nil return nil
@ -587,7 +587,7 @@ func (issue *Issue) ChangeContent(doer *User, content string) (err error) {
}) })
} }
if err != nil { if err != nil {
log.Error(2, "PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err) log.Error("PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err)
} }
return nil return nil
@ -601,7 +601,7 @@ func (issue *Issue) ChangeAssignee(doer *User, assigneeID int64) (err error) {
issue.Assignee, err = GetUserByID(issue.AssigneeID) issue.Assignee, err = GetUserByID(issue.AssigneeID)
if err != nil && !errors.IsUserNotExist(err) { if err != nil && !errors.IsUserNotExist(err) {
log.Error(4, "GetUserByID [assignee_id: %v]: %v", issue.AssigneeID, err) log.Error("GetUserByID [assignee_id: %v]: %v", issue.AssigneeID, err)
return nil return nil
} }
@ -636,7 +636,7 @@ func (issue *Issue) ChangeAssignee(doer *User, assigneeID int64) (err error) {
err = PrepareWebhooks(issue.Repo, HOOK_EVENT_ISSUES, apiIssues) err = PrepareWebhooks(issue.Repo, HOOK_EVENT_ISSUES, apiIssues)
} }
if err != nil { if err != nil {
log.Error(4, "PrepareWebhooks [is_pull: %v, remove_assignee: %v]: %v", issue.IsPull, isRemoveAssignee, err) log.Error("PrepareWebhooks [is_pull: %v, remove_assignee: %v]: %v", issue.IsPull, isRemoveAssignee, err)
} }
return nil return nil
@ -777,10 +777,10 @@ func NewIssue(repo *Repository, issue *Issue, labelIDs []int64, uuids []string)
RepoName: repo.Name, RepoName: repo.Name,
IsPrivate: repo.IsPrivate, IsPrivate: repo.IsPrivate,
}); err != nil { }); err != nil {
log.Error(2, "NotifyWatchers: %v", err) log.Error("NotifyWatchers: %v", err)
} }
if err = issue.MailParticipants(); err != nil { if err = issue.MailParticipants(); err != nil {
log.Error(2, "MailParticipants: %v", err) log.Error("MailParticipants: %v", err)
} }
if err = PrepareWebhooks(repo, HOOK_EVENT_ISSUES, &api.IssuesPayload{ if err = PrepareWebhooks(repo, HOOK_EVENT_ISSUES, &api.IssuesPayload{
@ -790,7 +790,7 @@ func NewIssue(repo *Repository, issue *Issue, labelIDs []int64, uuids []string)
Repository: repo.APIFormat(nil), Repository: repo.APIFormat(nil),
Sender: issue.Poster.APIFormat(), Sender: issue.Poster.APIFormat(),
}); err != nil { }); err != nil {
log.Error(2, "PrepareWebhooks: %v", err) log.Error("PrepareWebhooks: %v", err)
} }
return nil return nil

View File

@ -8,7 +8,7 @@ import (
"fmt" "fmt"
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/mailer" "gogs.io/gogs/internal/mailer"
"gogs.io/gogs/internal/markup" "gogs.io/gogs/internal/markup"
@ -173,7 +173,7 @@ func (issue *Issue) MailParticipants() (err error) {
} }
if err = mailIssueCommentToParticipants(issue, issue.Poster, mentions); err != nil { if err = mailIssueCommentToParticipants(issue, issue.Poster, mentions); err != nil {
log.Error(2, "mailIssueCommentToParticipants: %v", err) log.Error("mailIssueCommentToParticipants: %v", err)
} }
return nil return nil

View File

@ -19,8 +19,8 @@ import (
"github.com/go-macaron/binding" "github.com/go-macaron/binding"
"github.com/json-iterator/go" "github.com/json-iterator/go"
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1"
"gopkg.in/ini.v1" "gopkg.in/ini.v1"
log "unknwon.dev/clog/v2"
"xorm.io/core" "xorm.io/core"
"xorm.io/xorm" "xorm.io/xorm"
@ -469,7 +469,7 @@ func LoadAuthSources() {
paths, err := com.GetFileListBySuffix(authdPath, ".conf") paths, err := com.GetFileListBySuffix(authdPath, ".conf")
if err != nil { if err != nil {
log.Fatal(2, "Failed to list authentication sources: %v", err) log.Fatal("Failed to list authentication sources: %v", err)
} }
localLoginSources.sources = make([]*LoginSource, 0, len(paths)) localLoginSources.sources = make([]*LoginSource, 0, len(paths))
@ -477,7 +477,7 @@ func LoadAuthSources() {
for _, fpath := range paths { for _, fpath := range paths {
authSource, err := ini.Load(fpath) authSource, err := ini.Load(fpath)
if err != nil { if err != nil {
log.Fatal(2, "Failed to load authentication source: %v", err) log.Fatal("Failed to load authentication source: %v", err)
} }
authSource.NameMapper = ini.TitleUnderscore authSource.NameMapper = ini.TitleUnderscore
@ -496,7 +496,7 @@ func LoadAuthSources() {
fi, err := os.Stat(fpath) fi, err := os.Stat(fpath)
if err != nil { if err != nil {
log.Fatal(2, "Failed to load authentication source: %v", err) log.Fatal("Failed to load authentication source: %v", err)
} }
loginSource.Updated = fi.ModTime() loginSource.Updated = fi.ModTime()
@ -519,11 +519,11 @@ func LoadAuthSources() {
loginSource.Type = LOGIN_GITHUB loginSource.Type = LOGIN_GITHUB
loginSource.Cfg = &GitHubConfig{} loginSource.Cfg = &GitHubConfig{}
default: default:
log.Fatal(2, "Failed to load authentication source: unknown type '%s'", authType) log.Fatal("Failed to load authentication source: unknown type '%s'", authType)
} }
if err = authSource.Section("config").MapTo(loginSource.Cfg); err != nil { if err = authSource.Section("config").MapTo(loginSource.Cfg); err != nil {
log.Fatal(2, "Failed to parse authentication source 'config': %v", err) log.Fatal("Failed to parse authentication source 'config': %v", err)
} }
localLoginSources.sources = append(localLoginSources.sources, loginSource) localLoginSources.sources = append(localLoginSources.sources, loginSource)

View File

@ -10,7 +10,7 @@ import (
"time" "time"
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"xorm.io/xorm" "xorm.io/xorm"
"gogs.io/gogs/internal/tool" "gogs.io/gogs/internal/tool"
@ -93,7 +93,7 @@ func Migrate(x *xorm.Engine) error {
v := currentVersion.Version v := currentVersion.Version
if _MIN_DB_VER > v { if _MIN_DB_VER > v {
log.Fatal(0, ` log.Fatal(`
Hi there, thank you for using Gogs for so long! Hi there, thank you for using Gogs for so long!
However, Gogs has stopped supporting auto-migration from your previously installed version. However, Gogs has stopped supporting auto-migration from your previously installed version.
But the good news is, it's very easy to fix this problem! But the good news is, it's very easy to fix this problem!

View File

@ -12,7 +12,7 @@ import (
"strings" "strings"
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"xorm.io/xorm" "xorm.io/xorm"
"gogs.io/gogs/internal/osutil" "gogs.io/gogs/internal/osutil"

View File

@ -9,8 +9,8 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
log "unknwon.dev/clog/v2"
"xorm.io/xorm" "xorm.io/xorm"
log "gopkg.in/clog.v1"
"github.com/gogs/git-module" "github.com/gogs/git-module"

View File

@ -8,7 +8,7 @@ import (
"fmt" "fmt"
"time" "time"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"xorm.io/xorm" "xorm.io/xorm"
api "github.com/gogs/go-gogs-client" api "github.com/gogs/go-gogs-client"
@ -336,7 +336,7 @@ func ChangeMilestoneAssign(doer *User, issue *Issue, oldMilestoneID int64) (err
if issue.IsPull { if issue.IsPull {
err = issue.PullRequest.LoadIssue() err = issue.PullRequest.LoadIssue()
if err != nil { if err != nil {
log.Error(2, "LoadIssue: %v", err) log.Error("LoadIssue: %v", err)
return return
} }
err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{ err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
@ -356,7 +356,7 @@ func ChangeMilestoneAssign(doer *User, issue *Issue, oldMilestoneID int64) (err
}) })
} }
if err != nil { if err != nil {
log.Error(2, "PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err) log.Error("PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err)
} }
return nil return nil

View File

@ -12,8 +12,8 @@ import (
"time" "time"
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1"
"gopkg.in/ini.v1" "gopkg.in/ini.v1"
log "unknwon.dev/clog/v2"
"xorm.io/xorm" "xorm.io/xorm"
"github.com/gogs/git-module" "github.com/gogs/git-module"
@ -58,7 +58,7 @@ func (m *Mirror) AfterSet(colName string, _ xorm.Cell) {
case "repo_id": case "repo_id":
m.Repo, err = GetRepositoryByID(m.RepoID) m.Repo, err = GetRepositoryByID(m.RepoID)
if err != nil { if err != nil {
log.Error(3, "GetRepositoryByID [%d]: %v", m.ID, err) log.Error("GetRepositoryByID [%d]: %v", m.ID, err)
} }
case "updated_unix": case "updated_unix":
m.LastSync = time.Unix(m.LastSyncUnix, 0).Local() m.LastSync = time.Unix(m.LastSyncUnix, 0).Local()
@ -119,7 +119,7 @@ func (m *Mirror) readAddress() {
cfg, err := ini.Load(m.Repo.GitConfigPath()) cfg, err := ini.Load(m.Repo.GitConfigPath())
if err != nil { if err != nil {
log.Error(2, "Load: %v", err) log.Error("Load: %v", err)
return return
} }
m.address = cfg.Section("remote \"origin\"").Key("url").Value() m.address = cfg.Section("remote \"origin\"").Key("url").Value()
@ -233,12 +233,12 @@ func parseRemoteUpdateOutput(output string) []*mirrorSyncResult {
case strings.HasPrefix(lines[i], " "): // New commits of a reference case strings.HasPrefix(lines[i], " "): // New commits of a reference
delimIdx := strings.Index(lines[i][3:], " ") delimIdx := strings.Index(lines[i][3:], " ")
if delimIdx == -1 { if delimIdx == -1 {
log.Error(2, "SHA delimiter not found: %q", lines[i]) log.Error("SHA delimiter not found: %q", lines[i])
continue continue
} }
shas := strings.Split(lines[i][3:delimIdx+3], "..") shas := strings.Split(lines[i][3:delimIdx+3], "..")
if len(shas) != 2 { if len(shas) != 2 {
log.Error(2, "Expect two SHAs but not what found: %q", lines[i]) log.Error("Expect two SHAs but not what found: %q", lines[i])
continue continue
} }
results = append(results, &mirrorSyncResult{ results = append(results, &mirrorSyncResult{
@ -268,7 +268,7 @@ func (m *Mirror) runSync() ([]*mirrorSyncResult, bool) {
}) { }) {
desc := fmt.Sprintf("Source URL of mirror repository '%s' is not accessible: %s", m.Repo.FullName(), m.MosaicsAddress()) desc := fmt.Sprintf("Source URL of mirror repository '%s' is not accessible: %s", m.Repo.FullName(), m.MosaicsAddress())
if err := CreateRepositoryNotice(desc); err != nil { if err := CreateRepositoryNotice(desc); err != nil {
log.Error(2, "CreateRepositoryNotice: %v", err) log.Error("CreateRepositoryNotice: %v", err)
} }
return nil, false return nil, false
} }
@ -281,17 +281,17 @@ func (m *Mirror) runSync() ([]*mirrorSyncResult, bool) {
timeout, repoPath, fmt.Sprintf("Mirror.runSync: %s", repoPath), timeout, repoPath, fmt.Sprintf("Mirror.runSync: %s", repoPath),
"git", gitArgs...) "git", gitArgs...)
if err != nil { if err != nil {
desc := fmt.Sprintf("Fail to update mirror repository '%s': %s", repoPath, stderr) desc := fmt.Sprintf("Failed to update mirror repository '%s': %s", repoPath, stderr)
log.Error(2, desc) log.Error(desc)
if err = CreateRepositoryNotice(desc); err != nil { if err = CreateRepositoryNotice(desc); err != nil {
log.Error(2, "CreateRepositoryNotice: %v", err) log.Error("CreateRepositoryNotice: %v", err)
} }
return nil, false return nil, false
} }
output := stderr output := stderr
if err := m.Repo.UpdateSize(); err != nil { if err := m.Repo.UpdateSize(); err != nil {
log.Error(2, "UpdateSize [repo_id: %d]: %v", m.Repo.ID, err) log.Error("UpdateSize [repo_id: %d]: %v", m.Repo.ID, err)
} }
if m.Repo.HasWiki() { if m.Repo.HasWiki() {
@ -299,10 +299,10 @@ func (m *Mirror) runSync() ([]*mirrorSyncResult, bool) {
if _, stderr, err := process.ExecDir( if _, stderr, err := process.ExecDir(
timeout, wikiPath, fmt.Sprintf("Mirror.runSync: %s", wikiPath), timeout, wikiPath, fmt.Sprintf("Mirror.runSync: %s", wikiPath),
"git", "remote", "update", "--prune"); err != nil { "git", "remote", "update", "--prune"); err != nil {
desc := fmt.Sprintf("Fail to update mirror wiki repository '%s': %s", wikiPath, stderr) desc := fmt.Sprintf("Failed to update mirror wiki repository '%s': %s", wikiPath, stderr)
log.Error(2, desc) log.Error(desc)
if err = CreateRepositoryNotice(desc); err != nil { if err = CreateRepositoryNotice(desc); err != nil {
log.Error(2, "CreateRepositoryNotice: %v", err) log.Error("CreateRepositoryNotice: %v", err)
} }
} }
} }
@ -353,14 +353,14 @@ func MirrorUpdate() {
if err := x.Where("next_update_unix<=?", time.Now().Unix()).Iterate(new(Mirror), func(idx int, bean interface{}) error { if err := x.Where("next_update_unix<=?", time.Now().Unix()).Iterate(new(Mirror), func(idx int, bean interface{}) error {
m := bean.(*Mirror) m := bean.(*Mirror)
if m.Repo == nil { if m.Repo == nil {
log.Error(2, "Disconnected mirror repository found: %d", m.ID) log.Error("Disconnected mirror repository found: %d", m.ID)
return nil return nil
} }
MirrorQueue.Add(m.RepoID) MirrorQueue.Add(m.RepoID)
return nil return nil
}); err != nil { }); err != nil {
log.Error(2, "MirrorUpdate: %v", err) log.Error("MirrorUpdate: %v", err)
} }
} }
@ -374,7 +374,7 @@ func SyncMirrors() {
m, err := GetMirrorByRepoID(com.StrTo(repoID).MustInt64()) m, err := GetMirrorByRepoID(com.StrTo(repoID).MustInt64())
if err != nil { if err != nil {
log.Error(2, "GetMirrorByRepoID [%d]: %v", m.RepoID, err) log.Error("GetMirrorByRepoID [%d]: %v", m.RepoID, err)
continue continue
} }
@ -385,7 +385,7 @@ func SyncMirrors() {
m.ScheduleNextSync() m.ScheduleNextSync()
if err = UpdateMirror(m); err != nil { if err = UpdateMirror(m); err != nil {
log.Error(2, "UpdateMirror [%d]: %v", m.RepoID, err) log.Error("UpdateMirror [%d]: %v", m.RepoID, err)
continue continue
} }
@ -399,7 +399,7 @@ func SyncMirrors() {
} else { } else {
gitRepo, err = git.OpenRepository(m.Repo.RepoPath()) gitRepo, err = git.OpenRepository(m.Repo.RepoPath())
if err != nil { if err != nil {
log.Error(2, "OpenRepository [%d]: %v", m.RepoID, err) log.Error("OpenRepository [%d]: %v", m.RepoID, err)
continue continue
} }
} }
@ -413,7 +413,7 @@ func SyncMirrors() {
// Delete reference // Delete reference
if result.newCommitID == GIT_SHORT_EMPTY_SHA { if result.newCommitID == GIT_SHORT_EMPTY_SHA {
if err = MirrorSyncDeleteAction(m.Repo, result.refName); err != nil { if err = MirrorSyncDeleteAction(m.Repo, result.refName); err != nil {
log.Error(2, "MirrorSyncDeleteAction [repo_id: %d]: %v", m.RepoID, err) log.Error("MirrorSyncDeleteAction [repo_id: %d]: %v", m.RepoID, err)
} }
continue continue
} }
@ -422,7 +422,7 @@ func SyncMirrors() {
isNewRef := false isNewRef := false
if result.oldCommitID == GIT_SHORT_EMPTY_SHA { if result.oldCommitID == GIT_SHORT_EMPTY_SHA {
if err = MirrorSyncCreateAction(m.Repo, result.refName); err != nil { if err = MirrorSyncCreateAction(m.Repo, result.refName); err != nil {
log.Error(2, "MirrorSyncCreateAction [repo_id: %d]: %v", m.RepoID, err) log.Error("MirrorSyncCreateAction [repo_id: %d]: %v", m.RepoID, err)
continue continue
} }
isNewRef = true isNewRef = true
@ -435,33 +435,33 @@ func SyncMirrors() {
if !isNewRef { if !isNewRef {
oldCommitID, err = git.GetFullCommitID(gitRepo.Path, result.oldCommitID) oldCommitID, err = git.GetFullCommitID(gitRepo.Path, result.oldCommitID)
if err != nil { if err != nil {
log.Error(2, "GetFullCommitID [%d]: %v", m.RepoID, err) log.Error("GetFullCommitID [%d]: %v", m.RepoID, err)
continue continue
} }
newCommitID, err = git.GetFullCommitID(gitRepo.Path, result.newCommitID) newCommitID, err = git.GetFullCommitID(gitRepo.Path, result.newCommitID)
if err != nil { if err != nil {
log.Error(2, "GetFullCommitID [%d]: %v", m.RepoID, err) log.Error("GetFullCommitID [%d]: %v", m.RepoID, err)
continue continue
} }
commits, err = gitRepo.CommitsBetweenIDs(newCommitID, oldCommitID) commits, err = gitRepo.CommitsBetweenIDs(newCommitID, oldCommitID)
if err != nil { if err != nil {
log.Error(2, "CommitsBetweenIDs [repo_id: %d, new_commit_id: %s, old_commit_id: %s]: %v", m.RepoID, newCommitID, oldCommitID, err) log.Error("CommitsBetweenIDs [repo_id: %d, new_commit_id: %s, old_commit_id: %s]: %v", m.RepoID, newCommitID, oldCommitID, err)
continue continue
} }
} else { } else {
refNewCommitID, err := gitRepo.GetBranchCommitID(result.refName) refNewCommitID, err := gitRepo.GetBranchCommitID(result.refName)
if err != nil { if err != nil {
log.Error(2, "GetFullCommitID [%d]: %v", m.RepoID, err) log.Error("GetFullCommitID [%d]: %v", m.RepoID, err)
continue continue
} }
if newCommit, err := gitRepo.GetCommit(refNewCommitID); err != nil { if newCommit, err := gitRepo.GetCommit(refNewCommitID); err != nil {
log.Error(2, "GetCommit [repo_id: %d, commit_id: %s]: %v", m.RepoID, refNewCommitID, err) log.Error("GetCommit [repo_id: %d, commit_id: %s]: %v", m.RepoID, refNewCommitID, err)
continue continue
} else { } else {
// TODO: Get the commits for the new ref until the closest ancestor branch like Github does // TODO: Get the commits for the new ref until the closest ancestor branch like Github does
commits, err = newCommit.CommitsBeforeLimit(10) commits, err = newCommit.CommitsBeforeLimit(10)
if err != nil { if err != nil {
log.Error(2, "CommitsBeforeLimit [repo_id: %d, commit_id: %s]: %v", m.RepoID, refNewCommitID, err) log.Error("CommitsBeforeLimit [repo_id: %d, commit_id: %s]: %v", m.RepoID, refNewCommitID, err)
} }
oldCommitID = git.EMPTY_SHA oldCommitID = git.EMPTY_SHA
newCommitID = refNewCommitID newCommitID = refNewCommitID
@ -473,13 +473,13 @@ func SyncMirrors() {
NewCommitID: newCommitID, NewCommitID: newCommitID,
Commits: ListToPushCommits(commits), Commits: ListToPushCommits(commits),
}); err != nil { }); err != nil {
log.Error(2, "MirrorSyncPushAction [repo_id: %d]: %v", m.RepoID, err) log.Error("MirrorSyncPushAction [repo_id: %d]: %v", m.RepoID, err)
continue continue
} }
} }
if _, err = x.Exec("UPDATE mirror SET updated_unix = ? WHERE repo_id = ?", time.Now().Unix(), m.RepoID); err != nil { if _, err = x.Exec("UPDATE mirror SET updated_unix = ? WHERE repo_id = ?", time.Now().Unix(), m.RepoID); err != nil {
log.Error(2, "Update 'mirror.updated_unix' [%d]: %v", m.RepoID, err) log.Error("Update 'mirror.updated_unix' [%d]: %v", m.RepoID, err)
continue continue
} }
@ -487,14 +487,14 @@ func SyncMirrors() {
// update if latest commit date is newer. // update if latest commit date is newer.
commitDate, err := git.GetLatestCommitDate(m.Repo.RepoPath(), "") commitDate, err := git.GetLatestCommitDate(m.Repo.RepoPath(), "")
if err != nil { if err != nil {
log.Error(2, "GetLatestCommitDate [%d]: %v", m.RepoID, err) log.Error("GetLatestCommitDate [%d]: %v", m.RepoID, err)
continue continue
} else if commitDate.Before(m.Repo.Updated) { } else if commitDate.Before(m.Repo.Updated) {
continue continue
} }
if _, err = x.Exec("UPDATE repository SET updated_unix = ? WHERE id = ?", commitDate.Unix(), m.RepoID); err != nil { if _, err = x.Exec("UPDATE repository SET updated_unix = ? WHERE id = ?", commitDate.Unix(), m.RepoID); err != nil {
log.Error(2, "Update 'repository.updated_unix' [%d]: %v", m.RepoID, err) log.Error("Update 'repository.updated_unix' [%d]: %v", m.RepoID, err)
continue continue
} }
} }

View File

@ -20,7 +20,7 @@ import (
"github.com/json-iterator/go" "github.com/json-iterator/go"
_ "github.com/lib/pq" _ "github.com/lib/pq"
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"xorm.io/core" "xorm.io/core"
"xorm.io/xorm" "xorm.io/xorm"
@ -370,20 +370,20 @@ func ImportDatabase(dirPath string, verbose bool) (err error) {
meta := make(map[string]interface{}) meta := make(map[string]interface{})
if err = jsoniter.Unmarshal(scanner.Bytes(), &meta); err != nil { if err = jsoniter.Unmarshal(scanner.Bytes(), &meta); err != nil {
log.Error(2, "Failed to unmarshal to map: %v", err) log.Error("Failed to unmarshal to map: %v", err)
} }
// Reset created_unix back to the date save in archive because Insert method updates its value // Reset created_unix back to the date save in archive because Insert method updates its value
if isInsertProcessor && !skipInsertProcessors[rawTableName] { if isInsertProcessor && !skipInsertProcessors[rawTableName] {
if _, err = x.Exec("UPDATE "+rawTableName+" SET created_unix=? WHERE id=?", meta["CreatedUnix"], meta["ID"]); err != nil { if _, err = x.Exec("UPDATE "+rawTableName+" SET created_unix=? WHERE id=?", meta["CreatedUnix"], meta["ID"]); err != nil {
log.Error(2, "Failed to reset 'created_unix': %v", err) log.Error("Failed to reset 'created_unix': %v", err)
} }
} }
switch rawTableName { switch rawTableName {
case "milestone": case "milestone":
if _, err = x.Exec("UPDATE "+rawTableName+" SET deadline_unix=?, closed_date_unix=? WHERE id=?", meta["DeadlineUnix"], meta["ClosedDateUnix"], meta["ID"]); err != nil { if _, err = x.Exec("UPDATE "+rawTableName+" SET deadline_unix=?, closed_date_unix=? WHERE id=?", meta["DeadlineUnix"], meta["ClosedDateUnix"], meta["ID"]); err != nil {
log.Error(2, "Failed to reset 'milestone.deadline_unix', 'milestone.closed_date_unix': %v", err) log.Error("Failed to reset 'milestone.deadline_unix', 'milestone.closed_date_unix': %v", err)
} }
} }
} }

View File

@ -12,7 +12,7 @@ import (
"time" "time"
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"xorm.io/xorm" "xorm.io/xorm"
"github.com/gogs/git-module" "github.com/gogs/git-module"
@ -331,12 +331,12 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle
} }
if err = MergePullRequestAction(doer, pr.Issue.Repo, pr.Issue); err != nil { if err = MergePullRequestAction(doer, pr.Issue.Repo, pr.Issue); err != nil {
log.Error(2, "MergePullRequestAction [%d]: %v", pr.ID, err) log.Error("MergePullRequestAction [%d]: %v", pr.ID, err)
} }
// Reload pull request information. // Reload pull request information.
if err = pr.LoadAttributes(); err != nil { if err = pr.LoadAttributes(); err != nil {
log.Error(2, "LoadAttributes: %v", err) log.Error("LoadAttributes: %v", err)
return nil return nil
} }
if err = PrepareWebhooks(pr.Issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{ if err = PrepareWebhooks(pr.Issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
@ -346,13 +346,13 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle
Repository: pr.Issue.Repo.APIFormat(nil), Repository: pr.Issue.Repo.APIFormat(nil),
Sender: doer.APIFormat(), Sender: doer.APIFormat(),
}); err != nil { }); err != nil {
log.Error(2, "PrepareWebhooks: %v", err) log.Error("PrepareWebhooks: %v", err)
return nil return nil
} }
l, err := headGitRepo.CommitsBetweenIDs(pr.MergedCommitID, pr.MergeBase) l, err := headGitRepo.CommitsBetweenIDs(pr.MergedCommitID, pr.MergeBase)
if err != nil { if err != nil {
log.Error(2, "CommitsBetweenIDs: %v", err) log.Error("CommitsBetweenIDs: %v", err)
return nil return nil
} }
@ -361,7 +361,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle
// to avoid strange diff commits produced. // to avoid strange diff commits produced.
mergeCommit, err := baseGitRepo.GetBranchCommit(pr.BaseBranch) mergeCommit, err := baseGitRepo.GetBranchCommit(pr.BaseBranch)
if err != nil { if err != nil {
log.Error(2, "GetBranchCommit: %v", err) log.Error("GetBranchCommit: %v", err)
return nil return nil
} }
if mergeStyle == MERGE_STYLE_REGULAR { if mergeStyle == MERGE_STYLE_REGULAR {
@ -370,7 +370,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle
commits, err := ListToPushCommits(l).ToApiPayloadCommits(pr.BaseRepo.RepoPath(), pr.BaseRepo.HTMLURL()) commits, err := ListToPushCommits(l).ToApiPayloadCommits(pr.BaseRepo.RepoPath(), pr.BaseRepo.HTMLURL())
if err != nil { if err != nil {
log.Error(2, "ToApiPayloadCommits: %v", err) log.Error("ToApiPayloadCommits: %v", err)
return nil return nil
} }
@ -385,7 +385,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle
Sender: doer.APIFormat(), Sender: doer.APIFormat(),
} }
if err = PrepareWebhooks(pr.BaseRepo, HOOK_EVENT_PUSH, p); err != nil { if err = PrepareWebhooks(pr.BaseRepo, HOOK_EVENT_PUSH, p); err != nil {
log.Error(2, "PrepareWebhooks: %v", err) log.Error("PrepareWebhooks: %v", err)
return nil return nil
} }
return nil return nil
@ -490,10 +490,10 @@ func NewPullRequest(repo *Repository, pull *Issue, labelIDs []int64, uuids []str
RepoName: repo.Name, RepoName: repo.Name,
IsPrivate: repo.IsPrivate, IsPrivate: repo.IsPrivate,
}); err != nil { }); err != nil {
log.Error(2, "NotifyWatchers: %v", err) log.Error("NotifyWatchers: %v", err)
} }
if err = pull.MailParticipants(); err != nil { if err = pull.MailParticipants(); err != nil {
log.Error(2, "MailParticipants: %v", err) log.Error("MailParticipants: %v", err)
} }
pr.Issue = pull pr.Issue = pull
@ -505,7 +505,7 @@ func NewPullRequest(repo *Repository, pull *Issue, labelIDs []int64, uuids []str
Repository: repo.APIFormat(nil), Repository: repo.APIFormat(nil),
Sender: pull.Poster.APIFormat(), Sender: pull.Poster.APIFormat(),
}); err != nil { }); err != nil {
log.Error(2, "PrepareWebhooks: %v", err) log.Error("PrepareWebhooks: %v", err)
} }
return nil return nil
@ -667,7 +667,7 @@ func (pr *PullRequest) AddToTaskQueue() {
go PullRequestQueue.AddFunc(pr.ID, func() { go PullRequestQueue.AddFunc(pr.ID, func() {
pr.Status = PULL_REQUEST_STATUS_CHECKING pr.Status = PULL_REQUEST_STATUS_CHECKING
if err := pr.UpdateCols("status"); err != nil { if err := pr.UpdateCols("status"); err != nil {
log.Error(3, "AddToTaskQueue.UpdateCols[%d].(add to queue): %v", pr.ID, err) log.Error("AddToTaskQueue.UpdateCols[%d].(add to queue): %v", pr.ID, err)
} }
}) })
} }
@ -717,10 +717,10 @@ func addHeadRepoTasks(prs []*PullRequest) {
for _, pr := range prs { for _, pr := range prs {
log.Trace("addHeadRepoTasks[%d]: composing new test task", pr.ID) log.Trace("addHeadRepoTasks[%d]: composing new test task", pr.ID)
if err := pr.UpdatePatch(); err != nil { if err := pr.UpdatePatch(); err != nil {
log.Error(4, "UpdatePatch: %v", err) log.Error("UpdatePatch: %v", err)
continue continue
} else if err := pr.PushToBaseRepo(); err != nil { } else if err := pr.PushToBaseRepo(); err != nil {
log.Error(4, "PushToBaseRepo: %v", err) log.Error("PushToBaseRepo: %v", err)
continue continue
} }
@ -734,20 +734,20 @@ func AddTestPullRequestTask(doer *User, repoID int64, branch string, isSync bool
log.Trace("AddTestPullRequestTask [head_repo_id: %d, head_branch: %s]: finding pull requests", repoID, branch) log.Trace("AddTestPullRequestTask [head_repo_id: %d, head_branch: %s]: finding pull requests", repoID, branch)
prs, err := GetUnmergedPullRequestsByHeadInfo(repoID, branch) prs, err := GetUnmergedPullRequestsByHeadInfo(repoID, branch)
if err != nil { if err != nil {
log.Error(2, "Find pull requests [head_repo_id: %d, head_branch: %s]: %v", repoID, branch, err) log.Error("Find pull requests [head_repo_id: %d, head_branch: %s]: %v", repoID, branch, err)
return return
} }
if isSync { if isSync {
if err = PullRequestList(prs).LoadAttributes(); err != nil { if err = PullRequestList(prs).LoadAttributes(); err != nil {
log.Error(2, "PullRequestList.LoadAttributes: %v", err) log.Error("PullRequestList.LoadAttributes: %v", err)
} }
if err == nil { if err == nil {
for _, pr := range prs { for _, pr := range prs {
pr.Issue.PullRequest = pr pr.Issue.PullRequest = pr
if err = pr.Issue.LoadAttributes(); err != nil { if err = pr.Issue.LoadAttributes(); err != nil {
log.Error(2, "LoadAttributes: %v", err) log.Error("LoadAttributes: %v", err)
continue continue
} }
if err = PrepareWebhooks(pr.Issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{ if err = PrepareWebhooks(pr.Issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
@ -757,7 +757,7 @@ func AddTestPullRequestTask(doer *User, repoID int64, branch string, isSync bool
Repository: pr.Issue.Repo.APIFormat(nil), Repository: pr.Issue.Repo.APIFormat(nil),
Sender: doer.APIFormat(), Sender: doer.APIFormat(),
}); err != nil { }); err != nil {
log.Error(2, "PrepareWebhooks [pull_id: %v]: %v", pr.ID, err) log.Error("PrepareWebhooks [pull_id: %v]: %v", pr.ID, err)
continue continue
} }
} }
@ -769,7 +769,7 @@ func AddTestPullRequestTask(doer *User, repoID int64, branch string, isSync bool
log.Trace("AddTestPullRequestTask [base_repo_id: %d, base_branch: %s]: finding pull requests", repoID, branch) log.Trace("AddTestPullRequestTask [base_repo_id: %d, base_branch: %s]: finding pull requests", repoID, branch)
prs, err = GetUnmergedPullRequestsByBaseInfo(repoID, branch) prs, err = GetUnmergedPullRequestsByBaseInfo(repoID, branch)
if err != nil { if err != nil {
log.Error(2, "Find pull requests [base_repo_id: %d, base_branch: %s]: %v", repoID, branch, err) log.Error("Find pull requests [base_repo_id: %d, base_branch: %s]: %v", repoID, branch, err)
return return
} }
for _, pr := range prs { for _, pr := range prs {
@ -796,7 +796,7 @@ func (pr *PullRequest) checkAndUpdateStatus() {
// Make sure there is no waiting test to process before levaing the checking status. // Make sure there is no waiting test to process before levaing the checking status.
if !PullRequestQueue.Exist(pr.ID) { if !PullRequestQueue.Exist(pr.ID) {
if err := pr.UpdateCols("status"); err != nil { if err := pr.UpdateCols("status"); err != nil {
log.Error(4, "Update[%d]: %v", pr.ID, err) log.Error("Update[%d]: %v", pr.ID, err)
} }
} }
} }
@ -812,12 +812,12 @@ func TestPullRequests() {
pr := bean.(*PullRequest) pr := bean.(*PullRequest)
if err := pr.LoadAttributes(); err != nil { if err := pr.LoadAttributes(); err != nil {
log.Error(3, "LoadAttributes: %v", err) log.Error("LoadAttributes: %v", err)
return nil return nil
} }
if err := pr.testPatch(); err != nil { if err := pr.testPatch(); err != nil {
log.Error(3, "testPatch: %v", err) log.Error("testPatch: %v", err)
return nil return nil
} }
prs = append(prs, pr) prs = append(prs, pr)
@ -836,10 +836,10 @@ func TestPullRequests() {
pr, err := GetPullRequestByID(com.StrTo(prID).MustInt64()) pr, err := GetPullRequestByID(com.StrTo(prID).MustInt64())
if err != nil { if err != nil {
log.Error(4, "GetPullRequestByID[%s]: %v", prID, err) log.Error("GetPullRequestByID[%s]: %v", prID, err)
continue continue
} else if err = pr.testPatch(); err != nil { } else if err = pr.testPatch(); err != nil {
log.Error(4, "testPatch[%d]: %v", pr.ID, err) log.Error("testPatch[%d]: %v", pr.ID, err)
continue continue
} }

View File

@ -10,7 +10,7 @@ import (
"strings" "strings"
"time" "time"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"xorm.io/xorm" "xorm.io/xorm"
"github.com/gogs/git-module" "github.com/gogs/git-module"
@ -156,7 +156,7 @@ func (r *Release) preparePublishWebhooks() {
Repository: r.Repo.APIFormat(nil), Repository: r.Repo.APIFormat(nil),
Sender: r.Publisher.APIFormat(), Sender: r.Publisher.APIFormat(),
}); err != nil { }); err != nil {
log.Error(2, "PrepareWebhooks: %v", err) log.Error("PrepareWebhooks: %v", err)
} }
} }

View File

@ -23,8 +23,8 @@ import (
"github.com/nfnt/resize" "github.com/nfnt/resize"
"github.com/unknwon/cae/zip" "github.com/unknwon/cae/zip"
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1"
"gopkg.in/ini.v1" "gopkg.in/ini.v1"
log "unknwon.dev/clog/v2"
"xorm.io/xorm" "xorm.io/xorm"
"github.com/gogs/git-module" "github.com/gogs/git-module"
@ -59,13 +59,13 @@ func LoadRepoConfig() {
for i, t := range types { for i, t := range types {
files, err := conf.AssetDir("conf/" + t) files, err := conf.AssetDir("conf/" + t)
if err != nil { if err != nil {
log.Fatal(4, "Fail to get %s files: %v", t, err) log.Fatal("Failed to get %s files: %v", t, err)
} }
customPath := path.Join(setting.CustomPath, "conf", t) customPath := path.Join(setting.CustomPath, "conf", t)
if com.IsDir(customPath) { if com.IsDir(customPath) {
customFiles, err := com.StatDir(customPath) customFiles, err := com.StatDir(customPath)
if err != nil { if err != nil {
log.Fatal(4, "Fail to get custom %s files: %v", t, err) log.Fatal("Failed to get custom %s files: %v", t, err)
} }
for _, f := range customFiles { for _, f := range customFiles {
@ -106,19 +106,19 @@ func NewRepoContext() {
// Check Git installation. // Check Git installation.
if _, err := exec.LookPath("git"); err != nil { if _, err := exec.LookPath("git"); err != nil {
log.Fatal(2, "Failed to test 'git' command: %v (forgotten install?)", err) log.Fatal("Failed to test 'git' command: %v (forgotten install?)", err)
} }
// Check Git version. // Check Git version.
var err error var err error
setting.Git.Version, err = git.BinVersion() setting.Git.Version, err = git.BinVersion()
if err != nil { if err != nil {
log.Fatal(2, "Failed to get Git version: %v", err) log.Fatal("Failed to get Git version: %v", err)
} }
log.Trace("Git version: %s", setting.Git.Version) log.Trace("Git version: %s", setting.Git.Version)
if version.Compare("1.8.3", setting.Git.Version, ">") { if version.Compare("1.8.3", setting.Git.Version, ">") {
log.Fatal(2, "Gogs requires Git version greater or equal to 1.8.3") log.Fatal("Gogs requires Git version greater or equal to 1.8.3")
} }
git.HookDir = "custom_hooks" git.HookDir = "custom_hooks"
git.HookSampleDir = "hooks" git.HookSampleDir = "hooks"
@ -130,11 +130,11 @@ func NewRepoContext() {
// ExitError indicates this config is not set // ExitError indicates this config is not set
if _, ok := err.(*exec.ExitError); ok || strings.TrimSpace(stdout) == "" { if _, ok := err.(*exec.ExitError); ok || strings.TrimSpace(stdout) == "" {
if _, stderr, gerr := process.Exec("NewRepoContext(set "+configKey+")", "git", "config", "--global", configKey, defaultValue); gerr != nil { if _, stderr, gerr := process.Exec("NewRepoContext(set "+configKey+")", "git", "config", "--global", configKey, defaultValue); gerr != nil {
log.Fatal(4, "Fail to set git %s(%s): %s", configKey, gerr, stderr) log.Fatal("Failed to set git %s(%s): %s", configKey, gerr, stderr)
} }
log.Info("Git config %s set to %s", configKey, defaultValue) log.Info("Git config %s set to %s", configKey, defaultValue)
} else { } else {
log.Fatal(4, "Fail to get git %s(%s): %s", configKey, err, stderr) log.Fatal("Failed to get git %s(%s): %s", configKey, err, stderr)
} }
} }
} }
@ -142,7 +142,7 @@ func NewRepoContext() {
// Set git some configurations. // Set git some configurations.
if _, stderr, err := process.Exec("NewRepoContext(git config --global core.quotepath false)", if _, stderr, err := process.Exec("NewRepoContext(git config --global core.quotepath false)",
"git", "config", "--global", "core.quotepath", "false"); err != nil { "git", "config", "--global", "core.quotepath", "false"); err != nil {
log.Fatal(2, "Fail to execute 'git config --global core.quotepath false': %v - %s", err, stderr) log.Fatal("Failed to execute 'git config --global core.quotepath false': %v - %s", err, stderr)
} }
RemoveAllWithNotice("Clean up repository temporary data", filepath.Join(setting.AppDataPath, "tmp")) RemoveAllWithNotice("Clean up repository temporary data", filepath.Join(setting.AppDataPath, "tmp"))
@ -783,7 +783,7 @@ func MigrateRepository(doer, owner *User, opts MigrateRepoOptions) (*Repository,
Quiet: true, Quiet: true,
Timeout: migrateTimeout, Timeout: migrateTimeout,
}); err != nil { }); err != nil {
log.Trace("Fail to clone wiki: %v", err) log.Trace("Failed to clone wiki: %v", err)
RemoveAllWithNotice("Delete repository wiki for initialization failure", wikiPath) RemoveAllWithNotice("Delete repository wiki for initialization failure", wikiPath)
} }
} }
@ -813,7 +813,7 @@ func MigrateRepository(doer, owner *User, opts MigrateRepoOptions) (*Repository,
} }
if err = repo.UpdateSize(); err != nil { if err = repo.UpdateSize(); err != nil {
log.Error(2, "UpdateSize [repo_id: %d]: %v", repo.ID, err) log.Error("UpdateSize [repo_id: %d]: %v", repo.ID, err)
} }
} }
@ -1163,7 +1163,7 @@ func countRepositories(userID int64, private bool) int64 {
count, err := sess.Count(new(Repository)) count, err := sess.Count(new(Repository))
if err != nil { if err != nil {
log.Error(4, "countRepositories: %v", err) log.Error("countRepositories: %v", err)
} }
return count return count
} }
@ -1436,11 +1436,11 @@ func updateRepository(e Engine, repo *Repository, visibilityChanged bool) (err e
daemonExportFile := path.Join(repo.RepoPath(), "git-daemon-export-ok") daemonExportFile := path.Join(repo.RepoPath(), "git-daemon-export-ok")
if repo.IsPrivate && com.IsExist(daemonExportFile) { if repo.IsPrivate && com.IsExist(daemonExportFile) {
if err = os.Remove(daemonExportFile); err != nil { if err = os.Remove(daemonExportFile); err != nil {
log.Error(4, "Failed to remove %s: %v", daemonExportFile, err) log.Error("Failed to remove %s: %v", daemonExportFile, err)
} }
} else if !repo.IsPrivate && !com.IsExist(daemonExportFile) { } else if !repo.IsPrivate && !com.IsExist(daemonExportFile) {
if f, err := os.Create(daemonExportFile); err != nil { if f, err := os.Create(daemonExportFile); err != nil {
log.Error(4, "Failed to create %s: %v", daemonExportFile, err) log.Error("Failed to create %s: %v", daemonExportFile, err)
} else { } else {
f.Close() f.Close()
} }
@ -1592,7 +1592,7 @@ func DeleteRepository(uid, repoID int64) error {
if repo.NumForks > 0 { if repo.NumForks > 0 {
if _, err = x.Exec("UPDATE `repository` SET fork_id=0,is_fork=? WHERE fork_id=?", false, repo.ID); err != nil { if _, err = x.Exec("UPDATE `repository` SET fork_id=0,is_fork=? WHERE fork_id=?", false, repo.ID); err != nil {
log.Error(4, "reset 'fork_id' and 'is_fork': %v", err) log.Error("reset 'fork_id' and 'is_fork': %v", err)
} }
} }
@ -1781,14 +1781,14 @@ func DeleteOldRepositoryArchives() {
dir, err := os.Open(dirPath) dir, err := os.Open(dirPath)
if err != nil { if err != nil {
log.Error(3, "Fail to open directory '%s': %v", dirPath, err) log.Error("Failed to open directory '%s': %v", dirPath, err)
continue continue
} }
fis, err := dir.Readdir(0) fis, err := dir.Readdir(0)
dir.Close() dir.Close()
if err != nil { if err != nil {
log.Error(3, "Fail to read directory '%s': %v", dirPath, err) log.Error("Failed to read directory '%s': %v", dirPath, err)
continue continue
} }
@ -1799,10 +1799,10 @@ func DeleteOldRepositoryArchives() {
archivePath := filepath.Join(dirPath, fi.Name()) archivePath := filepath.Join(dirPath, fi.Name())
if err = os.Remove(archivePath); err != nil { if err = os.Remove(archivePath); err != nil {
desc := fmt.Sprintf("Fail to health delete archive '%s': %v", archivePath, err) desc := fmt.Sprintf("Failed to health delete archive '%s': %v", archivePath, err)
log.Warn(desc) log.Warn(desc)
if err = CreateRepositoryNotice(desc); err != nil { if err = CreateRepositoryNotice(desc); err != nil {
log.Error(3, "CreateRepositoryNotice: %v", err) log.Error("CreateRepositoryNotice: %v", err)
} }
} }
} }
@ -1810,7 +1810,7 @@ func DeleteOldRepositoryArchives() {
return nil return nil
}); err != nil { }); err != nil {
log.Error(2, "DeleteOldRepositoryArchives: %v", err) log.Error("DeleteOldRepositoryArchives: %v", err)
} }
} }
@ -1935,12 +1935,12 @@ func GitFsck() {
desc := fmt.Sprintf("Failed to perform health check on repository '%s': %v", repoPath, err) desc := fmt.Sprintf("Failed to perform health check on repository '%s': %v", repoPath, err)
log.Warn(desc) log.Warn(desc)
if err = CreateRepositoryNotice(desc); err != nil { if err = CreateRepositoryNotice(desc); err != nil {
log.Error(3, "CreateRepositoryNotice: %v", err) log.Error("CreateRepositoryNotice: %v", err)
} }
} }
return nil return nil
}); err != nil { }); err != nil {
log.Error(2, "GitFsck: %v", err) log.Error("GitFsck: %v", err)
} }
} }
@ -1971,7 +1971,7 @@ type repoChecker struct {
func repoStatsCheck(checker *repoChecker) { func repoStatsCheck(checker *repoChecker) {
results, err := x.Query(checker.querySQL) results, err := x.Query(checker.querySQL)
if err != nil { if err != nil {
log.Error(2, "Select %s: %v", checker.desc, err) log.Error("Select %s: %v", checker.desc, err)
return return
} }
for _, result := range results { for _, result := range results {
@ -1979,7 +1979,7 @@ func repoStatsCheck(checker *repoChecker) {
log.Trace("Updating %s: %d", checker.desc, id) log.Trace("Updating %s: %d", checker.desc, id)
_, err = x.Exec(checker.correctSQL, id, id) _, err = x.Exec(checker.correctSQL, id, id)
if err != nil { if err != nil {
log.Error(2, "Update %s[%d]: %v", checker.desc, id, err) log.Error("Update %s[%d]: %v", checker.desc, id, err)
} }
} }
} }
@ -2033,14 +2033,14 @@ func CheckRepoStats() {
desc := "repository count 'num_closed_issues'" desc := "repository count 'num_closed_issues'"
results, err := x.Query("SELECT repo.id FROM `repository` repo WHERE repo.num_closed_issues!=(SELECT COUNT(*) FROM `issue` WHERE repo_id=repo.id AND is_closed=? AND is_pull=?)", true, false) results, err := x.Query("SELECT repo.id FROM `repository` repo WHERE repo.num_closed_issues!=(SELECT COUNT(*) FROM `issue` WHERE repo_id=repo.id AND is_closed=? AND is_pull=?)", true, false)
if err != nil { if err != nil {
log.Error(2, "Select %s: %v", desc, err) log.Error("Select %s: %v", desc, err)
} else { } else {
for _, result := range results { for _, result := range results {
id := com.StrTo(result["id"]).MustInt64() id := com.StrTo(result["id"]).MustInt64()
log.Trace("Updating %s: %d", desc, id) log.Trace("Updating %s: %d", desc, id)
_, err = x.Exec("UPDATE `repository` SET num_closed_issues=(SELECT COUNT(*) FROM `issue` WHERE repo_id=? AND is_closed=? AND is_pull=?) WHERE id=?", id, true, false, id) _, err = x.Exec("UPDATE `repository` SET num_closed_issues=(SELECT COUNT(*) FROM `issue` WHERE repo_id=? AND is_closed=? AND is_pull=?) WHERE id=?", id, true, false, id)
if err != nil { if err != nil {
log.Error(2, "Update %s[%d]: %v", desc, id, err) log.Error("Update %s[%d]: %v", desc, id, err)
} }
} }
} }
@ -2050,7 +2050,7 @@ func CheckRepoStats() {
// ***** START: Repository.NumForks ***** // ***** START: Repository.NumForks *****
results, err = x.Query("SELECT repo.id FROM `repository` repo WHERE repo.num_forks!=(SELECT COUNT(*) FROM `repository` WHERE fork_id=repo.id)") results, err = x.Query("SELECT repo.id FROM `repository` repo WHERE repo.num_forks!=(SELECT COUNT(*) FROM `repository` WHERE fork_id=repo.id)")
if err != nil { if err != nil {
log.Error(2, "Select repository count 'num_forks': %v", err) log.Error("Select repository count 'num_forks': %v", err)
} else { } else {
for _, result := range results { for _, result := range results {
id := com.StrTo(result["id"]).MustInt64() id := com.StrTo(result["id"]).MustInt64()
@ -2058,19 +2058,19 @@ func CheckRepoStats() {
repo, err := GetRepositoryByID(id) repo, err := GetRepositoryByID(id)
if err != nil { if err != nil {
log.Error(2, "GetRepositoryByID[%d]: %v", id, err) log.Error("GetRepositoryByID[%d]: %v", id, err)
continue continue
} }
rawResult, err := x.Query("SELECT COUNT(*) FROM `repository` WHERE fork_id=?", repo.ID) rawResult, err := x.Query("SELECT COUNT(*) FROM `repository` WHERE fork_id=?", repo.ID)
if err != nil { if err != nil {
log.Error(2, "Select count of forks[%d]: %v", repo.ID, err) log.Error("Select count of forks[%d]: %v", repo.ID, err)
continue continue
} }
repo.NumForks = int(parseCountResult(rawResult)) repo.NumForks = int(parseCountResult(rawResult))
if err = UpdateRepository(repo, false); err != nil { if err = UpdateRepository(repo, false); err != nil {
log.Error(2, "UpdateRepository[%d]: %v", id, err) log.Error("UpdateRepository[%d]: %v", id, err)
continue continue
} }
} }
@ -2410,14 +2410,14 @@ func ForkRepository(doer, owner *User, baseRepo *Repository, name, desc string)
} }
if err = repo.UpdateSize(); err != nil { if err = repo.UpdateSize(); err != nil {
log.Error(2, "UpdateSize [repo_id: %d]: %v", repo.ID, err) log.Error("UpdateSize [repo_id: %d]: %v", repo.ID, err)
} }
if err = PrepareWebhooks(baseRepo, HOOK_EVENT_FORK, &api.ForkPayload{ if err = PrepareWebhooks(baseRepo, HOOK_EVENT_FORK, &api.ForkPayload{
Forkee: repo.APIFormat(nil), Forkee: repo.APIFormat(nil),
Repo: baseRepo.APIFormat(nil), Repo: baseRepo.APIFormat(nil),
Sender: doer.APIFormat(), Sender: doer.APIFormat(),
}); err != nil { }); err != nil {
log.Error(2, "PrepareWebhooks [repo_id: %d]: %v", baseRepo.ID, err) log.Error("PrepareWebhooks [repo_id: %d]: %v", baseRepo.ID, err)
} }
return repo, nil return repo, nil
} }

View File

@ -7,7 +7,7 @@ package db
import ( import (
"fmt" "fmt"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
api "github.com/gogs/go-gogs-client" api "github.com/gogs/go-gogs-client"
) )
@ -41,7 +41,7 @@ func IsCollaborator(repoID, userID int64) bool {
} }
has, err := x.Get(collaboration) has, err := x.Get(collaboration)
if err != nil { if err != nil {
log.Error(2, "get collaboration [repo_id: %d, user_id: %d]: %v", repoID, userID, err) log.Error("get collaboration [repo_id: %d, user_id: %d]: %v", repoID, userID, err)
return false return false
} }
return has return has

View File

@ -20,7 +20,7 @@ import (
"github.com/unknwon/com" "github.com/unknwon/com"
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"xorm.io/xorm" "xorm.io/xorm"
"gogs.io/gogs/internal/process" "gogs.io/gogs/internal/process"
@ -341,7 +341,7 @@ func appendAuthorizedKeysToFile(keys ...*PublicKey) error {
// .ssh directory should have mode 700, and authorized_keys file should have mode 600. // .ssh directory should have mode 700, and authorized_keys file should have mode 600.
if fi.Mode().Perm() > 0600 { if fi.Mode().Perm() > 0600 {
log.Error(4, "authorized_keys file has unusual permission flags: %s - setting to -rw-------", fi.Mode().Perm().String()) log.Error("authorized_keys file has unusual permission flags: %s - setting to -rw-------", fi.Mode().Perm().String())
if err = f.Chmod(0600); err != nil { if err = f.Chmod(0600); err != nil {
return err return err
} }

View File

@ -15,7 +15,7 @@ import (
) )
func init() { func init() {
setting.NewContext() setting.Init()
} }
func Test_SSHParsePublicKey(t *testing.T) { func Test_SSHParsePublicKey(t *testing.T) {

View File

@ -12,7 +12,7 @@ import (
"github.com/pquerna/otp/totp" "github.com/pquerna/otp/totp"
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"xorm.io/xorm" "xorm.io/xorm"
"gogs.io/gogs/internal/db/errors" "gogs.io/gogs/internal/db/errors"
@ -58,7 +58,7 @@ func (t *TwoFactor) ValidateTOTP(passcode string) (bool, error) {
func IsUserEnabledTwoFactor(userID int64) bool { func IsUserEnabledTwoFactor(userID int64) bool {
has, err := x.Where("user_id = ?", userID).Get(new(TwoFactor)) has, err := x.Where("user_id = ?", userID).Get(new(TwoFactor))
if err != nil { if err != nil {
log.Error(2, "IsUserEnabledTwoFactor [user_id: %d]: %v", userID, err) log.Error("IsUserEnabledTwoFactor [user_id: %d]: %v", userID, err)
} }
return has return has
} }

View File

@ -67,7 +67,7 @@ func PushUpdate(opts PushUpdateOptions) (err error) {
gitUpdate := exec.Command("git", "update-server-info") gitUpdate := exec.Command("git", "update-server-info")
gitUpdate.Dir = repoPath gitUpdate.Dir = repoPath
if err = gitUpdate.Run(); err != nil { if err = gitUpdate.Run(); err != nil {
return fmt.Errorf("Fail to call 'git update-server-info': %v", err) return fmt.Errorf("run 'git update-server-info': %v", err)
} }
gitRepo, err := git.OpenRepository(repoPath) gitRepo, err := git.OpenRepository(repoPath)

View File

@ -23,7 +23,7 @@ import (
"github.com/nfnt/resize" "github.com/nfnt/resize"
"github.com/unknwon/com" "github.com/unknwon/com"
"golang.org/x/crypto/pbkdf2" "golang.org/x/crypto/pbkdf2"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"xorm.io/xorm" "xorm.io/xorm"
"github.com/gogs/git-module" "github.com/gogs/git-module"
@ -265,7 +265,7 @@ func (u *User) RelAvatarLink() string {
case setting.DisableGravatar, setting.OfflineMode: case setting.DisableGravatar, setting.OfflineMode:
if !com.IsExist(u.CustomAvatarPath()) { if !com.IsExist(u.CustomAvatarPath()) {
if err := u.GenerateRandomAvatar(); err != nil { if err := u.GenerateRandomAvatar(); err != nil {
log.Error(3, "GenerateRandomAvatar: %v", err) log.Error("GenerateRandomAvatar: %v", err)
} }
} }
@ -371,7 +371,7 @@ func (u *User) DeleteAvatar() error {
func (u *User) IsAdminOfRepo(repo *Repository) bool { func (u *User) IsAdminOfRepo(repo *Repository) bool {
has, err := HasAccess(u.ID, repo, ACCESS_MODE_ADMIN) has, err := HasAccess(u.ID, repo, ACCESS_MODE_ADMIN)
if err != nil { if err != nil {
log.Error(2, "HasAccess: %v", err) log.Error("HasAccess: %v", err)
} }
return has return has
} }
@ -380,7 +380,7 @@ func (u *User) IsAdminOfRepo(repo *Repository) bool {
func (u *User) IsWriterOfRepo(repo *Repository) bool { func (u *User) IsWriterOfRepo(repo *Repository) bool {
has, err := HasAccess(u.ID, repo, ACCESS_MODE_WRITE) has, err := HasAccess(u.ID, repo, ACCESS_MODE_WRITE)
if err != nil { if err != nil {
log.Error(2, "HasAccess: %v", err) log.Error("HasAccess: %v", err)
} }
return has return has
} }
@ -608,7 +608,7 @@ func parseUserFromCode(code string) (user *User) {
if user, err = GetUserByName(string(b)); user != nil { if user, err = GetUserByName(string(b)); user != nil {
return user return user
} else if !errors.IsUserNotExist(err) { } else if !errors.IsUserNotExist(err) {
log.Error(2, "GetUserByName: %v", err) log.Error("GetUserByName: %v", err)
} }
} }

View File

@ -16,7 +16,7 @@ import (
"github.com/json-iterator/go" "github.com/json-iterator/go"
gouuid "github.com/satori/go.uuid" gouuid "github.com/satori/go.uuid"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"xorm.io/xorm" "xorm.io/xorm"
api "github.com/gogs/go-gogs-client" api "github.com/gogs/go-gogs-client"
@ -127,7 +127,7 @@ func (w *Webhook) AfterSet(colName string, _ xorm.Cell) {
case "events": case "events":
w.HookEvent = &HookEvent{} w.HookEvent = &HookEvent{}
if err = jsoniter.Unmarshal([]byte(w.Events), w.HookEvent); err != nil { if err = jsoniter.Unmarshal([]byte(w.Events), w.HookEvent); err != nil {
log.Error(3, "Unmarshal [%d]: %v", w.ID, err) log.Error("Unmarshal [%d]: %v", w.ID, err)
} }
case "created_unix": case "created_unix":
w.Created = time.Unix(w.CreatedUnix, 0).Local() w.Created = time.Unix(w.CreatedUnix, 0).Local()
@ -139,7 +139,7 @@ func (w *Webhook) AfterSet(colName string, _ xorm.Cell) {
func (w *Webhook) GetSlackHook() *SlackMeta { func (w *Webhook) GetSlackHook() *SlackMeta {
s := &SlackMeta{} s := &SlackMeta{}
if err := jsoniter.Unmarshal([]byte(w.Meta), s); err != nil { if err := jsoniter.Unmarshal([]byte(w.Meta), s); err != nil {
log.Error(2, "GetSlackHook [%d]: %v", w.ID, err) log.Error("GetSlackHook [%d]: %v", w.ID, err)
} }
return s return s
} }
@ -457,7 +457,7 @@ func (t *HookTask) AfterSet(colName string, _ xorm.Cell) {
t.RequestInfo = &HookRequest{} t.RequestInfo = &HookRequest{}
if err = jsoniter.Unmarshal([]byte(t.RequestContent), t.RequestInfo); err != nil { if err = jsoniter.Unmarshal([]byte(t.RequestContent), t.RequestInfo); err != nil {
log.Error(3, "Unmarshal[%d]: %v", t.ID, err) log.Error("Unmarshal[%d]: %v", t.ID, err)
} }
case "response_content": case "response_content":
@ -467,7 +467,7 @@ func (t *HookTask) AfterSet(colName string, _ xorm.Cell) {
t.ResponseInfo = &HookResponse{} t.ResponseInfo = &HookResponse{}
if err = jsoniter.Unmarshal([]byte(t.ResponseContent), t.ResponseInfo); err != nil { if err = jsoniter.Unmarshal([]byte(t.ResponseContent), t.ResponseInfo); err != nil {
log.Error(3, "Unmarshal [%d]: %v", t.ID, err) log.Error("Unmarshal [%d]: %v", t.ID, err)
} }
} }
} }
@ -475,7 +475,7 @@ func (t *HookTask) AfterSet(colName string, _ xorm.Cell) {
func (t *HookTask) MarshalJSON(v interface{}) string { func (t *HookTask) MarshalJSON(v interface{}) string {
p, err := jsoniter.Marshal(v) p, err := jsoniter.Marshal(v)
if err != nil { if err != nil {
log.Error(3, "Marshal [%d]: %v", t.ID, err) log.Error("Marshal [%d]: %v", t.ID, err)
} }
return string(p) return string(p)
} }
@ -588,7 +588,7 @@ func prepareHookTasks(e Engine, repo *Repository, event HookEventType, p api.Pay
if len(w.Secret) > 0 { if len(w.Secret) > 0 {
data, err := payloader.JSONPayload() data, err := payloader.JSONPayload()
if err != nil { if err != nil {
log.Error(2, "prepareWebhooks.JSONPayload: %v", err) log.Error("prepareWebhooks.JSONPayload: %v", err)
} }
sig := hmac.New(sha256.New, []byte(w.Secret)) sig := hmac.New(sha256.New, []byte(w.Secret))
sig.Write(data) sig.Write(data)
@ -691,7 +691,7 @@ func (t *HookTask) deliver() {
// Update webhook last delivery status. // Update webhook last delivery status.
w, err := GetWebhookByID(t.HookID) w, err := GetWebhookByID(t.HookID)
if err != nil { if err != nil {
log.Error(3, "GetWebhookByID: %v", err) log.Error("GetWebhookByID: %v", err)
return return
} }
if t.IsSucceed { if t.IsSucceed {
@ -700,7 +700,7 @@ func (t *HookTask) deliver() {
w.LastStatus = HOOK_STATUS_FAILED w.LastStatus = HOOK_STATUS_FAILED
} }
if err = UpdateWebhook(w); err != nil { if err = UpdateWebhook(w); err != nil {
log.Error(3, "UpdateWebhook: %v", err) log.Error("UpdateWebhook: %v", err)
return return
} }
}() }()
@ -742,7 +742,7 @@ func DeliverHooks() {
// Update hook task status. // Update hook task status.
for _, t := range tasks { for _, t := range tasks {
if err := UpdateHookTask(t); err != nil { if err := UpdateHookTask(t); err != nil {
log.Error(4, "UpdateHookTask [%d]: %v", t.ID, err) log.Error("UpdateHookTask [%d]: %v", t.ID, err)
} }
} }
@ -753,13 +753,13 @@ func DeliverHooks() {
tasks = make([]*HookTask, 0, 5) tasks = make([]*HookTask, 0, 5)
if err := x.Where("repo_id = ?", repoID).And("is_delivered = ?", false).Find(&tasks); err != nil { if err := x.Where("repo_id = ?", repoID).And("is_delivered = ?", false).Find(&tasks); err != nil {
log.Error(4, "Get repository [%s] hook tasks: %v", repoID, err) log.Error("Get repository [%s] hook tasks: %v", repoID, err)
continue continue
} }
for _, t := range tasks { for _, t := range tasks {
t.deliver() t.deliver()
if err := UpdateHookTask(t); err != nil { if err := UpdateHookTask(t); err != nil {
log.Error(4, "UpdateHookTask [%d]: %v", t.ID, err) log.Error("UpdateHookTask [%d]: %v", t.ID, err)
continue continue
} }
} }

View File

@ -11,9 +11,9 @@ import (
"sync" "sync"
"time" "time"
log "gopkg.in/clog.v1"
"gopkg.in/gomail.v2" "gopkg.in/gomail.v2"
"gopkg.in/macaron.v1" "gopkg.in/macaron.v1"
log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/assets/templates" "gogs.io/gogs/internal/assets/templates"
"gogs.io/gogs/internal/markup" "gogs.io/gogs/internal/markup"
@ -111,7 +111,7 @@ func SendUserMail(c *macaron.Context, u User, tpl, code, subject, info string) {
} }
body, err := render(tpl, data) body, err := render(tpl, data)
if err != nil { if err != nil {
log.Error(2, "render: %v", err) log.Error("render: %v", err)
return return
} }
@ -139,7 +139,7 @@ func SendActivateEmailMail(c *macaron.Context, u User, email string) {
} }
body, err := render(MAIL_AUTH_ACTIVATE_EMAIL, data) body, err := render(MAIL_AUTH_ACTIVATE_EMAIL, data)
if err != nil { if err != nil {
log.Error(3, "HTMLString: %v", err) log.Error("HTMLString: %v", err)
return return
} }
@ -156,7 +156,7 @@ func SendRegisterNotifyMail(c *macaron.Context, u User) {
} }
body, err := render(MAIL_AUTH_REGISTER_NOTIFY, data) body, err := render(MAIL_AUTH_REGISTER_NOTIFY, data)
if err != nil { if err != nil {
log.Error(3, "HTMLString: %v", err) log.Error("HTMLString: %v", err)
return return
} }
@ -177,7 +177,7 @@ func SendCollaboratorMail(u, doer User, repo Repository) {
} }
body, err := render(MAIL_NOTIFY_COLLABORATOR, data) body, err := render(MAIL_NOTIFY_COLLABORATOR, data)
if err != nil { if err != nil {
log.Error(3, "HTMLString: %v", err) log.Error("HTMLString: %v", err)
return return
} }
@ -202,7 +202,7 @@ func composeIssueMessage(issue Issue, repo Repository, doer User, tplName string
data["Doer"] = doer data["Doer"] = doer
content, err := render(tplName, data) content, err := render(tplName, data)
if err != nil { if err != nil {
log.Error(3, "HTMLString (%s): %v", tplName, err) log.Error("HTMLString (%s): %v", tplName, err)
} }
from := gomail.NewMessage().FormatAddress(setting.MailService.FromEmail, doer.DisplayName()) from := gomail.NewMessage().FormatAddress(setting.MailService.FromEmail, doer.DisplayName())
msg := NewMessageFrom(tos, from, subject, content) msg := NewMessageFrom(tos, from, subject, content)

View File

@ -15,8 +15,8 @@ import (
"time" "time"
"github.com/jaytaylor/html2text" "github.com/jaytaylor/html2text"
log "gopkg.in/clog.v1"
"gopkg.in/gomail.v2" "gopkg.in/gomail.v2"
log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/setting" "gogs.io/gogs/internal/setting"
) )
@ -43,7 +43,7 @@ func NewMessageFrom(to []string, from, subject, htmlBody string) *Message {
if setting.MailService.UsePlainText || setting.MailService.AddPlainTextAlt { if setting.MailService.UsePlainText || setting.MailService.AddPlainTextAlt {
plainBody, err := html2text.FromString(htmlBody) plainBody, err := html2text.FromString(htmlBody)
if err != nil { if err != nil {
log.Error(2, "html2text.FromString: %v", err) log.Error("html2text.FromString: %v", err)
} else { } else {
contentType = "text/plain" contentType = "text/plain"
body = plainBody body = plainBody
@ -209,7 +209,7 @@ func processMailQueue() {
case msg := <-mailQueue: case msg := <-mailQueue:
log.Trace("New e-mail sending request %s: %s", msg.GetHeader("To"), msg.Info) log.Trace("New e-mail sending request %s: %s", msg.GetHeader("To"), msg.Info)
if err := gomail.Send(sender, msg.Message); err != nil { if err := gomail.Send(sender, msg.Message); err != nil {
log.Error(3, "Fail to send emails %s: %s - %v", msg.GetHeader("To"), msg.Info, err) log.Error("Failed to send emails %s: %s - %v", msg.GetHeader("To"), msg.Info, err)
} else { } else {
log.Trace("E-mails sent %s: %s", msg.GetHeader("To"), msg.Info) log.Trace("E-mails sent %s: %s", msg.GetHeader("To"), msg.Info)
} }

View File

@ -12,11 +12,11 @@ import (
"sync" "sync"
"time" "time"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
) )
var ( var (
ErrExecTimeout = errors.New("Process execution timeout") ErrExecTimeout = errors.New("process execution timeout")
) )
const DEFAULT_TIMEOUT = 60 * time.Second const DEFAULT_TIMEOUT = 60 * time.Second
@ -101,7 +101,7 @@ func ExecDir(timeout time.Duration, dir, desc, cmdName string, args ...string) (
select { select {
case <-time.After(timeout): case <-time.After(timeout):
if errKill := Kill(pid); errKill != nil { if errKill := Kill(pid); errKill != nil {
log.Error(2, "Fail to kill timeout process [pid: %d, desc: %s]: %v", pid, desc, errKill) log.Error("Failed to kill timeout process [pid: %d, desc: %s]: %v", pid, desc, errKill)
} }
<-done <-done
return "", ErrExecTimeout.Error(), ErrExecTimeout return "", ErrExecTimeout.Error(), ErrExecTimeout

View File

@ -10,7 +10,7 @@ import (
"strings" "strings"
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"xorm.io/core" "xorm.io/core"
"gogs.io/gogs/internal/auth/ldap" "gogs.io/gogs/internal/auth/ldap"

View File

@ -7,7 +7,7 @@ package admin
import ( import (
"github.com/unknwon/com" "github.com/unknwon/com"
"github.com/unknwon/paginater" "github.com/unknwon/paginater"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/context" "gogs.io/gogs/internal/context"
"gogs.io/gogs/internal/db" "gogs.io/gogs/internal/db"

View File

@ -6,7 +6,7 @@ package admin
import ( import (
"github.com/unknwon/paginater" "github.com/unknwon/paginater"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/context" "gogs.io/gogs/internal/context"
"gogs.io/gogs/internal/db" "gogs.io/gogs/internal/db"

View File

@ -8,7 +8,7 @@ import (
"strings" "strings"
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/context" "gogs.io/gogs/internal/context"
"gogs.io/gogs/internal/db" "gogs.io/gogs/internal/db"

View File

@ -5,10 +5,9 @@
package admin package admin
import ( import (
user2 "gogs.io/gogs/internal/route/api/v1/user"
"net/http" "net/http"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
api "github.com/gogs/go-gogs-client" api "github.com/gogs/go-gogs-client"
@ -16,6 +15,7 @@ import (
"gogs.io/gogs/internal/db" "gogs.io/gogs/internal/db"
"gogs.io/gogs/internal/db/errors" "gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/internal/mailer" "gogs.io/gogs/internal/mailer"
"gogs.io/gogs/internal/route/api/v1/user"
"gogs.io/gogs/internal/setting" "gogs.io/gogs/internal/setting"
) )
@ -76,7 +76,7 @@ func CreateUser(c *context.APIContext, form api.CreateUserOption) {
} }
func EditUser(c *context.APIContext, form api.EditUserOption) { func EditUser(c *context.APIContext, form api.EditUserOption) {
u := user2.GetUserByParams(c) u := user.GetUserByParams(c)
if c.Written() { if c.Written() {
return return
} }
@ -131,7 +131,7 @@ func EditUser(c *context.APIContext, form api.EditUserOption) {
} }
func DeleteUser(c *context.APIContext) { func DeleteUser(c *context.APIContext) {
u := user2.GetUserByParams(c) u := user.GetUserByParams(c)
if c.Written() { if c.Written() {
return return
} }
@ -151,9 +151,9 @@ func DeleteUser(c *context.APIContext) {
} }
func CreatePublicKey(c *context.APIContext, form api.CreateKeyOption) { func CreatePublicKey(c *context.APIContext, form api.CreateKeyOption) {
u := user2.GetUserByParams(c) u := user.GetUserByParams(c)
if c.Written() { if c.Written() {
return return
} }
user2.CreateUserPublicKey(c, form, u.ID) user.CreateUserPublicKey(c, form, u.ID)
} }

View File

@ -6,11 +6,10 @@ package repo
import ( import (
"fmt" "fmt"
convert2 "gogs.io/gogs/internal/route/api/v1/convert"
"net/http" "net/http"
"path" "path"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
api "github.com/gogs/go-gogs-client" api "github.com/gogs/go-gogs-client"
@ -18,6 +17,7 @@ import (
"gogs.io/gogs/internal/db" "gogs.io/gogs/internal/db"
"gogs.io/gogs/internal/db/errors" "gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/internal/form" "gogs.io/gogs/internal/form"
"gogs.io/gogs/internal/route/api/v1/convert"
"gogs.io/gogs/internal/setting" "gogs.io/gogs/internal/setting"
) )
@ -25,7 +25,7 @@ func Search(c *context.APIContext) {
opts := &db.SearchRepoOptions{ opts := &db.SearchRepoOptions{
Keyword: path.Base(c.Query("q")), Keyword: path.Base(c.Query("q")),
OwnerID: c.QueryInt64("uid"), OwnerID: c.QueryInt64("uid"),
PageSize: convert2.ToCorrectPageSize(c.QueryInt("limit")), PageSize: convert.ToCorrectPageSize(c.QueryInt("limit")),
Page: c.QueryInt("page"), Page: c.QueryInt("page"),
} }
@ -173,7 +173,7 @@ func CreateUserRepo(c *context.APIContext, owner *db.User, opt api.CreateRepoOpt
} else { } else {
if repo != nil { if repo != nil {
if err = db.DeleteRepository(c.User.ID, repo.ID); err != nil { if err = db.DeleteRepository(c.User.ID, repo.ID); err != nil {
log.Error(2, "DeleteRepository: %v", err) log.Error("DeleteRepository: %v", err)
} }
} }
c.ServerError("CreateRepository", err) c.ServerError("CreateRepository", err)
@ -270,7 +270,7 @@ func Migrate(c *context.APIContext, f form.MigrateRepo) {
if err != nil { if err != nil {
if repo != nil { if repo != nil {
if errDelete := db.DeleteRepository(ctxUser.ID, repo.ID); errDelete != nil { if errDelete := db.DeleteRepository(ctxUser.ID, repo.ID); errDelete != nil {
log.Error(2, "DeleteRepository: %v", errDelete) log.Error("DeleteRepository: %v", errDelete)
} }
} }

View File

@ -12,9 +12,9 @@ import (
"strings" "strings"
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1"
"gopkg.in/ini.v1" "gopkg.in/ini.v1"
"gopkg.in/macaron.v1" "gopkg.in/macaron.v1"
log "unknwon.dev/clog/v2"
"xorm.io/xorm" "xorm.io/xorm"
"github.com/gogs/git-module" "github.com/gogs/git-module"
@ -46,24 +46,25 @@ func checkRunMode() {
log.Info("Run mode: %s", strings.Title(macaron.Env)) log.Info("Run mode: %s", strings.Title(macaron.Env))
} }
func NewServices() {
setting.NewServices()
mailer.NewContext()
}
// GlobalInit is for global configuration reload-able. // GlobalInit is for global configuration reload-able.
func GlobalInit() { func GlobalInit() {
setting.NewContext() setting.Init()
setting.InitLogging()
log.Info("%s %s", setting.AppName, setting.AppVersion)
log.Trace("Custom path: %s", setting.CustomPath) log.Trace("Custom path: %s", setting.CustomPath)
log.Trace("Log path: %s", setting.LogRootPath) log.Trace("Log path: %s", setting.LogRootPath)
log.Trace("Build time: %s", setting.BuildTime)
log.Trace("Build commit: %s", setting.BuildCommit)
db.LoadConfigs() db.LoadConfigs()
NewServices() setting.NewServices()
mailer.NewContext()
if setting.InstallLock { if setting.InstallLock {
highlight.NewContext() highlight.NewContext()
markup.NewSanitizer() markup.NewSanitizer()
if err := db.NewEngine(); err != nil { if err := db.NewEngine(); err != nil {
log.Fatal(2, "Fail to initialize ORM engine: %v", err) log.Fatal("Failed to initialize ORM engine: %v", err)
} }
db.HasEngine = true db.HasEngine = true
@ -302,7 +303,7 @@ func InstallPost(c *context.Context, f form.Install) {
if com.IsFile(setting.CustomConf) { if com.IsFile(setting.CustomConf) {
// Keeps custom settings if there is already something. // Keeps custom settings if there is already something.
if err := cfg.Append(setting.CustomConf); err != nil { if err := cfg.Append(setting.CustomConf); err != nil {
log.Error(2, "Fail to load custom conf '%s': %v", setting.CustomConf, err) log.Error("Failed to load custom conf '%s': %v", setting.CustomConf, err)
} }
} }
cfg.Section("database").Key("DB_TYPE").SetValue(db.DbCfg.Type) cfg.Section("database").Key("DB_TYPE").SetValue(db.DbCfg.Type)

View File

@ -6,7 +6,7 @@ package org
import ( import (
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/context" "gogs.io/gogs/internal/context"
"gogs.io/gogs/internal/db" "gogs.io/gogs/internal/db"
@ -76,7 +76,7 @@ func MembersAction(c *context.Context) {
} }
if err != nil { if err != nil {
log.Error(4, "Action(%s): %v", c.Params(":action"), err) log.Error("Action(%s): %v", c.Params(":action"), err)
c.JSON(200, map[string]interface{}{ c.JSON(200, map[string]interface{}{
"ok": false, "ok": false,
"err": err.Error(), "err": err.Error(),

View File

@ -5,7 +5,7 @@
package org package org
import ( import (
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/context" "gogs.io/gogs/internal/context"
"gogs.io/gogs/internal/db" "gogs.io/gogs/internal/db"

View File

@ -5,15 +5,15 @@
package org package org
import ( import (
user2 "gogs.io/gogs/internal/route/user"
"strings" "strings"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/context" "gogs.io/gogs/internal/context"
"gogs.io/gogs/internal/db" "gogs.io/gogs/internal/db"
"gogs.io/gogs/internal/db/errors" "gogs.io/gogs/internal/db/errors"
"gogs.io/gogs/internal/form" "gogs.io/gogs/internal/form"
"gogs.io/gogs/internal/route/user"
"gogs.io/gogs/internal/setting" "gogs.io/gogs/internal/setting"
) )
@ -89,7 +89,7 @@ func SettingsPost(c *context.Context, f form.UpdateOrgSetting) {
func SettingsAvatar(c *context.Context, f form.Avatar) { func SettingsAvatar(c *context.Context, f form.Avatar) {
f.Source = form.AVATAR_LOCAL f.Source = form.AVATAR_LOCAL
if err := user2.UpdateAvatarSetting(c, f, c.Org.Organization); err != nil { if err := user.UpdateAvatarSetting(c, f, c.Org.Organization); err != nil {
c.Flash.Error(err.Error()) c.Flash.Error(err.Error())
} else { } else {
c.Flash.Success(c.Tr("org.settings.update_avatar_success")) c.Flash.Success(c.Tr("org.settings.update_avatar_success"))

View File

@ -8,7 +8,7 @@ import (
"path" "path"
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/context" "gogs.io/gogs/internal/context"
"gogs.io/gogs/internal/db" "gogs.io/gogs/internal/db"
@ -90,7 +90,7 @@ func TeamsAction(c *context.Context) {
if db.IsErrLastOrgOwner(err) { if db.IsErrLastOrgOwner(err) {
c.Flash.Error(c.Tr("form.last_org_owner")) c.Flash.Error(c.Tr("form.last_org_owner"))
} else { } else {
log.Error(3, "Action(%s): %v", c.Params(":action"), err) log.Error("Action(%s): %v", c.Params(":action"), err)
c.JSON(200, map[string]interface{}{ c.JSON(200, map[string]interface{}{
"ok": false, "ok": false,
"err": err.Error(), "err": err.Error(),
@ -134,7 +134,7 @@ func TeamsRepoAction(c *context.Context) {
} }
if err != nil { if err != nil {
log.Error(3, "Action(%s): '%s' %v", c.Params(":action"), c.Org.Team.Name, err) log.Error("Action(%s): '%s' %v", c.Params(":action"), c.Org.Team.Name, err)
c.Handle(500, "TeamsRepoAction", err) c.Handle(500, "TeamsRepoAction", err)
return return
} }

View File

@ -7,7 +7,7 @@ package repo
import ( import (
"time" "time"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"github.com/gogs/git-module" "github.com/gogs/git-module"
api "github.com/gogs/go-gogs-client" api "github.com/gogs/go-gogs-client"
@ -125,7 +125,7 @@ func DeleteBranchPost(c *context.Context) {
if len(commitID) > 0 { if len(commitID) > 0 {
branchCommitID, err := c.Repo.GitRepo.GetBranchCommitID(branchName) branchCommitID, err := c.Repo.GitRepo.GetBranchCommitID(branchName)
if err != nil { if err != nil {
log.Error(2, "Failed to get commit ID of branch %q: %v", branchName, err) log.Error("Failed to get commit ID of branch %q: %v", branchName, err)
return return
} }
@ -138,7 +138,7 @@ func DeleteBranchPost(c *context.Context) {
if err := c.Repo.GitRepo.DeleteBranch(branchName, git.DeleteBranchOptions{ if err := c.Repo.GitRepo.DeleteBranch(branchName, git.DeleteBranchOptions{
Force: true, Force: true,
}); err != nil { }); err != nil {
log.Error(2, "Failed to delete branch %q: %v", branchName, err) log.Error("Failed to delete branch %q: %v", branchName, err)
return return
} }
@ -149,7 +149,7 @@ func DeleteBranchPost(c *context.Context) {
Repo: c.Repo.Repository.APIFormat(nil), Repo: c.Repo.Repository.APIFormat(nil),
Sender: c.User.APIFormat(), Sender: c.User.APIFormat(),
}); err != nil { }); err != nil {
log.Error(2, "Failed to prepare webhooks for %q: %v", db.HOOK_EVENT_DELETE, err) log.Error("Failed to prepare webhooks for %q: %v", db.HOOK_EVENT_DELETE, err)
return return
} }
} }

View File

@ -11,7 +11,7 @@ import (
"path" "path"
"strings" "strings"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"github.com/gogs/git-module" "github.com/gogs/git-module"
"gogs.io/gogs/internal/context" "gogs.io/gogs/internal/context"
@ -91,7 +91,7 @@ func editFile(c *context.Context, isNewFile bool) {
buf = append(buf, d...) buf = append(buf, d...)
if err, content := template.ToUTF8WithErr(buf); err != nil { if err, content := template.ToUTF8WithErr(buf); err != nil {
if err != nil { if err != nil {
log.Error(2, "Failed to convert encoding to UTF-8: %v", err) log.Error("Failed to convert encoding to UTF-8: %v", err)
} }
c.Data["FileContent"] = string(buf) c.Data["FileContent"] = string(buf)
} else { } else {
@ -278,7 +278,7 @@ func editFilePost(c *context.Context, f form.EditRepoFile, isNewFile bool) {
Content: strings.Replace(f.Content, "\r", "", -1), Content: strings.Replace(f.Content, "\r", "", -1),
IsNewFile: isNewFile, IsNewFile: isNewFile,
}); err != nil { }); err != nil {
log.Error(2, "Failed to update repo file: %v", err) log.Error("Failed to update repo file: %v", err)
c.FormErr("TreePath") c.FormErr("TreePath")
c.RenderWithErr(c.Tr("repo.editor.fail_to_update_file", f.TreePath, errors.InternalServerError), EDIT_FILE, &f) c.RenderWithErr(c.Tr("repo.editor.fail_to_update_file", f.TreePath, errors.InternalServerError), EDIT_FILE, &f)
return return
@ -385,7 +385,7 @@ func DeleteFilePost(c *context.Context, f form.DeleteRepoFile) {
TreePath: c.Repo.TreePath, TreePath: c.Repo.TreePath,
Message: message, Message: message,
}); err != nil { }); err != nil {
log.Error(2, "Failed to delete repo file: %v", err) log.Error("Failed to delete repo file: %v", err)
c.RenderWithErr(c.Tr("repo.editor.fail_to_delete_file", c.Repo.TreePath, errors.InternalServerError), DELETE_FILE, &f) c.RenderWithErr(c.Tr("repo.editor.fail_to_delete_file", c.Repo.TreePath, errors.InternalServerError), DELETE_FILE, &f)
return return
} }
@ -505,7 +505,7 @@ func UploadFilePost(c *context.Context, f form.UploadRepoFile) {
Message: message, Message: message,
Files: f.Files, Files: f.Files,
}); err != nil { }); err != nil {
log.Error(2, "Failed to upload files: %v", err) log.Error("Failed to upload files: %v", err)
c.FormErr("TreePath") c.FormErr("TreePath")
c.RenderWithErr(c.Tr("repo.editor.unable_to_upload_files", f.TreePath, errors.InternalServerError), UPLOAD_FILE, &f) c.RenderWithErr(c.Tr("repo.editor.unable_to_upload_files", f.TreePath, errors.InternalServerError), UPLOAD_FILE, &f)
return return

View File

@ -16,8 +16,8 @@ import (
"strings" "strings"
"time" "time"
log "gopkg.in/clog.v1"
"gopkg.in/macaron.v1" "gopkg.in/macaron.v1"
log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/context" "gogs.io/gogs/internal/context"
"gogs.io/gogs/internal/db" "gogs.io/gogs/internal/db"
@ -235,7 +235,7 @@ func serviceRPC(h serviceHandler, service string) {
if h.r.Header.Get("Content-Encoding") == "gzip" { if h.r.Header.Get("Content-Encoding") == "gzip" {
reqBody, err = gzip.NewReader(reqBody) reqBody, err = gzip.NewReader(reqBody)
if err != nil { if err != nil {
log.Error(2, "HTTP.Get: fail to create gzip reader: %v", err) log.Error("HTTP.Get: fail to create gzip reader: %v", err)
h.w.WriteHeader(http.StatusInternalServerError) h.w.WriteHeader(http.StatusInternalServerError)
return return
} }
@ -258,7 +258,7 @@ func serviceRPC(h serviceHandler, service string) {
cmd.Stderr = &stderr cmd.Stderr = &stderr
cmd.Stdin = reqBody cmd.Stdin = reqBody
if err = cmd.Run(); err != nil { if err = cmd.Run(); err != nil {
log.Error(2, "HTTP.serviceRPC: fail to serve RPC '%s': %v - %s", service, err, stderr.String()) log.Error("HTTP.serviceRPC: fail to serve RPC '%s': %v - %s", service, err, stderr.String())
h.w.WriteHeader(http.StatusInternalServerError) h.w.WriteHeader(http.StatusInternalServerError)
return return
} }
@ -286,7 +286,7 @@ func gitCommand(dir string, args ...string) []byte {
cmd.Dir = dir cmd.Dir = dir
out, err := cmd.Output() out, err := cmd.Output()
if err != nil { if err != nil {
log.Error(2, fmt.Sprintf("Git: %v - %s", err, out)) log.Error(fmt.Sprintf("Git: %v - %s", err, out))
} }
return out return out
} }

View File

@ -15,7 +15,7 @@ import (
"github.com/unknwon/com" "github.com/unknwon/com"
"github.com/unknwon/paginater" "github.com/unknwon/paginater"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/context" "gogs.io/gogs/internal/context"
"gogs.io/gogs/internal/db" "gogs.io/gogs/internal/db"
@ -891,7 +891,7 @@ func NewComment(c *context.Context, f form.CreateComment) {
c.Flash.Info(c.Tr("repo.pulls.open_unmerged_pull_exists", pr.Index)) c.Flash.Info(c.Tr("repo.pulls.open_unmerged_pull_exists", pr.Index))
} else { } else {
if err = issue.ChangeStatus(c.User, c.Repo.Repository, f.Status == "close"); err != nil { if err = issue.ChangeStatus(c.User, c.Repo.Repository, f.Status == "close"); err != nil {
log.Error(2, "ChangeStatus: %v", err) log.Error("ChangeStatus: %v", err)
} else { } else {
log.Trace("Issue [%d] status changed to closed: %v", issue.ID, issue.IsClosed) log.Trace("Issue [%d] status changed to closed: %v", issue.ID, issue.IsClosed)
} }

View File

@ -10,7 +10,7 @@ import (
"strings" "strings"
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"github.com/gogs/git-module" "github.com/gogs/git-module"
@ -28,7 +28,7 @@ const (
PULL_COMMITS = "repo/pulls/commits" PULL_COMMITS = "repo/pulls/commits"
PULL_FILES = "repo/pulls/files" PULL_FILES = "repo/pulls/files"
PULL_REQUEST_TEMPLATE_KEY = "PullRequestTemplate" PULL_REQUEST_TEMPLATE_KEY = "PullRequestTemplate"
PULL_REQUEST_TITLE_TEMPLATE_KEY = "PullRequestTitleTemplate" PULL_REQUEST_TITLE_TEMPLATE_KEY = "PullRequestTitleTemplate"
) )
@ -648,7 +648,7 @@ func CompareAndPullRequest(c *context.Context) {
if c.Data[PULL_REQUEST_TITLE_TEMPLATE_KEY] != nil { if c.Data[PULL_REQUEST_TITLE_TEMPLATE_KEY] != nil {
customTitle := c.Data[PULL_REQUEST_TITLE_TEMPLATE_KEY].(string) customTitle := c.Data[PULL_REQUEST_TITLE_TEMPLATE_KEY].(string)
r := strings.NewReplacer("{{headBranch}}", headBranch,"{{baseBranch}}", baseBranch) r := strings.NewReplacer("{{headBranch}}", headBranch, "{{baseBranch}}", baseBranch)
c.Data["title"] = r.Replace(customTitle) c.Data["title"] = r.Replace(customTitle)
} }

View File

@ -8,7 +8,7 @@ import (
"fmt" "fmt"
"strings" "strings"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/context" "gogs.io/gogs/internal/context"
"gogs.io/gogs/internal/db" "gogs.io/gogs/internal/db"

View File

@ -11,7 +11,7 @@ import (
"strings" "strings"
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"github.com/gogs/git-module" "github.com/gogs/git-module"
@ -139,7 +139,7 @@ func CreatePost(c *context.Context, f form.CreateRepo) {
if repo != nil { if repo != nil {
if errDelete := db.DeleteRepository(ctxUser.ID, repo.ID); errDelete != nil { if errDelete := db.DeleteRepository(ctxUser.ID, repo.ID); errDelete != nil {
log.Error(4, "DeleteRepository: %v", errDelete) log.Error("DeleteRepository: %v", errDelete)
} }
} }
@ -211,7 +211,7 @@ func MigratePost(c *context.Context, f form.MigrateRepo) {
if repo != nil { if repo != nil {
if errDelete := db.DeleteRepository(ctxUser.ID, repo.ID); errDelete != nil { if errDelete := db.DeleteRepository(ctxUser.ID, repo.ID); errDelete != nil {
log.Error(4, "DeleteRepository: %v", errDelete) log.Error("DeleteRepository: %v", errDelete)
} }
} }

View File

@ -12,7 +12,7 @@ import (
"github.com/gogs/git-module" "github.com/gogs/git-module"
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/context" "gogs.io/gogs/internal/context"
"gogs.io/gogs/internal/db" "gogs.io/gogs/internal/db"
@ -100,7 +100,7 @@ func SettingsPost(c *context.Context, f form.RepoSetting) {
if isNameChanged { if isNameChanged {
if err := db.RenameRepoAction(c.User, oldRepoName, repo); err != nil { if err := db.RenameRepoAction(c.User, oldRepoName, repo); err != nil {
log.Error(2, "RenameRepoAction: %v", err) log.Error("RenameRepoAction: %v", err)
} }
} }
@ -410,7 +410,7 @@ func ChangeCollaborationAccessMode(c *context.Context) {
if err := c.Repo.Repository.ChangeCollaborationAccessMode( if err := c.Repo.Repository.ChangeCollaborationAccessMode(
c.QueryInt64("uid"), c.QueryInt64("uid"),
db.AccessMode(c.QueryInt("mode"))); err != nil { db.AccessMode(c.QueryInt("mode"))); err != nil {
log.Error(2, "ChangeCollaborationAccessMode: %v", err) log.Error("ChangeCollaborationAccessMode: %v", err)
return return
} }

View File

@ -13,7 +13,7 @@ import (
"strings" "strings"
"github.com/unknwon/paginater" "github.com/unknwon/paginater"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"github.com/gogs/git-module" "github.com/gogs/git-module"
@ -176,7 +176,7 @@ func renderFile(c *context.Context, entry *git.TreeEntry, treeLink, rawLink stri
var fileContent string var fileContent string
if err, content := template.ToUTF8WithErr(buf); err != nil { if err, content := template.ToUTF8WithErr(buf); err != nil {
if err != nil { if err != nil {
log.Error(4, "ToUTF8WithErr: %s", err) log.Error("ToUTF8WithErr: %s", err)
} }
fileContent = string(buf) fileContent = string(buf)
} else { } else {
@ -186,7 +186,7 @@ func renderFile(c *context.Context, entry *git.TreeEntry, treeLink, rawLink stri
var output bytes.Buffer var output bytes.Buffer
lines := strings.Split(fileContent, "\n") lines := strings.Split(fileContent, "\n")
// Remove blank line at the end of file // Remove blank line at the end of file
if len(lines) > 0 && len(lines[len(lines)-1])==0 { if len(lines) > 0 && len(lines[len(lines)-1]) == 0 {
lines = lines[:len(lines)-1] lines = lines[:len(lines)-1]
} }
for index, line := range lines { for index, line := range lines {

View File

@ -9,7 +9,7 @@ import (
"net/url" "net/url"
"github.com/go-macaron/captcha" "github.com/go-macaron/captcha"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/context" "gogs.io/gogs/internal/context"
"gogs.io/gogs/internal/db" "gogs.io/gogs/internal/db"
@ -239,7 +239,7 @@ func LoginTwoFactorPost(c *context.Context) {
return return
} }
if err = c.Cache.Put(u.TwoFactorCacheKey(passcode), 1, 60); err != nil { if err = c.Cache.Put(u.TwoFactorCacheKey(passcode), 1, 60); err != nil {
log.Error(2, "Failed to put cache 'two factor passcode': %v", err) log.Error("Failed to put cache 'two factor passcode': %v", err)
} }
afterLogin(c, u, c.Session.Get("twoFactorRemember").(bool)) afterLogin(c, u, c.Session.Get("twoFactorRemember").(bool))
@ -376,7 +376,7 @@ func SignUpPost(c *context.Context, cpt *captcha.Captcha, f form.Register) {
c.Success(ACTIVATE) c.Success(ACTIVATE)
if err := c.Cache.Put(u.MailResendCacheKey(), 1, 180); err != nil { if err := c.Cache.Put(u.MailResendCacheKey(), 1, 180); err != nil {
log.Error(2, "Failed to put cache key 'mail resend': %v", err) log.Error("Failed to put cache key 'mail resend': %v", err)
} }
return return
} }
@ -401,7 +401,7 @@ func Activate(c *context.Context) {
mailer.SendActivateAccountMail(c.Context, db.NewMailerUser(c.User)) mailer.SendActivateAccountMail(c.Context, db.NewMailerUser(c.User))
if err := c.Cache.Put(c.User.MailResendCacheKey(), 1, 180); err != nil { if err := c.Cache.Put(c.User.MailResendCacheKey(), 1, 180); err != nil {
log.Error(2, "Failed to put cache key 'mail resend': %v", err) log.Error("Failed to put cache key 'mail resend': %v", err)
} }
} }
} else { } else {
@ -506,7 +506,7 @@ func ForgotPasswdPost(c *context.Context) {
mailer.SendResetPasswordMail(c.Context, db.NewMailerUser(u)) mailer.SendResetPasswordMail(c.Context, db.NewMailerUser(u))
if err = c.Cache.Put(u.MailResendCacheKey(), 1, 180); err != nil { if err = c.Cache.Put(u.MailResendCacheKey(), 1, 180); err != nil {
log.Error(2, "Failed to put cache key 'mail resend': %v", err) log.Error("Failed to put cache key 'mail resend': %v", err)
} }
c.Data["Hours"] = setting.Service.ActiveCodeLives / 60 c.Data["Hours"] = setting.Service.ActiveCodeLives / 60

View File

@ -16,7 +16,7 @@ import (
"github.com/pquerna/otp" "github.com/pquerna/otp"
"github.com/pquerna/otp/totp" "github.com/pquerna/otp/totp"
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/context" "gogs.io/gogs/internal/context"
"gogs.io/gogs/internal/db" "gogs.io/gogs/internal/db"
@ -144,7 +144,7 @@ func UpdateAvatarSetting(c *context.Context, f form.Avatar, ctxUser *db.User) er
// generate a random one when needed. // generate a random one when needed.
if ctxUser.UseCustomAvatar && !com.IsFile(ctxUser.CustomAvatarPath()) { if ctxUser.UseCustomAvatar && !com.IsFile(ctxUser.CustomAvatarPath()) {
if err := ctxUser.GenerateRandomAvatar(); err != nil { if err := ctxUser.GenerateRandomAvatar(); err != nil {
log.Error(2, "generate random avatar [%d]: %v", ctxUser.ID, err) log.Error("generate random avatar [%d]: %v", ctxUser.ID, err)
} }
} }
} }
@ -278,7 +278,7 @@ func SettingsEmailPost(c *context.Context, f form.AddEmail) {
mailer.SendActivateEmailMail(c.Context, db.NewMailerUser(c.User), email.Email) mailer.SendActivateEmailMail(c.Context, db.NewMailerUser(c.User), email.Email)
if err := c.Cache.Put("MailResendLimit_"+c.User.LowerName, c.User.LowerName, 180); err != nil { if err := c.Cache.Put("MailResendLimit_"+c.User.LowerName, c.User.LowerName, 180); err != nil {
log.Error(2, "Set cache 'MailResendLimit' failed: %v", err) log.Error("Set cache 'MailResendLimit' failed: %v", err)
} }
c.Flash.Info(c.Tr("settings.add_email_confirmation_sent", email.Email, setting.Service.ActiveCodeLives/60)) c.Flash.Info(c.Tr("settings.add_email_confirmation_sent", email.Email, setting.Service.ActiveCodeLives/60))
} else { } else {

View File

@ -22,8 +22,8 @@ import (
_ "github.com/go-macaron/session/redis" _ "github.com/go-macaron/session/redis"
"github.com/mcuadros/go-version" "github.com/mcuadros/go-version"
"github.com/unknwon/com" "github.com/unknwon/com"
log "gopkg.in/clog.v1"
"gopkg.in/ini.v1" "gopkg.in/ini.v1"
log "unknwon.dev/clog/v2"
"github.com/gogs/go-libravatar" "github.com/gogs/go-libravatar"
@ -346,15 +346,19 @@ func execPath() (string, error) {
func init() { func init() {
IsWindows = runtime.GOOS == "windows" IsWindows = runtime.GOOS == "windows"
log.New(log.CONSOLE, log.ConsoleConfig{})
var err error err := log.NewConsole()
if AppPath, err = execPath(); err != nil { if err != nil {
log.Fatal(2, "Fail to get app path: %v\n", err) panic("init console logger: " + err.Error())
} }
// Note: we don't use path.Dir here because it does not handle case AppPath, err = execPath()
// which path starts with two "/" in Windows: "//psf/Home/..." if err != nil {
log.Fatal("Failed to get executable path: %v", err)
}
// NOTE: we don't use path.Dir here because it does not handle case
// which path starts with two "/" in Windows: "//psf/Home/..."
AppPath = strings.Replace(AppPath, "\\", "/", -1) AppPath = strings.Replace(AppPath, "\\", "/", -1)
} }
@ -374,7 +378,7 @@ func WorkDir() (string, error) {
func forcePathSeparator(path string) { func forcePathSeparator(path string) {
if strings.Contains(path, "\\") { if strings.Contains(path, "\\") {
log.Fatal(2, "Do not use '\\' or '\\\\' in paths, instead, please use '/' in all places") log.Fatal("Do not use '\\' or '\\\\' in paths, please use '/' in all places")
} }
} }
@ -394,31 +398,33 @@ func IsRunUserMatchCurrentUser(runUser string) (string, bool) {
// getOpenSSHVersion parses and returns string representation of OpenSSH version // getOpenSSHVersion parses and returns string representation of OpenSSH version
// returned by command "ssh -V". // returned by command "ssh -V".
func getOpenSSHVersion() string { func getOpenSSHVersion() string {
// Note: somehow version is printed to stderr // NOTE: Somehow the version is printed to stderr.
_, stderr, err := process.Exec("getOpenSSHVersion", "ssh", "-V") _, stderr, err := process.Exec("setting.getOpenSSHVersion", "ssh", "-V")
if err != nil { if err != nil {
log.Fatal(2, "Fail to get OpenSSH version: %v - %s", err, stderr) log.Fatal("Failed to get OpenSSH version: %v - %s", err, stderr)
} }
// Trim unused information: https://gogs.io/gogs/issues/4507#issuecomment-305150441 // Trim unused information: https://github.com/gogs/gogs/issues/4507#issuecomment-305150441
version := strings.TrimRight(strings.Fields(stderr)[0], ",1234567890") version := strings.TrimRight(strings.Fields(stderr)[0], ",1234567890")
version = strings.TrimSuffix(strings.TrimPrefix(version, "OpenSSH_"), "p") version = strings.TrimSuffix(strings.TrimPrefix(version, "OpenSSH_"), "p")
return version return version
} }
// NewContext initializes configuration context. // Init initializes configuration by loading from sources.
// NOTE: do not print any log except error. // ⚠️ WARNING: Do not print anything in this function other than wanrings or errors.
func NewContext() { func Init() {
workDir, err := WorkDir() workDir, err := WorkDir()
if err != nil { if err != nil {
log.Fatal(2, "Fail to get work directory: %v", err) log.Fatal("Failed to get work directory: %v", err)
return
} }
Cfg, err = ini.LoadSources(ini.LoadOptions{ Cfg, err = ini.LoadSources(ini.LoadOptions{
IgnoreInlineComment: true, IgnoreInlineComment: true,
}, conf.MustAsset("conf/app.ini")) }, conf.MustAsset("conf/app.ini"))
if err != nil { if err != nil {
log.Fatal(2, "Fail to parse 'conf/app.ini': %v", err) log.Fatal("Failed to parse 'conf/app.ini': %v", err)
return
} }
CustomPath = os.Getenv("GOGS_CUSTOM") CustomPath = os.Getenv("GOGS_CUSTOM")
@ -432,16 +438,18 @@ func NewContext() {
if com.IsFile(CustomConf) { if com.IsFile(CustomConf) {
if err = Cfg.Append(CustomConf); err != nil { if err = Cfg.Append(CustomConf); err != nil {
log.Fatal(2, "Fail to load custom conf '%s': %v", CustomConf, err) log.Fatal("Failed to load custom conf %q: %v", CustomConf, err)
return
} }
} else { } else {
log.Warn("Custom config '%s' not found, ignore this if you're running first time", CustomConf) log.Warn("Custom config '%s' not found, ignore this warning if you're running the first time", CustomConf)
} }
Cfg.NameMapper = ini.AllCapsUnderscore Cfg.NameMapper = ini.SnackCase
homeDir, err := com.HomeDir() homeDir, err := com.HomeDir()
if err != nil { if err != nil {
log.Fatal(2, "Fail to get home directory: %v", err) log.Fatal("Failed to get home directory: %v", err)
return
} }
homeDir = strings.Replace(homeDir, "\\", "/", -1) homeDir = strings.Replace(homeDir, "\\", "/", -1)
@ -458,7 +466,8 @@ func NewContext() {
// Check if has app suburl. // Check if has app suburl.
url, err := url.Parse(AppURL) url, err := url.Parse(AppURL)
if err != nil { if err != nil {
log.Fatal(2, "Invalid ROOT_URL '%s': %s", AppURL, err) log.Fatal("Failed to parse ROOT_URL %q: %s", AppURL, err)
return
} }
// Suburl should start with '/' and end without '/', such as '/{subpath}'. // Suburl should start with '/' and end without '/', such as '/{subpath}'.
// This value is empty if site does not have sub-url. // This value is empty if site does not have sub-url.
@ -479,7 +488,8 @@ func NewContext() {
UnixSocketPermissionRaw := sec.Key("UNIX_SOCKET_PERMISSION").MustString("666") UnixSocketPermissionRaw := sec.Key("UNIX_SOCKET_PERMISSION").MustString("666")
UnixSocketPermissionParsed, err := strconv.ParseUint(UnixSocketPermissionRaw, 8, 32) UnixSocketPermissionParsed, err := strconv.ParseUint(UnixSocketPermissionRaw, 8, 32)
if err != nil || UnixSocketPermissionParsed > 0777 { if err != nil || UnixSocketPermissionParsed > 0777 {
log.Fatal(2, "Fail to parse unixSocketPermission: %s", UnixSocketPermissionRaw) log.Fatal("Failed to parse unixSocketPermission %q: %v", UnixSocketPermissionRaw, err)
return
} }
UnixSocketPermission = uint32(UnixSocketPermissionParsed) UnixSocketPermission = uint32(UnixSocketPermissionParsed)
} }
@ -506,7 +516,8 @@ func NewContext() {
SSH.ServerCiphers = sec.Key("SSH_SERVER_CIPHERS").Strings(",") SSH.ServerCiphers = sec.Key("SSH_SERVER_CIPHERS").Strings(",")
SSH.KeyTestPath = os.TempDir() SSH.KeyTestPath = os.TempDir()
if err = Cfg.Section("server").MapTo(&SSH); err != nil { if err = Cfg.Section("server").MapTo(&SSH); err != nil {
log.Fatal(2, "Fail to map SSH settings: %v", err) log.Fatal("Failed to map SSH settings: %v", err)
return
} }
if SSH.Disabled { if SSH.Disabled {
SSH.StartBuiltinServer = false SSH.StartBuiltinServer = false
@ -515,9 +526,11 @@ func NewContext() {
if !SSH.Disabled && !SSH.StartBuiltinServer { if !SSH.Disabled && !SSH.StartBuiltinServer {
if err := os.MkdirAll(SSH.RootPath, 0700); err != nil { if err := os.MkdirAll(SSH.RootPath, 0700); err != nil {
log.Fatal(2, "Fail to create '%s': %v", SSH.RootPath, err) log.Fatal("Failed to create '%s': %v", SSH.RootPath, err)
return
} else if err = os.MkdirAll(SSH.KeyTestPath, 0644); err != nil { } else if err = os.MkdirAll(SSH.KeyTestPath, 0644); err != nil {
log.Fatal(2, "Fail to create '%s': %v", SSH.KeyTestPath, err) log.Fatal("Failed to create '%s': %v", SSH.KeyTestPath, err)
return
} }
} }
@ -589,7 +602,8 @@ func NewContext() {
if InstallLock { if InstallLock {
currentUser, match := IsRunUserMatchCurrentUser(RunUser) currentUser, match := IsRunUserMatchCurrentUser(RunUser)
if !match { if !match {
log.Fatal(2, "Expect user '%s' but current user is: %s", RunUser, currentUser) log.Fatal("The user configured to run Gogs is %q, but the current user is %q", RunUser, currentUser)
return
} }
} }
@ -606,11 +620,14 @@ func NewContext() {
} }
ScriptType = sec.Key("SCRIPT_TYPE").MustString("bash") ScriptType = sec.Key("SCRIPT_TYPE").MustString("bash")
if err = Cfg.Section("repository").MapTo(&Repository); err != nil { if err = Cfg.Section("repository").MapTo(&Repository); err != nil {
log.Fatal(2, "Fail to map Repository settings: %v", err) log.Fatal("Failed to map Repository settings: %v", err)
return
} else if err = Cfg.Section("repository.editor").MapTo(&Repository.Editor); err != nil { } else if err = Cfg.Section("repository.editor").MapTo(&Repository.Editor); err != nil {
log.Fatal(2, "Fail to map Repository.Editor settings: %v", err) log.Fatal("Failed to map Repository.Editor settings: %v", err)
return
} else if err = Cfg.Section("repository.upload").MapTo(&Repository.Upload); err != nil { } else if err = Cfg.Section("repository.upload").MapTo(&Repository.Upload); err != nil {
log.Fatal(2, "Fail to map Repository.Upload settings: %v", err) log.Fatal("Failed to map Repository.Upload settings: %v", err)
return
} }
if !filepath.IsAbs(Repository.Upload.TempPath) { if !filepath.IsAbs(Repository.Upload.TempPath) {
@ -663,29 +680,41 @@ func NewContext() {
} }
if err = Cfg.Section("http").MapTo(&HTTP); err != nil { if err = Cfg.Section("http").MapTo(&HTTP); err != nil {
log.Fatal(2, "Failed to map HTTP settings: %v", err) log.Fatal("Failed to map HTTP settings: %v", err)
return
} else if err = Cfg.Section("webhook").MapTo(&Webhook); err != nil { } else if err = Cfg.Section("webhook").MapTo(&Webhook); err != nil {
log.Fatal(2, "Failed to map Webhook settings: %v", err) log.Fatal("Failed to map Webhook settings: %v", err)
return
} else if err = Cfg.Section("release.attachment").MapTo(&Release.Attachment); err != nil { } else if err = Cfg.Section("release.attachment").MapTo(&Release.Attachment); err != nil {
log.Fatal(2, "Failed to map Release.Attachment settings: %v", err) log.Fatal("Failed to map Release.Attachment settings: %v", err)
return
} else if err = Cfg.Section("markdown").MapTo(&Markdown); err != nil { } else if err = Cfg.Section("markdown").MapTo(&Markdown); err != nil {
log.Fatal(2, "Failed to map Markdown settings: %v", err) log.Fatal("Failed to map Markdown settings: %v", err)
return
} else if err = Cfg.Section("smartypants").MapTo(&Smartypants); err != nil { } else if err = Cfg.Section("smartypants").MapTo(&Smartypants); err != nil {
log.Fatal(2, "Failed to map Smartypants settings: %v", err) log.Fatal("Failed to map Smartypants settings: %v", err)
return
} else if err = Cfg.Section("admin").MapTo(&Admin); err != nil { } else if err = Cfg.Section("admin").MapTo(&Admin); err != nil {
log.Fatal(2, "Failed to map Admin settings: %v", err) log.Fatal("Failed to map Admin settings: %v", err)
return
} else if err = Cfg.Section("cron").MapTo(&Cron); err != nil { } else if err = Cfg.Section("cron").MapTo(&Cron); err != nil {
log.Fatal(2, "Failed to map Cron settings: %v", err) log.Fatal("Failed to map Cron settings: %v", err)
return
} else if err = Cfg.Section("git").MapTo(&Git); err != nil { } else if err = Cfg.Section("git").MapTo(&Git); err != nil {
log.Fatal(2, "Failed to map Git settings: %v", err) log.Fatal("Failed to map Git settings: %v", err)
return
} else if err = Cfg.Section("mirror").MapTo(&Mirror); err != nil { } else if err = Cfg.Section("mirror").MapTo(&Mirror); err != nil {
log.Fatal(2, "Failed to map Mirror settings: %v", err) log.Fatal("Failed to map Mirror settings: %v", err)
return
} else if err = Cfg.Section("api").MapTo(&API); err != nil { } else if err = Cfg.Section("api").MapTo(&API); err != nil {
log.Fatal(2, "Failed to map API settings: %v", err) log.Fatal("Failed to map API settings: %v", err)
return
} else if err = Cfg.Section("ui").MapTo(&UI); err != nil { } else if err = Cfg.Section("ui").MapTo(&UI); err != nil {
log.Fatal(2, "Failed to map UI settings: %v", err) log.Fatal("Failed to map UI settings: %v", err)
return
} else if err = Cfg.Section("prometheus").MapTo(&Prometheus); err != nil { } else if err = Cfg.Section("prometheus").MapTo(&Prometheus); err != nil {
log.Fatal(2, "Failed to map Prometheus settings: %v", err) log.Fatal("Failed to map Prometheus settings: %v", err)
return
} }
if Mirror.DefaultInterval <= 0 { if Mirror.DefaultInterval <= 0 {
@ -702,6 +731,114 @@ func NewContext() {
HasRobotsTxt = com.IsFile(path.Join(CustomPath, "robots.txt")) HasRobotsTxt = com.IsFile(path.Join(CustomPath, "robots.txt"))
} }
// InitLogging initializes the logging infrastructure of the application.
func InitLogging() {
// Because we always create a console logger as the primary logger at init time,
// we need to remove it in case the user doesn't configure to use it after the
// logging infrastructure is initalized.
hasConsole := false
// Iterate over [log.*] sections to initialize individual logger.
LogModes = strings.Split(Cfg.Section("log").Key("MODE").MustString("console"), ",")
LogConfigs = make([]interface{}, len(LogModes))
levelMappings := map[string]log.Level{
"trace": log.LevelTrace,
"info": log.LevelInfo,
"warn": log.LevelWarn,
"error": log.LevelError,
"fatal": log.LevelFatal,
}
type config struct {
Buffer int64
Config interface{}
}
for i, mode := range LogModes {
mode = strings.ToLower(strings.TrimSpace(mode))
secName := "log." + mode
sec, err := Cfg.GetSection(secName)
if err != nil {
log.Fatal("Missing configuration section [%s] for %q logger", secName, mode)
return
}
level := levelMappings[sec.Key("LEVEL").MustString("trace")]
buffer := sec.Key("BUFFER_LEN").MustInt64(100)
c := new(config)
switch mode {
case log.DefaultConsoleName:
hasConsole = true
c = &config{
Buffer: buffer,
Config: log.ConsoleConfig{
Level: level,
},
}
err = log.NewConsole(c.Buffer, c.Config)
case log.DefaultFileName:
logPath := filepath.Join(LogRootPath, "gogs.log")
logDir := filepath.Dir(logPath)
err = os.MkdirAll(logDir, os.ModePerm)
if err != nil {
log.Fatal("Failed to create log directory %q: %v", logDir, err)
return
}
c = &config{
Buffer: buffer,
Config: log.FileConfig{
Level: level,
Filename: logPath,
FileRotationConfig: log.FileRotationConfig{
Rotate: sec.Key("LOG_ROTATE").MustBool(true),
Daily: sec.Key("DAILY_ROTATE").MustBool(true),
MaxSize: 1 << uint(sec.Key("MAX_SIZE_SHIFT").MustInt(28)),
MaxLines: sec.Key("MAX_LINES").MustInt64(1000000),
MaxDays: sec.Key("MAX_DAYS").MustInt64(7),
},
},
}
err = log.NewFile(c.Buffer, c.Config)
case log.DefaultSlackName:
c = &config{
Buffer: buffer,
Config: log.SlackConfig{
Level: level,
URL: sec.Key("URL").String(),
},
}
err = log.NewSlack(c.Buffer, c.Config)
case log.DefaultDiscordName:
c = &config{
Buffer: buffer,
Config: log.DiscordConfig{
Level: level,
URL: sec.Key("URL").String(),
Username: sec.Key("USERNAME").String(),
},
}
default:
continue
}
if err != nil {
log.Fatal("Failed to init %s logger: %v", mode, err)
return
}
LogConfigs[i] = c
log.Trace("Log mode: %s (%s)", strings.Title(mode), strings.Title(strings.ToLower(level.String())))
}
if !hasConsole {
log.Remove(log.DefaultConsoleName)
}
}
var Service struct { var Service struct {
ActiveCodeLives int ActiveCodeLives int
ResetPwdCodeLives int ResetPwdCodeLives int
@ -727,98 +864,6 @@ func newService() {
Service.EnableCaptcha = sec.Key("ENABLE_CAPTCHA").MustBool() Service.EnableCaptcha = sec.Key("ENABLE_CAPTCHA").MustBool()
} }
func newLogService() {
if len(BuildTime) > 0 {
log.Trace("Build time: %s", BuildTime)
log.Trace("Build commit: %s", BuildCommit)
}
// Because we always create a console logger as primary logger before all settings are loaded,
// thus if user doesn't set console logger, we should remove it after other loggers are created.
hasConsole := false
// Get and check log modes.
LogModes = strings.Split(Cfg.Section("log").Key("MODE").MustString("console"), ",")
LogConfigs = make([]interface{}, len(LogModes))
levelNames := map[string]log.LEVEL{
"trace": log.TRACE,
"info": log.INFO,
"warn": log.WARN,
"error": log.ERROR,
"fatal": log.FATAL,
}
for i, mode := range LogModes {
mode = strings.ToLower(strings.TrimSpace(mode))
sec, err := Cfg.GetSection("log." + mode)
if err != nil {
log.Fatal(2, "Unknown logger mode: %s", mode)
}
validLevels := []string{"trace", "info", "warn", "error", "fatal"}
name := Cfg.Section("log." + mode).Key("LEVEL").Validate(func(v string) string {
v = strings.ToLower(v)
if com.IsSliceContainsStr(validLevels, v) {
return v
}
return "trace"
})
level := levelNames[name]
// Generate log configuration.
switch log.MODE(mode) {
case log.CONSOLE:
hasConsole = true
LogConfigs[i] = log.ConsoleConfig{
Level: level,
BufferSize: Cfg.Section("log").Key("BUFFER_LEN").MustInt64(100),
}
case log.FILE:
logPath := path.Join(LogRootPath, "gogs.log")
if err = os.MkdirAll(path.Dir(logPath), os.ModePerm); err != nil {
log.Fatal(2, "Fail to create log directory '%s': %v", path.Dir(logPath), err)
}
LogConfigs[i] = log.FileConfig{
Level: level,
BufferSize: Cfg.Section("log").Key("BUFFER_LEN").MustInt64(100),
Filename: logPath,
FileRotationConfig: log.FileRotationConfig{
Rotate: sec.Key("LOG_ROTATE").MustBool(true),
Daily: sec.Key("DAILY_ROTATE").MustBool(true),
MaxSize: 1 << uint(sec.Key("MAX_SIZE_SHIFT").MustInt(28)),
MaxLines: sec.Key("MAX_LINES").MustInt64(1000000),
MaxDays: sec.Key("MAX_DAYS").MustInt64(7),
},
}
case log.SLACK:
LogConfigs[i] = log.SlackConfig{
Level: level,
BufferSize: Cfg.Section("log").Key("BUFFER_LEN").MustInt64(100),
URL: sec.Key("URL").String(),
}
case log.DISCORD:
LogConfigs[i] = log.DiscordConfig{
Level: level,
BufferSize: Cfg.Section("log").Key("BUFFER_LEN").MustInt64(100),
URL: sec.Key("URL").String(),
Username: sec.Key("USERNAME").String(),
}
}
log.New(log.MODE(mode), LogConfigs[i])
log.Trace("Log mode: %s (%s)", strings.Title(mode), strings.Title(name))
}
// Make sure everyone gets version info printed.
log.Info("%s %s", AppName, AppVersion)
if !hasConsole {
log.Delete(log.CONSOLE)
}
}
func newCacheService() { func newCacheService() {
CacheAdapter = Cfg.Section("cache").Key("ADAPTER").In("memory", []string{"memory", "redis", "memcache"}) CacheAdapter = Cfg.Section("cache").Key("ADAPTER").In("memory", []string{"memory", "redis", "memcache"})
switch CacheAdapter { switch CacheAdapter {
@ -827,7 +872,8 @@ func newCacheService() {
case "redis", "memcache": case "redis", "memcache":
CacheConn = strings.Trim(Cfg.Section("cache").Key("HOST").String(), "\" ") CacheConn = strings.Trim(Cfg.Section("cache").Key("HOST").String(), "\" ")
default: default:
log.Fatal(2, "Unknown cache adapter: %s", CacheAdapter) log.Fatal("Unrecognized cache adapter %q", CacheAdapter)
return
} }
log.Trace("Cache service is enabled") log.Trace("Cache service is enabled")
@ -896,7 +942,8 @@ func newMailService() {
if len(MailService.From) > 0 { if len(MailService.From) > 0 {
parsed, err := mail.ParseAddress(MailService.From) parsed, err := mail.ParseAddress(MailService.From)
if err != nil { if err != nil {
log.Fatal(2, "Invalid mailer.FROM (%s): %v", MailService.From, err) log.Fatal("Failed to parse value %q for '[mailer] FROM': %v", MailService.From, err)
return
} }
MailService.FromEmail = parsed.Address MailService.FromEmail = parsed.Address
} }
@ -941,7 +988,6 @@ func NewService() {
func NewServices() { func NewServices() {
newService() newService()
newLogService()
newCacheService() newCacheService()
newSessionService() newSessionService()
newMailService() newMailService()

View File

@ -16,7 +16,7 @@ import (
"github.com/unknwon/com" "github.com/unknwon/com"
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/db" "gogs.io/gogs/internal/db"
"gogs.io/gogs/internal/setting" "gogs.io/gogs/internal/setting"
@ -39,7 +39,7 @@ func handleServerConn(keyID string, chans <-chan ssh.NewChannel) {
ch, reqs, err := newChan.Accept() ch, reqs, err := newChan.Accept()
if err != nil { if err != nil {
log.Error(3, "Error accepting channel: %v", err) log.Error("Error accepting channel: %v", err)
continue continue
} }
@ -57,7 +57,7 @@ func handleServerConn(keyID string, chans <-chan ssh.NewChannel) {
args[0] = strings.TrimLeft(args[0], "\x04") args[0] = strings.TrimLeft(args[0], "\x04")
_, _, err := com.ExecCmdBytes("env", args[0]+"="+args[1]) _, _, err := com.ExecCmdBytes("env", args[0]+"="+args[1])
if err != nil { if err != nil {
log.Error(3, "env: %v", err) log.Error("env: %v", err)
return return
} }
case "exec": case "exec":
@ -71,23 +71,23 @@ func handleServerConn(keyID string, chans <-chan ssh.NewChannel) {
stdout, err := cmd.StdoutPipe() stdout, err := cmd.StdoutPipe()
if err != nil { if err != nil {
log.Error(3, "SSH: StdoutPipe: %v", err) log.Error("SSH: StdoutPipe: %v", err)
return return
} }
stderr, err := cmd.StderrPipe() stderr, err := cmd.StderrPipe()
if err != nil { if err != nil {
log.Error(3, "SSH: StderrPipe: %v", err) log.Error("SSH: StderrPipe: %v", err)
return return
} }
input, err := cmd.StdinPipe() input, err := cmd.StdinPipe()
if err != nil { if err != nil {
log.Error(3, "SSH: StdinPipe: %v", err) log.Error("SSH: StdinPipe: %v", err)
return return
} }
// FIXME: check timeout // FIXME: check timeout
if err = cmd.Start(); err != nil { if err = cmd.Start(); err != nil {
log.Error(3, "SSH: Start: %v", err) log.Error("SSH: Start: %v", err)
return return
} }
@ -97,7 +97,7 @@ func handleServerConn(keyID string, chans <-chan ssh.NewChannel) {
io.Copy(ch.Stderr(), stderr) io.Copy(ch.Stderr(), stderr)
if err = cmd.Wait(); err != nil { if err = cmd.Wait(); err != nil {
log.Error(3, "SSH: Wait: %v", err) log.Error("SSH: Wait: %v", err)
return return
} }
@ -113,13 +113,13 @@ func handleServerConn(keyID string, chans <-chan ssh.NewChannel) {
func listen(config *ssh.ServerConfig, host string, port int) { func listen(config *ssh.ServerConfig, host string, port int) {
listener, err := net.Listen("tcp", host+":"+com.ToStr(port)) listener, err := net.Listen("tcp", host+":"+com.ToStr(port))
if err != nil { if err != nil {
log.Fatal(4, "Fail to start SSH server: %v", err) log.Fatal("Failed to start SSH server: %v", err)
} }
for { for {
// Once a ServerConfig has been configured, connections can be accepted. // Once a ServerConfig has been configured, connections can be accepted.
conn, err := listener.Accept() conn, err := listener.Accept()
if err != nil { if err != nil {
log.Error(3, "SSH: Error accepting incoming connection: %v", err) log.Error("SSH: Error accepting incoming connection: %v", err)
continue continue
} }
@ -134,7 +134,7 @@ func listen(config *ssh.ServerConfig, host string, port int) {
if err == io.EOF { if err == io.EOF {
log.Warn("SSH: Handshaking was terminated: %v", err) log.Warn("SSH: Handshaking was terminated: %v", err)
} else { } else {
log.Error(3, "SSH: Error on handshaking: %v", err) log.Error("SSH: Error on handshaking: %v", err)
} }
return return
} }
@ -156,7 +156,7 @@ func Listen(host string, port int, ciphers []string) {
PublicKeyCallback: func(conn ssh.ConnMetadata, key ssh.PublicKey) (*ssh.Permissions, error) { PublicKeyCallback: func(conn ssh.ConnMetadata, key ssh.PublicKey) (*ssh.Permissions, error) {
pkey, err := db.SearchPublicKeyByContent(strings.TrimSpace(string(ssh.MarshalAuthorizedKey(key)))) pkey, err := db.SearchPublicKeyByContent(strings.TrimSpace(string(ssh.MarshalAuthorizedKey(key))))
if err != nil { if err != nil {
log.Error(3, "SearchPublicKeyByContent: %v", err) log.Error("SearchPublicKeyByContent: %v", err)
return nil, err return nil, err
} }
return &ssh.Permissions{Extensions: map[string]string{"key-id": com.ToStr(pkey.ID)}}, nil return &ssh.Permissions{Extensions: map[string]string{"key-id": com.ToStr(pkey.ID)}}, nil
@ -168,18 +168,18 @@ func Listen(host string, port int, ciphers []string) {
os.MkdirAll(filepath.Dir(keyPath), os.ModePerm) os.MkdirAll(filepath.Dir(keyPath), os.ModePerm)
_, stderr, err := com.ExecCmd(setting.SSH.KeygenPath, "-f", keyPath, "-t", "rsa", "-m", "PEM", "-N", "") _, stderr, err := com.ExecCmd(setting.SSH.KeygenPath, "-f", keyPath, "-t", "rsa", "-m", "PEM", "-N", "")
if err != nil { if err != nil {
panic(fmt.Sprintf("Fail to generate private key: %v - %s", err, stderr)) panic(fmt.Sprintf("Failed to generate private key: %v - %s", err, stderr))
} }
log.Trace("SSH: New private key is generateed: %s", keyPath) log.Trace("SSH: New private key is generateed: %s", keyPath)
} }
privateBytes, err := ioutil.ReadFile(keyPath) privateBytes, err := ioutil.ReadFile(keyPath)
if err != nil { if err != nil {
panic("SSH: Fail to load private key: " + err.Error()) panic("SSH: Failed to load private key: " + err.Error())
} }
private, err := ssh.ParsePrivateKey(privateBytes) private, err := ssh.ParsePrivateKey(privateBytes)
if err != nil { if err != nil {
panic("SSH: Fail to parse private key: " + err.Error()) panic("SSH: Failed to parse private key: " + err.Error())
} }
config.AddHostKey(private) config.AddHostKey(private)

View File

@ -19,7 +19,7 @@ import (
"github.com/microcosm-cc/bluemonday" "github.com/microcosm-cc/bluemonday"
"golang.org/x/net/html/charset" "golang.org/x/net/html/charset"
"golang.org/x/text/transform" "golang.org/x/text/transform"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/db" "gogs.io/gogs/internal/db"
"gogs.io/gogs/internal/markup" "gogs.io/gogs/internal/markup"
@ -292,7 +292,7 @@ func ActionIcon(opType int) string {
func ActionContent2Commits(act Actioner) *db.PushCommits { func ActionContent2Commits(act Actioner) *db.PushCommits {
push := db.NewPushCommits() push := db.NewPushCommits()
if err := jsoniter.Unmarshal([]byte(act.GetContent()), push); err != nil { if err := jsoniter.Unmarshal([]byte(act.GetContent()), push); err != nil {
log.Error(4, "Unmarshal:\n%s\nERROR: %v", act.GetContent(), err) log.Error("Unmarshal:\n%s\nERROR: %v", act.GetContent(), err)
} }
return push return push
} }

View File

@ -20,7 +20,7 @@ import (
"github.com/unknwon/com" "github.com/unknwon/com"
"github.com/unknwon/i18n" "github.com/unknwon/i18n"
log "gopkg.in/clog.v1" log "unknwon.dev/clog/v2"
"github.com/gogs/chardet" "github.com/gogs/chardet"