12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- // Copyright 2019 github.com. All rights reserved.
- // Use of this source code is governed by github.com.
- package utils
- import (
- "context"
- "encoding/json"
- "smart-enterprise-management-gateway/pb"
- "smart-enterprise-management-gateway/pb/v1"
- "github.com/jaryhe/gopkgs/logger"
- "go.uber.org/zap"
- "smart-enterprise-management-gateway/consts"
- )
- func LogWrite(operation string, uid int64, name string, detail string, er error, projectId int64) {
- go func() {
- rpcReq := &v1.LogAddRequest{
- Operation: operation,
- Uid: uid,
- Result: 1,
- Detail: detail,
- Username: name,
- Type:consts.LogTypeCompany,
- ProjectId:projectId,
- }
- if er != nil {
- rpcReq.Result = 2
- }
- _, err := pb.OperationLog.LogAdd(context.Background(), rpcReq)
- if err != nil {
- s, _ := json.Marshal(rpcReq)
- logger.Error("func",
- zap.String("call", "LogAdd"),
- zap.String("params", string(s)),
- zap.String("error", err.Error()))
- return
- }
- }()
- }
|