Browse Source

add msgid in log

tags/v1.21.12.1
lewis 4 years ago
parent
commit
488ebee844
3 changed files with 11 additions and 11 deletions
  1. +9
    -9
      routers/repo/blockchain.go
  2. +1
    -1
      routers/repo/cloudbrain.go
  3. +1
    -1
      routers/routes/routes.go

+ 9
- 9
routers/repo/blockchain.go View File

@@ -28,14 +28,14 @@ const (
func BlockChainIndex(ctx *context.Context) {
repo := ctx.Repo.Repository
if repo.ContractAddress == "" || ctx.User.PublicKey == "" {
log.Error("the repo(%d) or the user(%d) has not been initialized in block_chain", repo.RepoID, ctx.User.ID)
log.Error("the repo(%d) or the user(%d) has not been initialized in block_chain", repo.RepoID, ctx.User.ID, ctx.Data["msgID"])
ctx.HTML(http.StatusInternalServerError, tplBlockChainIndex)
return
}

res, err := blockchain.GetBalance(repo.ContractAddress, ctx.User.PublicKey)
if err != nil {
log.Error("GetBalance(%s) failed:%v", ctx.User.PublicKey, err)
log.Error("GetBalance(%s) failed:%s", ctx.User.PublicKey, err, ctx.Data["msgID"])
ctx.HTML(http.StatusInternalServerError, tplBlockChainIndex)
return
}
@@ -52,7 +52,7 @@ func HandleBlockChainInitNotify(ctx *context.Context) {

repo, err := models.GetRepositoryByID(req.RepoId)
if err != nil {
log.Error("GetRepositoryByID failed:", err.Error())
log.Error("GetRepositoryByID failed:%v", err.Error(), ctx.Data["msgID"])
ctx.JSON(200, map[string]string{
"code": "-1",
"message": "internal error",
@@ -61,7 +61,7 @@ func HandleBlockChainInitNotify(ctx *context.Context) {
}

if repo.BlockChainStatus == models.RepoBlockChainSuccess && len(repo.ContractAddress) != 0 {
log.Error("the repo has been RepoBlockChainSuccess:", req.RepoId)
log.Error("the repo has been RepoBlockChainSuccess:%d", req.RepoId, ctx.Data["msgID"])
ctx.JSON(200, map[string]string{
"code": "-1",
"message": "the repo has been RepoBlockChainSuccess",
@@ -73,7 +73,7 @@ func HandleBlockChainInitNotify(ctx *context.Context) {
repo.ContractAddress = req.ContractAddress

if err = models.UpdateRepositoryCols(repo, "block_chain_status", "contract_address"); err != nil {
log.Error("UpdateRepositoryCols failed:", err.Error())
log.Error("UpdateRepositoryCols failed:%v", err.Error(), ctx.Data["msgID"])
ctx.JSON(200, map[string]string{
"code": "-1",
"message": "internal error",
@@ -91,7 +91,7 @@ func HandleBlockChainCommitNotify(ctx *context.Context) {
var req BlockChainCommitNotify
data, _ := ctx.Req.Body().Bytes()
if err := json.Unmarshal(data, &req); err != nil {
log.Error("json.Unmarshal failed:", err.Error())
log.Error("json.Unmarshal failed:%v", err.Error(), ctx.Data["msgID"])
ctx.JSON(200, map[string]string{
"code": "-1",
"message": "response data error",
@@ -101,7 +101,7 @@ func HandleBlockChainCommitNotify(ctx *context.Context) {

blockChain, err := models.GetBlockChainByCommitID(req.CommitID)
if err != nil {
log.Error("GetRepositoryByID failed:", err.Error())
log.Error("GetRepositoryByID failed:%v", err.Error(), ctx.Data["msgID"])
ctx.JSON(200, map[string]string{
"code": "-1",
"message": "internal error",
@@ -110,7 +110,7 @@ func HandleBlockChainCommitNotify(ctx *context.Context) {
}

if blockChain.Status == models.BlockChainCommitSuccess {
log.Error("the commit has been BlockChainCommitReady:", blockChain.RepoID)
log.Error("the commit has been BlockChainCommitReady:%s", blockChain.RepoID, ctx.Data["msgID"])
ctx.JSON(200, map[string]string{
"code": "-1",
"message": "the commit has been BlockChainCommitReady",
@@ -122,7 +122,7 @@ func HandleBlockChainCommitNotify(ctx *context.Context) {
blockChain.TransactionHash = req.TransactionHash

if err = models.UpdateBlockChainCols(blockChain, "status", "transaction_hash"); err != nil {
log.Error("UpdateBlockChainCols failed:", err.Error())
log.Error("UpdateBlockChainCols failed:%v", err.Error(), ctx.Data["msgID"])
ctx.JSON(200, map[string]string{
"code": "-1",
"message": "internal error",


+ 1
- 1
routers/repo/cloudbrain.go View File

@@ -417,7 +417,7 @@ func GetRate(ctx *context.Context) {

func downloadCode(repo *models.Repository, codePath string) error {
if err := git.Clone(repo.RepoPath(), codePath, git.CloneRepoOptions{}); err != nil {
log.Error("Failed to clone repository: %s (%v)", repo.FullName(), err, ctx.Data["msgID"])
log.Error("Failed to clone repository: %s (%v)", repo.FullName(), err)
return err
}



+ 1
- 1
routers/routes/routes.go View File

@@ -108,7 +108,7 @@ func RouterHandler(level log.Level) func(ctx *macaron.Context) {
}
}

// SetLogMsgID set msgID in log
// SetLogMsgID set msgID in Context
func SetLogMsgID() func(ctx *macaron.Context) {
return func(ctx *macaron.Context) {
start := time.Now()


Loading…
Cancel
Save