mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-22 21:04:06 +01:00
Remove qiniu/log
This commit is contained in:
parent
6c8d630bef
commit
8bfa7ae745
8 changed files with 56 additions and 83 deletions
58
cmd/serve.go
58
cmd/serve.go
|
@ -13,9 +13,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/codegangsta/cli"
|
"github.com/codegangsta/cli"
|
||||||
qlog "github.com/qiniu/log"
|
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/modules/log"
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -27,26 +27,13 @@ var CmdServ = cli.Command{
|
||||||
Flags: []cli.Flag{},
|
Flags: []cli.Flag{},
|
||||||
}
|
}
|
||||||
|
|
||||||
func newLogger(logPath string) {
|
|
||||||
os.MkdirAll(path.Dir(logPath), os.ModePerm)
|
|
||||||
|
|
||||||
f, err := os.OpenFile(logPath, os.O_WRONLY|os.O_APPEND|os.O_CREATE, os.ModePerm)
|
|
||||||
if err != nil {
|
|
||||||
qlog.Fatal("Fail to open log file(%s): %v", logPath, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
qlog.SetOutput(f)
|
|
||||||
qlog.Info("Start logging serv...")
|
|
||||||
}
|
|
||||||
|
|
||||||
func setup(logPath string) {
|
func setup(logPath string) {
|
||||||
workDir, _ := setting.WorkDir()
|
|
||||||
newLogger(path.Join(workDir, logPath))
|
|
||||||
|
|
||||||
setting.NewConfigContext()
|
setting.NewConfigContext()
|
||||||
|
log.NewGitLogger(path.Join(setting.LogRootPath, logPath))
|
||||||
models.LoadModelsConfig()
|
models.LoadModelsConfig()
|
||||||
|
|
||||||
if models.UseSQLite3 {
|
if models.UseSQLite3 {
|
||||||
|
workDir, _ := setting.WorkDir()
|
||||||
os.Chdir(workDir)
|
os.Chdir(workDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,27 +74,27 @@ func In(b string, sl map[string]int) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func runServ(k *cli.Context) {
|
func runServ(k *cli.Context) {
|
||||||
setup(path.Join(setting.LogRootPath, "serv.log"))
|
setup("serv.log")
|
||||||
|
|
||||||
keys := strings.Split(os.Args[2], "-")
|
keys := strings.Split(os.Args[2], "-")
|
||||||
if len(keys) != 2 {
|
if len(keys) != 2 {
|
||||||
println("Gogs: auth file format error")
|
println("Gogs: auth file format error")
|
||||||
qlog.Fatal("Invalid auth file format: %s", os.Args[2])
|
log.GitLogger.Fatal("Invalid auth file format: %s", os.Args[2])
|
||||||
}
|
}
|
||||||
|
|
||||||
keyId, err := strconv.ParseInt(keys[1], 10, 64)
|
keyId, err := strconv.ParseInt(keys[1], 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println("Gogs: auth file format error")
|
println("Gogs: auth file format error")
|
||||||
qlog.Fatalf("Invalid auth file format: %v", err)
|
log.GitLogger.Fatal("Invalid auth file format: %v", err)
|
||||||
}
|
}
|
||||||
user, err := models.GetUserByKeyId(keyId)
|
user, err := models.GetUserByKeyId(keyId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrUserNotKeyOwner {
|
if err == models.ErrUserNotKeyOwner {
|
||||||
println("Gogs: you are not the owner of SSH key")
|
println("Gogs: you are not the owner of SSH key")
|
||||||
qlog.Fatalf("Invalid owner of SSH key: %d", keyId)
|
log.GitLogger.Fatal("Invalid owner of SSH key: %d", keyId)
|
||||||
}
|
}
|
||||||
println("Gogs: internal error:", err)
|
println("Gogs: internal error:", err)
|
||||||
qlog.Fatalf("Fail to get user by key ID(%d): %v", keyId, err)
|
log.GitLogger.Fatal("Fail to get user by key ID(%d): %v", keyId, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := os.Getenv("SSH_ORIGINAL_COMMAND")
|
cmd := os.Getenv("SSH_ORIGINAL_COMMAND")
|
||||||
|
@ -121,7 +108,7 @@ func runServ(k *cli.Context) {
|
||||||
rr := strings.SplitN(repoPath, "/", 2)
|
rr := strings.SplitN(repoPath, "/", 2)
|
||||||
if len(rr) != 2 {
|
if len(rr) != 2 {
|
||||||
println("Gogs: unavailable repository", args)
|
println("Gogs: unavailable repository", args)
|
||||||
qlog.Fatalf("Unavailable repository: %v", args)
|
log.GitLogger.Fatal("Unavailable repository: %v", args)
|
||||||
}
|
}
|
||||||
repoUserName := rr[0]
|
repoUserName := rr[0]
|
||||||
repoName := strings.TrimSuffix(rr[1], ".git")
|
repoName := strings.TrimSuffix(rr[1], ".git")
|
||||||
|
@ -133,10 +120,10 @@ func runServ(k *cli.Context) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrUserNotExist {
|
if err == models.ErrUserNotExist {
|
||||||
println("Gogs: given repository owner are not registered")
|
println("Gogs: given repository owner are not registered")
|
||||||
qlog.Fatalf("Unregistered owner: %s", repoUserName)
|
log.GitLogger.Fatal("Unregistered owner: %s", repoUserName)
|
||||||
}
|
}
|
||||||
println("Gogs: internal error:", err)
|
println("Gogs: internal error:", err)
|
||||||
qlog.Fatalf("Fail to get repository owner(%s): %v", repoUserName, err)
|
log.GitLogger.Fatal("Fail to get repository owner(%s): %v", repoUserName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Access check.
|
// Access check.
|
||||||
|
@ -145,20 +132,20 @@ func runServ(k *cli.Context) {
|
||||||
has, err := models.HasAccess(user.Name, path.Join(repoUserName, repoName), models.AU_WRITABLE)
|
has, err := models.HasAccess(user.Name, path.Join(repoUserName, repoName), models.AU_WRITABLE)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println("Gogs: internal error:", err)
|
println("Gogs: internal error:", err)
|
||||||
qlog.Fatal("Fail to check write access:", err)
|
log.GitLogger.Fatal("Fail to check write access:", err)
|
||||||
} else if !has {
|
} else if !has {
|
||||||
println("You have no right to write this repository")
|
println("You have no right to write this repository")
|
||||||
qlog.Fatalf("User %s has no right to write repository %s", user.Name, repoPath)
|
log.GitLogger.Fatal("User %s has no right to write repository %s", user.Name, repoPath)
|
||||||
}
|
}
|
||||||
case isRead:
|
case isRead:
|
||||||
repo, err := models.GetRepositoryByName(repoUser.Id, repoName)
|
repo, err := models.GetRepositoryByName(repoUser.Id, repoName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrRepoNotExist {
|
if err == models.ErrRepoNotExist {
|
||||||
println("Gogs: given repository does not exist")
|
println("Gogs: given repository does not exist")
|
||||||
qlog.Fatalf("Repository does not exist: %s/%s", repoUser.Name, repoName)
|
log.GitLogger.Fatal("Repository does not exist: %s/%s", repoUser.Name, repoName)
|
||||||
}
|
}
|
||||||
println("Gogs: internal error:", err)
|
println("Gogs: internal error:", err)
|
||||||
qlog.Fatalf("Fail to get repository: %v", err)
|
log.GitLogger.Fatal("Fail to get repository: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !repo.IsPrivate {
|
if !repo.IsPrivate {
|
||||||
|
@ -168,10 +155,10 @@ func runServ(k *cli.Context) {
|
||||||
has, err := models.HasAccess(user.Name, path.Join(repoUserName, repoName), models.AU_READABLE)
|
has, err := models.HasAccess(user.Name, path.Join(repoUserName, repoName), models.AU_READABLE)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println("Gogs: internal error:", err)
|
println("Gogs: internal error:", err)
|
||||||
qlog.Fatal("Fail to check read access:", err)
|
log.GitLogger.Fatal("Fail to check read access:", err)
|
||||||
} else if !has {
|
} else if !has {
|
||||||
println("You have no right to access this repository")
|
println("You have no right to access this repository")
|
||||||
qlog.Fatalf("User %s has no right to read repository %s", user.Name, repoPath)
|
log.GitLogger.Fatal("User %s has no right to read repository %s", user.Name, repoPath)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
println("Unknown command")
|
println("Unknown command")
|
||||||
|
@ -188,15 +175,6 @@ func runServ(k *cli.Context) {
|
||||||
err = gitcmd.Run()
|
err = gitcmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println("Gogs: internal error:", err)
|
println("Gogs: internal error:", err)
|
||||||
qlog.Fatalf("Fail to execute git command: %v", err)
|
log.GitLogger.Fatal("Fail to execute git command: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
//refName := os.Getenv("refName")
|
|
||||||
//oldCommitId := os.Getenv("oldCommitId")
|
|
||||||
//newCommitId := os.Getenv("newCommitId")
|
|
||||||
|
|
||||||
//qlog.Error("get envs:", refName, oldCommitId, newCommitId)
|
|
||||||
|
|
||||||
// update
|
|
||||||
//models.Update(refName, oldCommitId, newCommitId, repoUserName, repoName, user.Id)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,14 +6,12 @@ package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/codegangsta/cli"
|
"github.com/codegangsta/cli"
|
||||||
qlog "github.com/qiniu/log"
|
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var CmdUpdate = cli.Command{
|
var CmdUpdate = cli.Command{
|
||||||
|
@ -24,33 +22,23 @@ var CmdUpdate = cli.Command{
|
||||||
Flags: []cli.Flag{},
|
Flags: []cli.Flag{},
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateEnv(refName, oldCommitId, newCommitId string) {
|
|
||||||
os.Setenv("refName", refName)
|
|
||||||
os.Setenv("oldCommitId", oldCommitId)
|
|
||||||
os.Setenv("newCommitId", newCommitId)
|
|
||||||
qlog.Info("set envs:", refName, oldCommitId, newCommitId)
|
|
||||||
}
|
|
||||||
|
|
||||||
func runUpdate(c *cli.Context) {
|
func runUpdate(c *cli.Context) {
|
||||||
cmd := os.Getenv("SSH_ORIGINAL_COMMAND")
|
cmd := os.Getenv("SSH_ORIGINAL_COMMAND")
|
||||||
if cmd == "" {
|
if cmd == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
setup(path.Join(setting.LogRootPath, "update.log"))
|
setup("update.log")
|
||||||
|
|
||||||
args := c.Args()
|
args := c.Args()
|
||||||
if len(args) != 3 {
|
if len(args) != 3 {
|
||||||
qlog.Fatal("received less 3 parameters")
|
log.GitLogger.Fatal("received less 3 parameters")
|
||||||
} else if args[0] == "" {
|
} else if args[0] == "" {
|
||||||
qlog.Fatal("refName is empty, shouldn't use")
|
log.GitLogger.Fatal("refName is empty, shouldn't use")
|
||||||
}
|
}
|
||||||
|
|
||||||
//updateEnv(args[0], args[1], args[2])
|
|
||||||
|
|
||||||
userName := os.Getenv("userName")
|
userName := os.Getenv("userName")
|
||||||
userId, _ := strconv.ParseInt(os.Getenv("userId"), 10, 64)
|
userId, _ := strconv.ParseInt(os.Getenv("userId"), 10, 64)
|
||||||
//repoId := os.Getenv("repoId")
|
|
||||||
repoUserName := os.Getenv("repoUserName")
|
repoUserName := os.Getenv("repoUserName")
|
||||||
repoName := os.Getenv("repoName")
|
repoName := os.Getenv("repoName")
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gogits/git"
|
"github.com/gogits/git"
|
||||||
qlog "github.com/qiniu/log"
|
|
||||||
|
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/modules/log"
|
"github.com/gogits/gogs/modules/log"
|
||||||
|
@ -115,7 +114,7 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string,
|
||||||
return errors.New("action.CommitRepoAction(NotifyWatchers): " + err.Error())
|
return errors.New("action.CommitRepoAction(NotifyWatchers): " + err.Error())
|
||||||
|
|
||||||
}
|
}
|
||||||
qlog.Info("action.CommitRepoAction(end): %d/%s", repoUserId, repoName)
|
//qlog.Info("action.CommitRepoAction(end): %d/%s", repoUserId, repoName)
|
||||||
|
|
||||||
// New push event hook.
|
// New push event hook.
|
||||||
if err := repo.GetOwner(); err != nil {
|
if err := repo.GetOwner(); err != nil {
|
||||||
|
|
|
@ -19,7 +19,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Unknwon/com"
|
"github.com/Unknwon/com"
|
||||||
qlog "github.com/qiniu/log"
|
|
||||||
|
|
||||||
"github.com/gogits/gogs/modules/log"
|
"github.com/gogits/gogs/modules/log"
|
||||||
"github.com/gogits/gogs/modules/process"
|
"github.com/gogits/gogs/modules/process"
|
||||||
|
@ -55,7 +54,7 @@ func exePath() (string, error) {
|
||||||
func homeDir() string {
|
func homeDir() string {
|
||||||
home, err := com.HomeDir()
|
home, err := com.HomeDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
qlog.Fatalln(err)
|
log.Fatal("Fail to get home directory: %v", err)
|
||||||
}
|
}
|
||||||
return home
|
return home
|
||||||
}
|
}
|
||||||
|
@ -64,13 +63,13 @@ func init() {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
if appPath, err = exePath(); err != nil {
|
if appPath, err = exePath(); err != nil {
|
||||||
qlog.Fatalf("publickey.init(fail to get app path): %v\n", err)
|
log.Fatal("publickey.init(fail to get app path): %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine and create .ssh path.
|
// Determine and create .ssh path.
|
||||||
SshPath = filepath.Join(homeDir(), ".ssh")
|
SshPath = filepath.Join(homeDir(), ".ssh")
|
||||||
if err = os.MkdirAll(SshPath, os.ModePerm); err != nil {
|
if err = os.MkdirAll(SshPath, os.ModePerm); err != nil {
|
||||||
qlog.Fatalf("publickey.init(fail to create SshPath(%s)): %v\n", SshPath, err)
|
log.Fatal("publickey.init(fail to create SshPath(%s)): %v\n", SshPath, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,18 +9,17 @@ import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
qlog "github.com/qiniu/log"
|
|
||||||
|
|
||||||
"github.com/gogits/git"
|
"github.com/gogits/git"
|
||||||
|
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
|
"github.com/gogits/gogs/modules/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName string, userId int64) {
|
func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName string, userId int64) {
|
||||||
isNew := strings.HasPrefix(oldCommitId, "0000000")
|
isNew := strings.HasPrefix(oldCommitId, "0000000")
|
||||||
if isNew &&
|
if isNew &&
|
||||||
strings.HasPrefix(newCommitId, "0000000") {
|
strings.HasPrefix(newCommitId, "0000000") {
|
||||||
qlog.Fatal("old rev and new rev both 000000")
|
log.GitLogger.Fatal("old rev and new rev both 000000")
|
||||||
}
|
}
|
||||||
|
|
||||||
f := RepoPath(repoUserName, repoName)
|
f := RepoPath(repoUserName, repoName)
|
||||||
|
@ -31,18 +30,18 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName
|
||||||
|
|
||||||
isDel := strings.HasPrefix(newCommitId, "0000000")
|
isDel := strings.HasPrefix(newCommitId, "0000000")
|
||||||
if isDel {
|
if isDel {
|
||||||
qlog.Info("del rev", refName, "from", userName+"/"+repoName+".git", "by", userId)
|
log.GitLogger.Info("del rev", refName, "from", userName+"/"+repoName+".git", "by", userId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
repo, err := git.OpenRepository(f)
|
repo, err := git.OpenRepository(f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
qlog.Fatalf("runUpdate.Open repoId: %v", err)
|
log.GitLogger.Fatal("runUpdate.Open repoId: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
newCommit, err := repo.GetCommit(newCommitId)
|
newCommit, err := repo.GetCommit(newCommitId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
qlog.Fatalf("runUpdate GetCommit of newCommitId: %v", err)
|
log.GitLogger.Fatal("runUpdate GetCommit of newCommitId: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,28 +50,28 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName
|
||||||
if isNew {
|
if isNew {
|
||||||
l, err = newCommit.CommitsBefore()
|
l, err = newCommit.CommitsBefore()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
qlog.Fatalf("Find CommitsBefore erro: %v", err)
|
log.GitLogger.Fatal("Find CommitsBefore erro: %v", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
l, err = newCommit.CommitsBeforeUntil(oldCommitId)
|
l, err = newCommit.CommitsBeforeUntil(oldCommitId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
qlog.Fatalf("Find CommitsBeforeUntil erro: %v", err)
|
log.GitLogger.Fatal("Find CommitsBeforeUntil erro: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
qlog.Fatalf("runUpdate.Commit repoId: %v", err)
|
log.GitLogger.Fatal("runUpdate.Commit repoId: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ru, err := GetUserByName(repoUserName)
|
ru, err := GetUserByName(repoUserName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
qlog.Fatalf("runUpdate.GetUserByName: %v", err)
|
log.GitLogger.Fatal("runUpdate.GetUserByName: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
repos, err := GetRepositoryByName(ru.Id, repoName)
|
repos, err := GetRepositoryByName(ru.Id, repoName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
qlog.Fatalf("runUpdate.GetRepositoryByName userId: %v", err)
|
log.GitLogger.Fatal("runUpdate.GetRepositoryByName userId: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
commits := make([]*base.PushCommit, 0)
|
commits := make([]*base.PushCommit, 0)
|
||||||
|
@ -96,6 +95,6 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName
|
||||||
//commits = append(commits, []string{lastCommit.Id().String(), lastCommit.Message()})
|
//commits = append(commits, []string{lastCommit.Id().String(), lastCommit.Message()})
|
||||||
if err = CommitRepoAction(userId, ru.Id, userName, actEmail,
|
if err = CommitRepoAction(userId, ru.Id, userName, actEmail,
|
||||||
repos.Id, repoUserName, repoName, refName, &base.PushCommits{l.Len(), commits}); err != nil {
|
repos.Id, repoUserName, repoName, refName, &base.PushCommits{l.Len(), commits}); err != nil {
|
||||||
qlog.Fatalf("runUpdate.models.CommitRepoAction: %s/%s:%v", repoUserName, repoName, err)
|
log.GitLogger.Fatal("runUpdate.models.CommitRepoAction: %s/%s:%v", repoUserName, repoName, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,16 @@
|
||||||
package log
|
package log
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
|
|
||||||
"github.com/gogits/logs"
|
"github.com/gogits/logs"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
loggers []*logs.BeeLogger
|
loggers []*logs.BeeLogger
|
||||||
|
GitLogger *logs.BeeLogger
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -38,6 +41,12 @@ func NewLogger(bufLen int64, mode, config string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewGitLogger(logPath string) {
|
||||||
|
os.MkdirAll(path.Dir(logPath), os.ModePerm)
|
||||||
|
GitLogger = logs.NewLogger(0)
|
||||||
|
GitLogger.SetLogger("file", fmt.Sprintf(`{"level":0,"filename":"%s","rotate":false}`, logPath))
|
||||||
|
}
|
||||||
|
|
||||||
func Trace(format string, v ...interface{}) {
|
func Trace(format string, v ...interface{}) {
|
||||||
for _, logger := range loggers {
|
for _, logger := range loggers {
|
||||||
logger.Trace(format, v...)
|
logger.Trace(format, v...)
|
||||||
|
|
|
@ -60,6 +60,7 @@ func GlobalInit() {
|
||||||
|
|
||||||
models.HasEngine = true
|
models.HasEngine = true
|
||||||
cron.NewCronContext()
|
cron.NewCronContext()
|
||||||
|
log.NewGitLogger(path.Join(setting.LogRootPath, "http.log"))
|
||||||
}
|
}
|
||||||
if models.EnableSQLite3 {
|
if models.EnableSQLite3 {
|
||||||
log.Info("SQLite3 Enabled")
|
log.Info("SQLite3 Enabled")
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
@ -22,6 +21,7 @@ import (
|
||||||
|
|
||||||
"github.com/go-martini/martini"
|
"github.com/go-martini/martini"
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
|
"github.com/gogits/gogs/modules/log"
|
||||||
"github.com/gogits/gogs/modules/middleware"
|
"github.com/gogits/gogs/modules/middleware"
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
@ -190,7 +190,7 @@ var routes = []route{
|
||||||
// Request handling function
|
// Request handling function
|
||||||
func HttpBackend(config *Config) http.HandlerFunc {
|
func HttpBackend(config *Config) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
//log.Printf("%s %s %s %s", r.RemoteAddr, r.Method, r.URL.Path, r.Proto)
|
//log.GitLogger.Printf("%s %s %s %s", r.RemoteAddr, r.Method, r.URL.Path, r.Proto)
|
||||||
for _, route := range routes {
|
for _, route := range routes {
|
||||||
if m := route.cr.FindStringSubmatch(r.URL.Path); m != nil {
|
if m := route.cr.FindStringSubmatch(r.URL.Path); m != nil {
|
||||||
if route.method != r.Method {
|
if route.method != r.Method {
|
||||||
|
@ -202,7 +202,7 @@ func HttpBackend(config *Config) http.HandlerFunc {
|
||||||
dir, err := getGitDir(config, m[1])
|
dir, err := getGitDir(config, m[1])
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err)
|
log.GitLogger.Error(err.Error())
|
||||||
renderNotFound(w)
|
renderNotFound(w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -246,19 +246,19 @@ func serviceRpc(rpc string, hr handler) {
|
||||||
cmd.Dir = dir
|
cmd.Dir = dir
|
||||||
in, err := cmd.StdinPipe()
|
in, err := cmd.StdinPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err)
|
log.GitLogger.Error(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
stdout, err := cmd.StdoutPipe()
|
stdout, err := cmd.StdoutPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err)
|
log.GitLogger.Error(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = cmd.Start()
|
err = cmd.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err)
|
log.GitLogger.Error(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ func getGitDir(config *Config, fPath string) (string, error) {
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err)
|
log.GitLogger.Error(err.Error())
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,7 +422,7 @@ func gitCommand(gitBinPath, dir string, args ...string) []byte {
|
||||||
out, err := command.Output()
|
out, err := command.Output()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err)
|
log.GitLogger.Error(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
Loading…
Reference in a new issue