本文整理汇总了Golang中github.com/astaxie/beego/logs.BeeLogger类的典型用法代码示例。如果您正苦于以下问题:Golang BeeLogger类的具体用法?Golang BeeLogger怎么用?Golang BeeLogger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BeeLogger类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: GetTagsListV2Handler
func GetTagsListV2Handler(ctx *macaron.Context, log *logs.BeeLogger) (int, []byte) {
namespace := ctx.Params(":namespace")
repository := ctx.Params(":repository")
r := new(models.Repository)
if _, err := r.Get(namespace, repository); err != nil {
log.Error("[REGISTRY API V2] Failed to get repository %v/%v: %v", namespace, repository, err.Error())
result, _ := json.Marshal(map[string]string{"message": "Failed to get repository"})
return http.StatusBadRequest, result
}
data := map[string]interface{}{}
data["name"] = fmt.Sprintf("%s/%s", namespace, repository)
tagslist := r.GetTagslist()
if len(tagslist) <= 0 {
log.Error("[REGISTRY API V2] Repository %v/%v tags list is empty", namespace, repository)
result, _ := json.Marshal(map[string]string{"message": "Tags list is empty"})
return http.StatusNotFound, result
}
data["tags"] = tagslist
result, _ := json.Marshal(data)
return http.StatusOK, result
}
开发者ID:yanghongkjxy,项目名称:dockyard,代码行数:28,代码来源:manifests.go
示例2: GetTagsListV2Handler
func GetTagsListV2Handler(ctx *macaron.Context, log *logs.BeeLogger) (int, []byte) {
namespace := ctx.Params(":namespace")
repository := ctx.Params(":repository")
r := new(models.Repository)
if has, _, err := r.Has(namespace, repository); err != nil || has == false {
log.Error("[REGISTRY API V2] Repository not found: %v", repository)
result, _ := json.Marshal(map[string]string{"message": "Repository not found"})
return http.StatusNotFound, result
}
data := map[string]interface{}{}
tags := []string{}
data["name"] = fmt.Sprintf("%s/%s", namespace, repository)
for _, value := range r.Tags {
t := new(models.Tag)
if err := t.GetByKey(value); err != nil {
log.Error("[REGISTRY API V2] Tag not found: %v", err.Error())
result, _ := json.Marshal(map[string]string{"message": "Tag not found"})
return http.StatusNotFound, result
}
tags = append(tags, t.Name)
}
data["tags"] = tags
result, _ := json.Marshal(data)
return http.StatusOK, result
}
开发者ID:CodeJuan,项目名称:dockyard,代码行数:34,代码来源:manifests.go
示例3: DiscoveryACIHandler
// TBD: discovery template should be updated to keep in line with ACI
func DiscoveryACIHandler(ctx *macaron.Context, log *logs.BeeLogger) {
img := ctx.Params(":imagename")
t, err := template.ParseFiles("conf/acifetchtemplate.html")
if err != nil {
log.Error("[ACI API] Discovery parse template file failed: %v", err.Error())
ctx.Resp.WriteHeader(http.StatusInternalServerError)
fmt.Fprintf(ctx.Resp, fmt.Sprintf("%v", err))
return
}
err = t.Execute(ctx.Resp, struct {
Name string
ServerName string
ListenMode string
}{
Name: img,
ServerName: setting.Domains,
ListenMode: setting.ListenMode,
})
if err != nil {
log.Error("[ACI API] Discovery respond failed: %v", err.Error())
fmt.Fprintf(ctx.Resp, fmt.Sprintf("%v", err))
}
}
开发者ID:m20082008m,项目名称:dockyard,代码行数:26,代码来源:acidiscover.go
示例4: HeadBlobsV2Handler
func HeadBlobsV2Handler(ctx *macaron.Context, log *logs.BeeLogger) (int, []byte) {
digest := ctx.Params(":digest")
tarsum := strings.Split(digest, ":")[1]
ctx.Resp.Header().Set("Content-Type", "application/json; charset=utf-8")
i := new(models.Image)
if exists, err := i.Get(tarsum); err != nil {
log.Info("[REGISTRY API V2] Failed to get tarsum %v: %v", tarsum, err.Error())
result, _ := json.Marshal(map[string]string{"message": "Failed to get tarsum"})
return http.StatusBadRequest, result
} else if !exists {
log.Info("[REGISTRY API V2] Not found tarsum: %v", tarsum)
result, _ := json.Marshal(map[string]string{"message": "Not found tarsum"})
return http.StatusNotFound, result
}
ctx.Resp.Header().Set("Content-Type", "application/octet-stream")
ctx.Resp.Header().Set("Docker-Content-Digest", digest)
ctx.Resp.Header().Set("Content-Length", fmt.Sprint(i.Size))
result, _ := json.Marshal(map[string]string{})
return http.StatusOK, result
}
开发者ID:yanghongkjxy,项目名称:dockyard,代码行数:25,代码来源:blob.go
示例5: PutImageLayerv1Handler
func PutImageLayerv1Handler(ctx *macaron.Context, log *logs.BeeLogger) (int, []byte) {
imageId := ctx.Params(":imageId")
basePath := setting.ImagePath
imagePath := fmt.Sprintf("%v/images/%v", basePath, imageId)
layerfile := fmt.Sprintf("%v/images/%v/layer", basePath, imageId)
if !utils.IsDirExist(imagePath) {
os.MkdirAll(imagePath, os.ModePerm)
}
if _, err := os.Stat(layerfile); err == nil {
os.Remove(layerfile)
}
data, _ := ioutil.ReadAll(ctx.Req.Request.Body)
if err := ioutil.WriteFile(layerfile, data, 0777); err != nil {
log.Error("[REGISTRY API V1] Put Image Layer File Error: %v", err.Error())
result, _ := json.Marshal(map[string]string{"message": "Put Image Layer File Error"})
return http.StatusBadRequest, result
}
i := new(models.Image)
if err := i.PutLayer(imageId, layerfile, true, int64(len(data))); err != nil {
log.Error("[REGISTRY API V1] Put Image Layer File Data Error: %v", err.Error())
result, _ := json.Marshal(map[string]string{"message": "Put Image Layer File Data Error"})
return http.StatusBadRequest, result
}
result, _ := json.Marshal(map[string]string{})
return http.StatusOK, result
}
开发者ID:pombredanne,项目名称:wharf-1,代码行数:34,代码来源:image.go
示例6: GetImageJSONV1Handler
func GetImageJSONV1Handler(ctx *macaron.Context, log *logs.BeeLogger) (int, []byte) {
var jsonInfo string
var payload string
var err error
imageId := ctx.Params(":imageId")
i := new(models.Image)
if jsonInfo, err = i.GetJSON(imageId); err != nil {
log.Error("[REGISTRY API V1] Search Image JSON Error: %v", err.Error())
result, _ := json.Marshal(map[string]string{"message": "Search Image JSON Error"})
return http.StatusNotFound, result
}
if payload, err = i.GetChecksumPayload(imageId); err != nil {
log.Error("[REGISTRY API V1] Search Image Checksum Error: %v", err.Error())
result, _ := json.Marshal(map[string]string{"message": "Search Image Checksum Error"})
return http.StatusNotFound, result
}
ctx.Resp.Header().Set("X-Docker-Checksum-Payload", fmt.Sprintf("sha256:%v", payload))
ctx.Resp.Header().Set("X-Docker-Size", fmt.Sprint(i.Size))
ctx.Resp.Header().Set("Content-Length", fmt.Sprint(len(jsonInfo)))
return http.StatusOK, []byte(jsonInfo)
}
开发者ID:pombredanne,项目名称:wharf-1,代码行数:28,代码来源:image.go
示例7: GetManifestsV2Handler
func GetManifestsV2Handler(ctx *macaron.Context, log *logs.BeeLogger) (int, []byte) {
namespace := ctx.Params(":namespace")
repository := ctx.Params(":repository")
tag := ctx.Params(":tag")
t := new(models.Tag)
if exists, err := t.Get(namespace, repository, tag); err != nil || !exists {
log.Error("[REGISTRY API V2] Not found manifest: %v", err)
result, _ := json.Marshal(map[string]string{"message": "Not found manifest"})
return http.StatusNotFound, result
}
digest, err := signature.DigestManifest([]byte(t.Manifest))
if err != nil {
log.Error("[REGISTRY API V2] Failed to get manifest digest: %v", err.Error())
result, _ := json.Marshal(map[string]string{"message": "Failed to get manifest digest"})
return http.StatusInternalServerError, result
}
contenttype := []string{"", "application/json; charset=utf-8", "application/vnd.docker.distribution.manifest.v2+json"}
ctx.Resp.Header().Set("Content-Type", contenttype[t.Schema])
ctx.Resp.Header().Set("Docker-Content-Digest", digest)
ctx.Resp.Header().Set("Content-Length", fmt.Sprint(len(t.Manifest)))
return http.StatusOK, []byte(t.Manifest)
}
开发者ID:yanghongkjxy,项目名称:dockyard,代码行数:29,代码来源:manifests.go
示例8: InitiateUpload
func InitiateUpload(ctx *macaron.Context, log *logs.BeeLogger) (int, []byte) {
image := ctx.Params(":image")
if image == "" {
log.Error("[ACI API]Get image name failed")
result, _ := json.Marshal(map[string]string{"message": "Get image name failed"})
return http.StatusNotFound, result
}
uploadNum := strconv.Itoa(newUpload(image))
var prefix string
prefix = setting.ListenMode + "://" + setting.Domains + "/ac-push"
deets := initiateDetails{
ACIPushVersion: "0.0.1",
Multipart: false,
ManifestURL: prefix + "/manifest/" + uploadNum,
SignatureURL: prefix + "/signature/" + uploadNum,
ACIURL: prefix + "/aci/" + uploadNum,
CompletedURL: prefix + "/complete/" + uploadNum,
}
result, _ := json.Marshal(deets)
return http.StatusInternalServerError, result
}
开发者ID:m20082008m,项目名称:dockyard,代码行数:26,代码来源:acipush.go
示例9: GetFileInfo
func GetFileInfo(ctx *macaron.Context, log *logs.BeeLogger) (int, []byte) {
path := ctx.Req.Header.Get(headerPath)
log.Info("[OSS][getFileInfo] Path: %s", path)
result, err := metaDriver.GetFileMetaInfo(path, false)
if err != nil {
log.Error("[OSS][getFileInfo] get metainfo error, key: %s, error: %s", path, err)
return http.StatusInternalServerError, []byte(err.Error())
}
if len(result) == 0 {
log.Info("[OSS][getFileInfo] metainfo not exists, key: %s", path)
return http.StatusNotFound, []byte(err.Error())
}
resultMap := make(map[string]interface{})
resultMap["fragment-info"] = result
jsonResult, err := json.Marshal(resultMap)
if err != nil {
log.Error("json.Marshal error, key: %s, error: %s", path, err)
return http.StatusInternalServerError, []byte(err.Error())
}
log.Info("[getFileInfo] success, path: %s, result: %s", path, string(jsonResult))
return http.StatusOK, jsonResult
}
开发者ID:maquanyi,项目名称:dockyard,代码行数:26,代码来源:handler.go
示例10: UploadFile
func UploadFile(ctx *macaron.Context, log *logs.BeeLogger) (int, []byte) {
metaInfo, _, err := uploadFileReadParam(&ctx.Req.Header)
if err != nil {
log.Error("[OSS][uploadFile] read param error: %v", err)
return http.StatusBadRequest, []byte(err.Error())
}
data, err := ctx.Req.Body().Bytes()
if err != nil {
log.Error("[OSS]read request body error: %s", err)
return http.StatusBadRequest, []byte(err.Error())
}
statusCode, err := ossupload(data, metaInfo)
if err != nil {
log.Error("[OSS][uploadFile] upload error: %v", err)
return statusCode, []byte(err.Error())
}
if err = metaDriver.StoreMetaInfoV1(metaInfo); err != nil {
log.Error("[OSS]store metaInfo error: %s", err)
return http.StatusInternalServerError, []byte(err.Error())
}
log.Info("[OSS][postFile] success. path: %s, fragmentIndex: %d, bytesRange: %d-%d, isLast: %v", metaInfo.Path, metaInfo.Value.Index, metaInfo.Value.Start, metaInfo.Value.End, metaInfo.Value.IsLast)
return http.StatusOK, nil
}
开发者ID:maquanyi,项目名称:dockyard,代码行数:27,代码来源:handler.go
示例11: GetManifestsV2Handler
func GetManifestsV2Handler(ctx *macaron.Context, log *logs.BeeLogger) (int, []byte) {
t := new(models.Tag)
namespace := ctx.Params(":namespace")
repository := ctx.Params(":repository")
if err := t.Get(namespace, repository, ctx.Params(":tag")); err != nil {
log.Error("[REGISTRY API V2] Manifest not found: %v", err.Error())
result, _ := json.Marshal(map[string]string{"message": "Manifest not found"})
return http.StatusNotFound, result
}
digest, err := utils.DigestManifest([]byte(t.Manifest))
if err != nil {
log.Error("[REGISTRY API V2] Get manifest digest failed: %v", err.Error())
result, _ := json.Marshal(map[string]string{"message": "Get manifest digest failed"})
return http.StatusBadRequest, result
}
ctx.Resp.Header().Set("Content-Type", "application/json; charset=utf-8")
ctx.Resp.Header().Set("Docker-Content-Digest", digest)
ctx.Resp.Header().Set("Content-Length", fmt.Sprint(len(t.Manifest)))
return http.StatusOK, []byte(t.Manifest)
}
开发者ID:CodeJuan,项目名称:dockyard,代码行数:26,代码来源:manifests.go
示例12: PutRepositoryImagesV1Handler
func PutRepositoryImagesV1Handler(ctx *macaron.Context, log *logs.BeeLogger) (int, []byte) {
namespace := ctx.Params(":namespace")
repository := ctx.Params(":repository")
r := new(models.Repository)
if err := r.PutImages(namespace, repository); err != nil {
log.Error("[REGISTRY API V1] Put images error: %v", err.Error())
result, _ := json.Marshal(map[string]string{"message": "Put V1 images error"})
return http.StatusBadRequest, result
}
if ctx.Req.Header.Get("X-Docker-Token") == "true" {
username, _, _ := utils.DecodeBasicAuth(ctx.Req.Header.Get("Authorization"))
token := fmt.Sprintf("Token signature=%v,repository=\"%v/%v\",access=%v",
utils.MD5(username),
namespace,
repository,
"write")
ctx.Resp.Header().Set("X-Docker-Token", token)
ctx.Resp.Header().Set("WWW-Authenticate", token)
}
result, _ := json.Marshal(map[string]string{})
return http.StatusNoContent, result
}
开发者ID:CodeJuan,项目名称:dockyard,代码行数:27,代码来源:repository.go
示例13: PutRepositoryV1Handler
func PutRepositoryV1Handler(ctx *macaron.Context, log *logs.BeeLogger) (int, []byte) {
username, _, _ := utils.DecodeBasicAuth(ctx.Req.Header.Get("Authorization"))
namespace := ctx.Params(":namespace")
repository := ctx.Params(":repository")
body, err := ctx.Req.Body().String()
if err != nil {
log.Error("[REGISTRY API V1] Get request body error: %v", err.Error())
result, _ := json.Marshal(map[string]string{"message": "Put V1 repository failed,request body is empty"})
return http.StatusBadRequest, result
}
r := new(models.Repository)
if err := r.Put(namespace, repository, body, ctx.Req.Header.Get("User-Agent"), setting.APIVERSION_V1); err != nil {
log.Error("[REGISTRY API V1] Put repository error: %v", err.Error())
result, _ := json.Marshal(map[string]string{"message": err.Error()})
return http.StatusBadRequest, result
}
if ctx.Req.Header.Get("X-Docker-Token") == "true" {
token := fmt.Sprintf("Token signature=%v,repository=\"%v/%v\",access=%v",
utils.MD5(username),
namespace,
repository,
"write")
ctx.Resp.Header().Set("X-Docker-Token", token)
ctx.Resp.Header().Set("WWW-Authenticate", token)
}
result, _ := json.Marshal(map[string]string{})
return http.StatusOK, result
}
开发者ID:CodeJuan,项目名称:dockyard,代码行数:35,代码来源:repository.go
示例14: GetPubkeys
func GetPubkeys(ctx *macaron.Context, log *logs.BeeLogger) (int, []byte) {
var pubkey []byte
var err error
pubkeypath := setting.ImagePath + "/acpool/" + "pubkeys.gpg"
if pubkey, err = ioutil.ReadFile(pubkeypath); err != nil {
log.Error("[ACI API] Get pubkey file failed: %v", err.Error())
result, _ := json.Marshal(map[string]string{"message": "Get pubkey file failed"})
return http.StatusNotFound, result
}
return http.StatusOK, pubkey
}
开发者ID:m20082008m,项目名称:dockyard,代码行数:12,代码来源:acipush.go
示例15: newLogger
// 初始化日志模块
func newLogger(config LogConfig, isDaily bool) (*logs.BeeLogger, error) {
var logger *logs.BeeLogger
var configInner logConfigInner
if config.Filename == "" {
return logger, errors.New("文件名不能为空哈")
}
configInner.Filename = config.Filename
if config.Maxlines == 0 {
config.Maxlines = 1000000
}
configInner.Maxlines = config.Maxlines
configInner.Daily = isDaily
if config.Maxdays == 0 {
config.Maxdays = 7
}
configInner.Maxdays = config.Maxdays
logLevel := map[string]int{
"error": logs.LevelError,
"warn": logs.LevelWarning,
"info": logs.LevelInformational,
}
var logLevelInt int
if config.Level == "" {
logLevelInt = logs.LevelInformational
} else {
var ok bool
logLevelInt, ok = logLevel[config.Level]
if ok == false {
return logger, errors.New("日志等级设置不正确")
}
}
configInner.Level = logLevelInt
configInner.Rotate = true
// 普通日志
logger = logs.NewLogger(10000)
logConfigString, err := json.Marshal(&configInner)
if err != nil {
return logger, err
}
err = logger.SetLogger("file", string(logConfigString))
if err != nil {
return logger, err
}
return logger, nil
}
开发者ID:fishedee,项目名称:reproxy,代码行数:54,代码来源:log.go
示例16: ReceiveChunkserverInfo
func ReceiveChunkserverInfo(ctx *macaron.Context, log *logs.BeeLogger) (int, []byte) {
header := ctx.Req.Header
nodeip := header.Get("nodeip")
nodeport := header.Get("nodeport")
groupid := header.Get("groupid")
stderr := header.Get("stderr")
stdout := header.Get("stdout")
log.Info("[OSS]Chunkserver %s:%s groupid:%s start error", nodeip, nodeport, groupid)
log.Info("[OSS]STDOUT:%s", stdout)
log.Info("[OSS]STDERR:%s", stderr)
return http.StatusOK, []byte("information recieced")
}
开发者ID:yanghongkjxy,项目名称:dockyard,代码行数:12,代码来源:service.go
示例17: ReceiveAciUpload
func ReceiveAciUpload(ctx *macaron.Context, log *logs.BeeLogger) (int, []byte) {
num, err := strconv.Atoi(ctx.Params(":num"))
if err != nil {
fmt.Fprintf(os.Stderr, "%v", err)
result, _ := json.Marshal(map[string]string{})
return http.StatusNotFound, result
}
up := getUpload(num)
if up == nil {
fmt.Fprintf(os.Stderr, "%v", err)
result, _ := json.Marshal(map[string]string{})
return http.StatusNotFound, result
}
_, err = os.Stat(up.Image)
if err == nil {
log.Error("[ACI API]item already uploaded")
result, _ := json.Marshal(map[string]string{"message": "item already uploaded"})
return http.StatusConflict, result
} else if !os.IsNotExist(err) {
fmt.Fprintf(os.Stderr, "%v", err)
result, _ := json.Marshal(map[string]string{})
return http.StatusInternalServerError, result
}
aci, err := os.OpenFile(tmpACIPath(num),
os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
if err != nil {
fmt.Fprintf(os.Stderr, "%v", err)
result, _ := json.Marshal(map[string]string{})
return http.StatusInternalServerError, result
}
defer aci.Close()
_, err = io.Copy(aci, ctx.Req.Request.Body)
if err != nil {
fmt.Fprintf(os.Stderr, "%v", err)
result, _ := json.Marshal(map[string]string{})
return http.StatusInternalServerError, result
}
err = gotACI(num)
if err != nil {
fmt.Fprintf(os.Stderr, "%v", err)
result, _ := json.Marshal(map[string]string{})
return http.StatusInternalServerError, result
}
result, _ := json.Marshal(map[string]string{})
return http.StatusOK, result
}
开发者ID:m20082008m,项目名称:dockyard,代码行数:51,代码来源:acipush.go
示例18: PutImageChecksumV1Handler
func PutImageChecksumV1Handler(ctx *macaron.Context, log *logs.BeeLogger) (int, []byte) {
imageId := ctx.Params(":imageId")
checksum := strings.Split(ctx.Req.Header.Get("X-Docker-Checksum"), ":")[1]
payload := strings.Split(ctx.Req.Header.Get("X-Docker-Checksum-Payload"), ":")[1]
log.Debug("[REGISTRY API V1] Image Checksum : %v", checksum)
log.Debug("[REGISTRY API V1] Image Payload: %v", payload)
i := new(models.Image)
if err := i.PutChecksum(imageId, checksum, true, payload); err != nil {
log.Error("[REGISTRY API V1] Put Image Checksum & Payload Error: %v", err.Error())
result, _ := json.Marshal(map[string]string{"message": "Put Image Checksum & Payload Error"})
return http.StatusBadRequest, result
}
if err := i.PutAncestry(imageId); err != nil {
log.Error("[REGISTRY API V1] Put Image Ancestry Error: %v", err.Error())
result, _ := json.Marshal(map[string]string{"message": "Put Image Ancestry Error"})
return http.StatusBadRequest, result
}
result, _ := json.Marshal(map[string]string{})
return http.StatusOK, result
}
开发者ID:pombredanne,项目名称:wharf-1,代码行数:27,代码来源:image.go
示例19: GetImageAncestryV1Handler
func GetImageAncestryV1Handler(ctx *macaron.Context, log *logs.BeeLogger) (int, []byte) {
imageId := ctx.Params(":imageId")
i := new(models.Image)
if _, err := i.Get(imageId); err != nil {
log.Error("[REGISTRY API V1] Failed to get image %v ancestry: %v", imageId, err.Error())
result, _ := json.Marshal(map[string]string{"message": "Failed to get image ancestry"})
return http.StatusBadRequest, result
}
ctx.Resp.Header().Set("Content-Length", fmt.Sprint(len(i.Ancestry)))
return http.StatusOK, []byte(i.Ancestry)
}
开发者ID:maquanyi,项目名称:dockyard,代码行数:15,代码来源:image.go
示例20: PutManifestHandler
func PutManifestHandler(ctx *macaron.Context, log *logs.BeeLogger) (int, []byte) {
imageId := ctx.Params(":imageId")
manipath := module.GetManifestPath(imageId, setting.APIVERSION_ACI)
data, _ := ctx.Req.Body().Bytes()
if err := ioutil.WriteFile(manipath, data, 0777); err != nil {
//Temporary directory would be deleted in PostCompleteHandler
log.Error("[ACI API] Failed to save manifest file: %v", err.Error())
result, _ := json.Marshal(map[string]string{"message": "Failed to save manifest"})
return http.StatusInternalServerError, result
}
result, _ := json.Marshal(map[string]string{})
return http.StatusOK, result
}
开发者ID:yanghongkjxy,项目名称:dockyard,代码行数:16,代码来源:aci.go
注:本文中的github.com/astaxie/beego/logs.BeeLogger类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论