当前位置: 首页>>代码示例>>Golang>>正文


Golang logrus.Warnln函数代码示例

本文整理汇总了Golang中github.com/Sirupsen/logrus.Warnln函数的典型用法代码示例。如果您正苦于以下问题:Golang Warnln函数的具体用法?Golang Warnln怎么用?Golang Warnln使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Warnln函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: cpFile

func cpFile(src, dst string) error {
	s, err := os.Open(src)
	if err != nil {
		log.Warnln("sensor: monitor - cp - error opening source file =>", src)
		return err
	}
	defer s.Close()

	dstDir := utils.FileDir(dst)
	err = os.MkdirAll(dstDir, 0777)
	if err != nil {
		log.Warnln("sensor: monitor - dir error =>", err)
	}

	d, err := os.Create(dst)
	if err != nil {
		log.Warnln("sensor: monitor - cp - error opening dst file =>", dst)
		return err
	}

	srcFileInfo, err := s.Stat()
	if err == nil {
		d.Chmod(srcFileInfo.Mode())
	}

	if _, err := io.Copy(d, s); err != nil {
		d.Close()
		return err
	}
	return d.Close()
}
开发者ID:BenHall,项目名称:docker-slim,代码行数:31,代码来源:artifacts.go

示例2: mapRoutes

func (s *Server) mapRoutes() {
	r := s.router

	cwd, _ := os.Getwd()
	staticPath := path.Join(cwd, s.config.static)
	var staticURL string
	var staticBundleURL string
	if s.config.hot {
		// create the prefix necessary to load bundles from hmr server
		staticBundleURL = s.config.hmr
		staticURL = s.config.address
	} else {
		// ensure bundles exist if not hot reloading
		ensureBundles(s.config.js, s.config.style, staticPath)
		if s.config.dev {
			staticBundleURL = s.config.address
			staticURL = s.config.address
		} else {
			staticBundleURL = s.config.serve
			staticURL = s.config.serve
		}
	}
	staticBundleURL = path.Join(staticBundleURL, s.config.static)
	staticURL = path.Join(staticURL, s.config.static)
	log.Warnln(s.config.js)
	log.Warnln(s.config.static)
	// create the default app (the route used to serve the client app)
	app := defaultApp{}
	// load template
	f, err := os.Open(s.config.template)
	if err != nil {
		log.Errorln("Tpl err", err)
		os.Exit(1)
	}
	defer f.Close()
	b, err := ioutil.ReadAll(f)
	if err != nil {
		log.Errorln("Tpl read err", err)
		os.Exit(1)
	}
	tpl, err := template.New("app").Parse(string(b))
	if err != nil {
		log.Errorln("Tpl parse err", err)
		os.Exit(1)
	}
	app.data = map[string]interface{}{
		"Js":     path.Join(staticBundleURL, s.config.js),
		"Style":  path.Join(staticBundleURL, s.config.style),
		"Static": staticURL,
		"Hot":    s.config.hot,
	}
	log.Warnln(app.data)
	app.template = tpl

	// httprouter fileserver
	r.ServeFiles(path.Join(base(s.config.static), "*filepath"), http.Dir(staticPath))
	// if it's not an api call then we use the app, after first checking
	// if there's a file matching the route
	r.NotFound = app
}
开发者ID:axcoto-lab,项目名称:moon,代码行数:60,代码来源:router.go

示例3: runHostCmd

func runHostCmd(cmd *cobra.Command, args []string) {
	router := httprouter.New()
	serverHandler := &server.Handler{}
	serverHandler.Start(c, router)

	if ok, _ := cmd.Flags().GetBool("dangerous-auto-logon"); ok {
		logrus.Warnln("Do not use flag --dangerous-auto-logon in production.")
		err := c.Persist()
		pkg.Must(err, "Could not write configuration file: %s", err)
	}

	http.Handle("/", router)

	var srv = http.Server{
		Addr: c.GetAddress(),
		TLSConfig: &tls.Config{
			Certificates: []tls.Certificate{
				getOrCreateTLSCertificate(cmd),
			},
		},
	}

	var err error
	logrus.Infof("Starting server on %s", c.GetAddress())
	if ok, _ := cmd.Flags().GetBool("force-dangerous-http"); ok {
		logrus.Warnln("HTTPS disabled. Never do this in production.")
		err = srv.ListenAndServe()
	} else {
		err = srv.ListenAndServeTLS("", "")
	}
	pkg.Must(err, "Could not start server: %s %s.", err)
}
开发者ID:jemacom,项目名称:hydra,代码行数:32,代码来源:host.go

示例4: AddSSHKeyToTags

// AddSSHKeyToTags adds the ssh key in the tags
func AddSSHKeyToTags(ctx CommandContext, tags *[]string, image string) error {
	home, err := config.GetHomeDir()
	if err != nil {
		return fmt.Errorf("unable to find your home %v", err)
	}
	idRsa := filepath.Join(home, ".ssh", "id_rsa")
	if _, err := os.Stat(idRsa); err != nil {
		if os.IsNotExist(err) {
			logrus.Warnln("Unable to find your ~/.ssh/id_rsa")
			logrus.Warnln("Run 'ssh-keygen -t rsa'")
			return nil
		}
	}
	idRsa = strings.Join([]string{idRsa, ".pub"}, "")
	data, err := ioutil.ReadFile(idRsa)
	if err != nil {
		return fmt.Errorf("failed to read %v", err)
	}
	data[7] = '_'
	for i := range data {
		if data[i] == ' ' {
			data = data[:i]
			break
		}
	}
	*tags = append(*tags, strings.Join([]string{"AUTHORIZED_KEY", string(data[:len(data)])}, "="))
	return nil
}
开发者ID:awesome-docker,项目名称:scaleway-cli,代码行数:29,代码来源:run.go

示例5: CmdDefault

func CmdDefault(alias string, id IDefault) error {
	logrus.Warnln("The \"default\" command has been deprecated! It will be removed in a future version.")
	logrus.Warnln("Please specify \"-E\" on all commands instead of using the default.")
	err := id.Set(alias)
	if err != nil {
		return err
	}
	logrus.Printf("%s is now the default environment", alias)
	return nil
}
开发者ID:catalyzeio,项目名称:cli,代码行数:10,代码来源:default.go

示例6: readRecord

func (t *Table) readRecord() (Record, error) {
	r := Record{}
	bytes := make([]byte, t.RecordLength)
	if r, err := io.ReadFull(t.data, bytes); err != nil {
		log.Warn("didn't read enough: ", r, err)
		return nil, err
	}
	if string(bytes[:len(RecordMagicHeader)]) != RecordMagicHeader {
		//return nil, ErrMagicHeaderNotFound
	}
	for _, column := range t.Columns {
		value, err := ReadValue(bytes, column)
		// dbg:
		//valueBytes := bytes[column.Offset : column.Offset+column.Length]

		if asMemo, ok := value.(MemoField); ok {
			t.memoData.Seek(int64(asMemo.BlockOffset)*8, 0)
			data := make([]byte, asMemo.Length)
			if _, err := io.ReadFull(t.memoData, data); err != nil {
				log.Warnln("didn't read enough for memo field", column.Name, err)
				return nil, nil
			}
			value = data
		}

		if err != nil {
			return nil, err
		}
		r[column.Name] = value
	}
	return r, nil
}
开发者ID:tmc,项目名称:adt,代码行数:32,代码来源:table.go

示例7: pickupstreams

func (pool *streampool) pickupstreams(udp bool) []*upstream {
	pool.waitforalive()

	// pick udp and tcp equally
	pool.RLock()
	defer pool.RUnlock()

	// pick one of each

	switch {
	case udp && pool.udplen > 0:
		rn := int(atomic.AddUint32(&pool.rn, 1) - 1)
		return []*upstream{pool.udpool[rn%pool.udplen]}
	case pool.tcplen > 0 && pool.udplen > 0:
		// pick one of each
		rn := int(atomic.AddUint32(&pool.rn, 1) - 1)
		return []*upstream{
			pool.udpool[rn%pool.udplen],
			pool.tcpool[rn%pool.tcplen],
		}
	case pool.tcplen == 0 || pool.udplen == 0:
		// pick 2 alived
		rn := int(atomic.AddUint32(&pool.rn, 2) - 2)

		return []*upstream{
			pool.alived[rn%pool.alvlen],
			pool.alived[(rn+1)%pool.alvlen],
		}
	}
	logrus.Warnln("no upstream avalible for pick")
	return nil
}
开发者ID:tomasen,项目名称:trafcacc,代码行数:32,代码来源:upstream.go

示例8: logImpl

func logImpl(ctx *evalCtx, args []ast) (ast, error) {
	level, ok := args[0].(astString)
	if !ok {
		return nil, fmt.Errorf("log level must be a string: %s\n", level)
	}

	msgAst, ok := args[1].(astString)
	if !ok {
		return nil, fmt.Errorf("log message must be a string: %s\n", args[1])
	}

	msg := string(msgAst)
	switch level {
	case "print":
		log.Println(msg)
	case "debug":
		log.Debugln(msg)
	case "info":
		log.Infoln(msg)
	case "warn":
		log.Warnln(msg)
	case "error":
		log.Errorln(msg)
	default:
		return nil,
			fmt.Errorf("log level must be one of "+
				"[print, info, debug, warn, error]: %s",
				level)
	}

	return astList{}, nil
}
开发者ID:yuenmeiwan,项目名称:quilt,代码行数:32,代码来源:func.go

示例9: GetTenantByTenantId

func (p *TenantService) GetTenantByTenantId(tenantId string) (tenant *entity.Tenant, err error) {
	if !bson.IsObjectIdHex(tenantId) {
		logrus.Errorln("invalid object id for getTenantById: ", tenantId)
		err = errors.New("invalid object id for getTenantById")
		return
	}
	selector := bson.M{}
	selector["_id"] = bson.ObjectIdHex(tenantId)

	tenant = new(entity.Tenant)
	queryStruct := dao.QueryStruct{
		CollectionName: p.collectionName,
		Selector:       selector,
		Skip:           0,
		Limit:          0,
		Sort:           ""}

	err = dao.HandleQueryOne(tenant, queryStruct)
	if err != nil {
		logrus.Warnln("failed to get tenant by id %v", err)
		return
	}

	return
}
开发者ID:popsuper1982,项目名称:DCOS_Cluster,代码行数:25,代码来源:tenantService.go

示例10: generate

func (blog *Blog) generate(fileInfo os.FileInfo) {

	defer blog.wg.Done()

	//markdown input
	input, err := ioutil.ReadFile(config.SourceDir + "/articles/" + fileInfo.Name())
	if err != nil {
		log.Warnln("Can not open file: ", fileInfo.Name())
		return
	}

	//parse markdown to *Markdown obj
	markdown := mark.Mark(input)

	//extract article info
	article, err := getArticle(markdown, fileInfo)
	if err != nil {
		log.Error("[Format Error]: ", fileInfo.Name(), "; ", err)
		return
	}
	blog.articles = append(blog.articles, &article)

	markdown.Parts = markdown.Parts[1:]

	//transform markdown to html and output
	renderArticle(markdown, article)
}
开发者ID:gssdromen,项目名称:goblog,代码行数:27,代码来源:blog.go

示例11: createAndInsertUser

func (p *UserService) createAndInsertUser(userName string, password string, email string, tenanId string, roleId string, company string) (userId string, err error) {
	// var jsondocument interface{}
	currentUser, erro := p.getAllUserByName(userName)
	if erro != nil {
		logrus.Error("get all user by username err is %v", erro)
		return "", erro
	}
	if len(currentUser) != 0 {
		logrus.Infoln("user already exist! username:", userName)
		userId = currentUser[0].ObjectId.Hex()
		return
	}

	currentTime := dao.GetCurrentTime()
	user := new(entity.User)
	user.ObjectId = bson.NewObjectId()
	user.Username = userName
	user.Password = password
	user.TenantId = tenanId
	user.RoleId = roleId
	user.Email = email
	user.Company = company
	user.TimeCreate = currentTime
	user.TimeUpdate = currentTime

	err = dao.HandleInsert(p.userCollectionName, user)
	if err != nil {
		logrus.Warnln("create user error %v", err)
		return
	}
	userId = user.ObjectId.Hex()

	return
}
开发者ID:popsuper1982,项目名称:DCOS_Cluster,代码行数:34,代码来源:userService.go

示例12: GetUserByUserId

func (p *UserService) GetUserByUserId(userId string) (user *entity.User, err error) {
	if !bson.IsObjectIdHex(userId) {
		logrus.Errorln("invalid object id for getUseerById: ", userId)
		err = errors.New("invalid object id for getUserById")
		return nil, err
	}
	selector := bson.M{}
	selector["_id"] = bson.ObjectIdHex(userId)

	user = new(entity.User)
	queryStruct := dao.QueryStruct{
		CollectionName: p.userCollectionName,
		Selector:       selector,
		Skip:           0,
		Limit:          0,
		Sort:           ""}

	err = dao.HandleQueryOne(user, queryStruct)

	if err != nil {
		logrus.Warnln("failed to get user by id %v", err)
		return
	}

	return
}
开发者ID:popsuper1982,项目名称:DCOS_Cluster,代码行数:26,代码来源:userService.go

示例13: StartGossip

func (sn *Node) StartGossip() {
	go func() {
		t := time.Tick(GOSSIP_TIME)
		for {
			select {
			case <-t:
				sn.viewmu.Lock()
				c := sn.HostListOn(sn.ViewNo)
				sn.viewmu.Unlock()
				if len(c) == 0 {
					log.Errorln(sn.Name(), "StartGossip: none in hostlist for view: ", sn.ViewNo, len(c))
					continue
				}
				sn.randmu.Lock()
				from := c[sn.Rand.Int()%len(c)]
				sn.randmu.Unlock()
				log.Errorln("Gossiping with: ", from)
				sn.CatchUp(int(atomic.LoadInt64(&sn.LastAppliedVote)+1), from)
			case <-sn.closed:
				log.Warnln("stopping gossip: closed")
				return
			}
		}
	}()
}
开发者ID:ineiti,项目名称:prifi,代码行数:25,代码来源:snvoting.go

示例14: createAndInsertRole

// CreateAndInsertRole creat and insert the role items according to the given
// rolename and desc.
func (p *RoleService) createAndInsertRole(roleName string, desc string) (roleId string, err error) {
	role := &entity.Role{}
	role, err = p.getRoleByName(roleName)
	if err == nil {
		logrus.Infoln("role already exist! roleName: ", roleName)
		roleId = role.ObjectId.Hex()
		return
	}

	currentTime := dao.GetCurrentTime()
	objectId := bson.NewObjectId()
	role = &entity.Role{
		ObjectId:    objectId,
		Rolename:    roleName,
		Description: desc,
		TimeCreate:  currentTime,
		TimeUpdate:  currentTime,
	}

	err = dao.HandleInsert(p.collectionName, role)
	if err != nil {
		logrus.Warnln("create role error %v", err)
		return
	}
	roleId = role.ObjectId.Hex()
	return

}
开发者ID:popsuper1982,项目名称:DCOS_Cluster,代码行数:30,代码来源:roleService.go

示例15: tcphandler

// handle packed data from client side as backend
func (s *serv) tcphandler(conn net.Conn) {

	dec := gob.NewDecoder(conn)
	enc := gob.NewEncoder(conn)

	// add to pool
	u := newUpstream(s.proto)
	u.encoder = enc
	u.decoder = dec

	defer func() {
		conn.Close()
		// remove from pool
		s.pool.remove(u)
	}()

	s.pool.append(u, 0)

	for {
		p := packet{}
		err := dec.Decode(&p)
		if err != nil {
			logrus.Warnln("packetHandler() Decode err:", err)
			break
		}

		if err := s.proc(u, &p); err != nil {
			logrus.WithError(err).Warn("serve send pong err")
			return
		}
	}
}
开发者ID:tomasen,项目名称:trafcacc,代码行数:33,代码来源:server.go


注:本文中的github.com/Sirupsen/logrus.Warnln函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。