當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。