(requestID, runtimeID, userID, funcName, funcVer, fpath, logtype string)
| 98 | ) |
| 99 | |
| 100 | func getUserLogPath(requestID, runtimeID, userID, funcName, funcVer, fpath, logtype string) string { |
| 101 | var logpath string |
| 102 | |
| 103 | if logtype != string(UserLogTypePlain) { |
| 104 | if _, err := os.Stat(fpath); err != nil { |
| 105 | return "" |
| 106 | } |
| 107 | logpath = path.Join(fpath, userLogSingleFile) |
| 108 | return logpath |
| 109 | } |
| 110 | |
| 111 | logpath = path.Join(fpath, fmt.Sprintf("%s.%s.%s", userID, funcName, strings.TrimLeft(funcVer, "$"))) |
| 112 | _, err := os.Stat(logpath) |
| 113 | if err != nil { |
| 114 | if os.IsNotExist(err) { |
| 115 | err = os.MkdirAll(logpath, 0755) |
| 116 | if err != nil { |
| 117 | logs.V(4).Warn(fmt.Sprintf("recvlog %s create dir %s failed: %s", |
| 118 | runtimeID, logpath, err.Error()), zap.String("request_id", requestID)) |
| 119 | logpath = "" |
| 120 | } |
| 121 | } else { |
| 122 | logs.V(4).Warn(fmt.Sprintf("recvlog %s stat dir %s failed: %s", |
| 123 | runtimeID, logpath, err.Error()), zap.String("request_id", requestID)) |
| 124 | logpath = "" |
| 125 | } |
| 126 | } |
| 127 | if len(logpath) > 0 { |
| 128 | logpath = path.Join(logpath, fmt.Sprintf("%d.%s", time.Now().UnixNano(), requestID)) |
| 129 | _, err = os.Stat(logpath) |
| 130 | if err == nil { |
| 131 | logs.V(4).Warn(fmt.Sprintf("recvlog %s logfile %s already exist", |
| 132 | runtimeID, logpath), zap.String("request_id", requestID)) |
| 133 | logpath = "" |
| 134 | } |
| 135 | } |
| 136 | return logpath |
| 137 | } |
| 138 | |
| 139 | type LogStatStoreParameter struct { |
| 140 | RequestID string |
no test coverage detected