// Copyright 2019 github.com. All rights reserved. // Use of this source code is governed by github.com. package utils import ( "context" "encoding/json" "smart-site-management-gateway/pb" "smart-site-management-gateway/pb/v1" "github.com/jaryhe/gopkgs/logger" "go.uber.org/zap" "smart-site-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.LogTypeProject, 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 } }() }