mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-16 10:28:24 -07:00
add log
This commit is contained in:
parent
c0649c861c
commit
a80603727d
16
serve.go
16
serve.go
@ -48,6 +48,7 @@ gogs serv provide access auth for repositories`,
|
|||||||
func init() {
|
func init() {
|
||||||
os.MkdirAll("log", os.ModePerm)
|
os.MkdirAll("log", os.ModePerm)
|
||||||
log.NewLogger(10000, "file", fmt.Sprintf(`{"filename":"%s"}`, "log/serv.log"))
|
log.NewLogger(10000, "file", fmt.Sprintf(`{"filename":"%s"}`, "log/serv.log"))
|
||||||
|
log.Info("start logging...")
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseCmd(cmd string) (string, string) {
|
func parseCmd(cmd string) (string, string) {
|
||||||
@ -124,6 +125,7 @@ func runServ(k *cli.Context) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
println("Get repository error:", err)
|
println("Get repository error:", err)
|
||||||
|
log.Error(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -134,6 +136,7 @@ func runServ(k *cli.Context) {
|
|||||||
has, err := models.HasAccess(user.Name, repoName, models.AU_WRITABLE)
|
has, err := models.HasAccess(user.Name, repoName, models.AU_WRITABLE)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println("Inernel error:", err)
|
println("Inernel error:", err)
|
||||||
|
log.Error(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !has {
|
if !has {
|
||||||
@ -144,12 +147,14 @@ func runServ(k *cli.Context) {
|
|||||||
has, err := models.HasAccess(user.Name, repoName, models.AU_READABLE)
|
has, err := models.HasAccess(user.Name, repoName, models.AU_READABLE)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println("Inernel error")
|
println("Inernel error")
|
||||||
|
log.Error(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !has {
|
if !has {
|
||||||
has, err = models.HasAccess(user.Name, repoName, models.AU_WRITABLE)
|
has, err = models.HasAccess(user.Name, repoName, models.AU_WRITABLE)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println("Inernel error")
|
println("Inernel error")
|
||||||
|
log.Error(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -169,6 +174,7 @@ func runServ(k *cli.Context) {
|
|||||||
_, err = models.CreateRepository(user, repoName, "", "", "", false, true)
|
_, err = models.CreateRepository(user, repoName, "", "", "", false, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println("Create repository failed")
|
println("Create repository failed")
|
||||||
|
log.Error(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -177,12 +183,14 @@ func runServ(k *cli.Context) {
|
|||||||
rep, err = git.OpenRepository(repoPath)
|
rep, err = git.OpenRepository(repoPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println(err.Error())
|
println(err.Error())
|
||||||
|
log.Error(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
refs, err := rep.AllReferencesMap()
|
refs, err := rep.AllReferencesMap()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println(err.Error())
|
println(err.Error())
|
||||||
|
log.Error(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,6 +207,7 @@ func runServ(k *cli.Context) {
|
|||||||
|
|
||||||
if err = gitcmd.Run(); err != nil {
|
if err = gitcmd.Run(); err != nil {
|
||||||
println("execute command error:", err.Error())
|
println("execute command error:", err.Error())
|
||||||
|
log.Error(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,15 +247,17 @@ func runServ(k *cli.Context) {
|
|||||||
refs, err = rep.AllReferencesMap()
|
refs, err = rep.AllReferencesMap()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println(err.Error())
|
println(err.Error())
|
||||||
|
log.Error(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if ref, ok = refs[refname]; !ok {
|
if ref, ok = refs[refname]; !ok {
|
||||||
log.Trace("unknow reference name -", refname, "-", b.String())
|
log.Error("unknow reference name -", refname, "-", b.String())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
l, err = ref.AllCommits()
|
l, err = ref.AllCommits()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println(err.Error())
|
println(err.Error())
|
||||||
|
log.Error(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -256,12 +267,14 @@ func runServ(k *cli.Context) {
|
|||||||
last, err = ref.LastCommit()
|
last, err = ref.LastCommit()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println(err.Error())
|
println(err.Error())
|
||||||
|
log.Error(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ref2, err := rep.LookupReference(ref.Name)
|
ref2, err := rep.LookupReference(ref.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println(err.Error())
|
println(err.Error())
|
||||||
|
log.Error(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,6 +282,7 @@ func runServ(k *cli.Context) {
|
|||||||
before, err := ref2.LastCommit()
|
before, err := ref2.LastCommit()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println(err.Error())
|
println(err.Error())
|
||||||
|
log.Error(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//log.Info("----", before.Id(), "-----", last.Id())
|
//log.Info("----", before.Id(), "-----", last.Id())
|
||||||
|
Loading…
Reference in New Issue
Block a user