本文整理汇总了Golang中github.com/Sirupsen/logrus.Warnln函数的典型用法代码示例。如果您正苦于以下问题:Golang Warnln函数的具体用法?Golang Warnln怎么用?Golang Warnln使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Warnln函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: CmdClear
func CmdClear(privateKey, session, environments, defaultEnv, pods bool, settings *models.Settings) error {
if defaultEnv {
logrus.Warnln("The \"--default\" flag has been deprecated! It will be removed in a future version.")
}
if privateKey {
settings.PrivateKeyPath = ""
}
if session {
settings.SessionToken = ""
settings.UsersID = ""
}
if environments {
settings.Environments = map[string]models.AssociatedEnv{}
}
if defaultEnv {
settings.Default = ""
}
if pods {
settings.Pods = &[]models.Pod{}
}
config.SaveSettings(settings)
if !privateKey && !session && !environments && !defaultEnv && !pods {
logrus.Println("No settings were specified. To see available options, run \"catalyze clear --help\"")
} else {
logrus.Println("All specified settings have been cleared")
}
return nil
}
开发者ID:catalyzeio,项目名称:cli,代码行数:28,代码来源:clear.go
示例17: Handle
func (s *SitesMeta) Handle(resp *crawler.Response) (follow bool, links []*crawler.Link) {
if resp.NewURL.Path != "/robots.txt" {
if s.Exist(resp.NewURL) {
return true, nil
}
}
var err error
root := siteRoot(resp.NewURL)
// url := resp.NewURL.String()
s.Lock()
site, ok := s.m[root]
if !ok {
if site, err = newSiteFromURL(resp.NewURL); err != nil {
return
}
s.m[root] = site
}
site.Lock()
defer site.Unlock()
s.Unlock()
if err = site.updateRobots(resp.StatusCode, resp.Content); err != nil {
logrus.Warnln(err)
}
return true, urlToLink(site.sitemapURLs())
}
开发者ID:fanyang01,项目名称:crawler,代码行数:27,代码来源:site.go
示例18: UserUpdateHandler
// UserUpdateHandler parses the http request and updata a exist user.
// Usage :
// PUT /v1/user/{ParamID}
// Params :
// ParamID : storage identifier of user
// If successful,response code will be set to 201.
func (p *Resource) UserUpdateHandler(req *restful.Request, resp *restful.Response) {
logrus.Infof("UserUpdateHanlder is called!")
token := req.HeaderParameter("X-Auth-Token")
id := req.PathParameter(ParamID)
if len(id) <= 0 {
logrus.Warnln("user id should not be null for update operation")
response.WriteStatusError(services.COMMON_ERROR_INVALIDATE, errors.New("user id should not be null for update operation"), resp)
return
}
newuser := entity.User{}
// Populate the user data
err := json.NewDecoder(req.Request.Body).Decode(&newuser)
if err != nil {
logrus.Errorf("convert body to user failed, error is %v", err)
response.WriteStatusError(services.COMMON_ERROR_INVALIDATE, err, resp)
return
}
created, id, errorCode, err := services.GetUserService().UserUpdate(token, newuser, id)
if err != nil {
response.WriteStatusError(errorCode, err, resp)
return
}
p.successUpdate(id, created, req, resp)
}
开发者ID:popsuper1982,项目名称:DCOS_Cluster,代码行数:34,代码来源:userHandler.go
示例19: Generate
//Generate ...
func (blog *Blog) Generate() (err error) {
//generate static article html
files, err := blog.files()
defer func() {
//generate category.json
b, _ := json.Marshal(blog.articles)
err = ioutil.WriteFile("category.json", b, os.ModePerm)
if err != nil {
log.Warnln("[Generate Fail]: category.json")
}
//generate static category html
By(func(i1, i2 interface{}) bool {
return i1.(*Article).Date.Time.After(i2.(*Article).Date.Time)
}).Sort(blog.articles)
renderCategory(blog.articles)
//generate home page
renderHomePage(getOutputPath(*(blog.articles[0].(*Article))))
}()
if err != nil || len(files) == 0 {
return
}
for _, file := range files {
blog.wg.Add(1)
go blog.generate(file)
}
blog.wg.Wait()
return
}
开发者ID:flytiny,项目名称:goblog,代码行数:36,代码来源:blog.go
示例20: NewFromParameters
// NewFromParameters construye un Scheduler a partir de un mapeo de parámetros
// Al menos se debe pasar como parametro address, ya que si no existe se retornara un error
// Si se pasa tlsverify como true los parametros tlscacert, tlscert y tlskey también deben existir
func NewFromParameters(params map[string]interface{}) (*Framework, error) {
address, ok := params["address"]
if !ok || fmt.Sprint(address) == "" {
return nil, errors.New("Parametro address no existe")
}
authfile := dockerCfgPath()
if af, ok := params["authfile"]; !ok || fmt.Sprint(af) == "" {
log.Warnln("Parametro authfile no existe o está vacio, utilizando su valor por defecto", authfile)
} else {
authfile = fmt.Sprint(af)
}
tlsInfo, err := utils.NewTlsStruct(params)
if err != nil {
return nil, err
}
p := parameters{
address: fmt.Sprint(address),
authfile: authfile,
tlsverify: tlsInfo.TlsVerify,
tlscacert: tlsInfo.TlsCaCert,
tlscert: tlsInfo.TlsCert,
tlskey: tlsInfo.TlsKey,
}
return New(p)
}
开发者ID:latam-airlines,项目名称:mesos-framework-factory,代码行数:33,代码来源:swarm.go
注:本文中的github.com/Sirupsen/logrus.Warnln函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论