本文整理汇总了Golang中github.com/Sirupsen/logrus.Infoln函数的典型用法代码示例。如果您正苦于以下问题:Golang Infoln函数的具体用法?Golang Infoln怎么用?Golang Infoln使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Infoln函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: SaveTweet
func (cli *MongoClient) SaveTweet(tweets []anaconda.Tweet) {
session, err := mgo.Dial(config.MongoDBServerHost)
if err != nil {
logrus.Errorln(err)
}
defer session.Close()
db := session.DB("oreppoid")
col := db.C("tweet")
for _, tweet := range tweets {
logrus.Infoln("saving...", tweet.Text)
insertTweet := Tweet{
Text: tweet.Text,
Name: tweet.User.Name,
UserId: tweet.User.IdStr,
CreatedAt: tweet.CreatedAt,
}
err := col.Insert(insertTweet)
if err != nil {
logrus.Fatalln(err)
}
}
logrus.Infoln("tweets are saved in mongo")
}
开发者ID:RyotaKatoh,项目名称:oreppoid,代码行数:26,代码来源:save_tweet.go
示例2: Setup
// Setup download selected version to target dir and unpacks it
func (v *Version) Setup(rootDir string) error {
sdkRoot := filepath.Join(rootDir, v.Release)
os.MkdirAll(sdkRoot, 0755)
targetFile := filepath.Join(rootDir, v.name)
if _, err := os.Stat(targetFile); os.IsNotExist(err) {
resp, err := req.Get(
v.remoteURL,
&req.RequestOptions{
UserAgent: "Mozilla/5.0 (compatible; Gobu; +https://github.com/dz0ny/gobu)",
},
)
if err != nil {
return err
}
log.Infoln("Starting download of ", v.String())
err = resp.DownloadToFile(targetFile)
if err != nil {
return err
}
log.Infoln("Starting extraction of ", targetFile)
if strings.HasSuffix(v.name, ".zip") {
return archive.Unzip(targetFile, sdkRoot)
}
if strings.HasSuffix(v.name, ".tar.gz") {
return archive.Untar(targetFile, sdkRoot)
}
return errors.New("Unsuported archive type")
}
return nil
}
开发者ID:dz0ny,项目名称:gobu,代码行数:34,代码来源:version.go
示例3: AuthOperation
func (p *AuthService) AuthOperation(operations []string, tokenid string, objectId string, collectionName string) (map[string]int, error) {
logrus.Infoln("begin to list authorized operations")
token, err := GetTokenById(tokenid)
if err != nil {
logrus.Errorln("get token error:", err)
return nil, errors.New("get token error!")
}
data := p.getObjectById(objectId, collectionName)
authParam := &AuthParam{
auth_instanceId: "",
auth_token: token,
auth_collectionName: ""}
result := make(map[string]int)
for i := 0; i < len(operations); i++ {
op := operations[i]
policyValue, exist := AUTHDATA[op]
if !exist {
logrus.Infoln("no auth policy for specific operation, operation:", op)
result[op] = 1
continue
}
if p.check(policyValue, authParam, data) {
result[op] = 1
} else {
result[op] = 0
}
}
return result, nil
}
开发者ID:popsuper1982,项目名称:DCOS_Cluster,代码行数:35,代码来源:authservice.go
示例4: startFrontends
func startFrontends(httpConfig httpfrontend.Config, udpConfig udpfrontend.Config, logic *middleware.Logic, errChan chan<- error) (httpFrontend *httpfrontend.Frontend, udpFrontend *udpfrontend.Frontend) {
if httpConfig.Addr != "" {
httpFrontend = httpfrontend.NewFrontend(logic, httpConfig)
go func() {
log.Infoln("started serving HTTP on", httpConfig.Addr)
if err := httpFrontend.ListenAndServe(); err != nil {
errChan <- errors.New("failed to cleanly shutdown HTTP frontend: " + err.Error())
}
}()
}
if udpConfig.Addr != "" {
udpFrontend = udpfrontend.NewFrontend(logic, udpConfig)
go func() {
log.Infoln("started serving UDP on", udpConfig.Addr)
if err := udpFrontend.ListenAndServe(); err != nil {
errChan <- errors.New("failed to cleanly shutdown UDP frontend: " + err.Error())
}
}()
}
return
}
开发者ID:mrd0ll4r,项目名称:chihaya,代码行数:25,代码来源:main.go
示例5: BuildQueryByAuth
//return a query language by authenticate
//this will be used for listAll, list and deleteAll interface
func (p *AuthService) BuildQueryByAuth(operation string, tokenId string) (query bson.M, err error) {
logrus.Infoln("build query object by auth")
token, err := GetTokenService().GetTokenById(tokenId)
if err != nil {
logrus.Errorln("get token error:", err)
return nil, errors.New("get token by id error!")
}
authParam := &AuthParam{auth_token: token}
policyValue, exist := p.authdata[operation]
if !exist {
logrus.Infoln("no auth policy for specific operation, operation:", operation)
query = bson.M{}
return
}
switch checkType := policyValue.(type) {
case entity.OrCheck:
orresult, orsuccess := p.orCheck_query(checkType.Basechecks, checkType.Andchecks, checkType.Orchecks, authParam)
if !orsuccess {
logrus.Warnln("build auth query error")
return nil, errors.New("build auth query error")
}
query, err = format(orresult)
if err != nil {
logrus.Warnln("format query result to bson error %v", err)
return nil, err
}
return
case entity.AndCheck:
andresult, andsuccess := p.andCheck_query(checkType.Basechecks, checkType.Andchecks, checkType.Orchecks, authParam)
if !andsuccess {
logrus.Warnln("build auth query error")
return nil, errors.New("build auth query error")
}
query, err = format(andresult)
if err != nil {
logrus.Warnln("format query result to bson error %v", err)
return nil, err
}
return
case entity.BaseCheck:
baseresult, basesuccess := p.baseCheck_query(checkType.Checktype, checkType.Value, authParam)
if !basesuccess {
logrus.Warnln("build auth query error")
return nil, errors.New("build auth query error")
}
query, err = format(baseresult)
if err != nil {
logrus.Warnln("format query result to bson error %v", err)
return nil, err
}
return
default:
logrus.Errorln("unkonwn check type:", checkType)
return nil, errors.New("unknown check type")
}
}
开发者ID:popsuper1982,项目名称:DCOS_Cluster,代码行数:62,代码来源:userAuthService.go
示例6: main
func main() {
log.SetLevel(log.DebugLevel)
log.Infoln("*******************************************")
log.Infoln("Port Scanner")
log.Infoln("*******************************************")
t := time.Now()
defer func() {
if e := recover(); e != nil {
log.Debugln(e)
}
}()
log.Debugln(loadConfig("config.properties"))
log.Debugln("Parsed input data ", len(portScannerTuple.portScannerResult))
CheckPort(&portScannerTuple)
for key, value := range portScannerTuple.portScannerResult {
if value {
log.Debugln("Port Scanner Result", key, " port is open :", value)
}
}
log.Debugln("Total time taken %s to scan %d ports", time.Since(t), len(portScannerTuple.portScannerResult))
}
开发者ID:beeyeas,项目名称:portscanner,代码行数:26,代码来源:portscanner.go
示例7: NewSwitch
// Builds and populates a Switch struct then starts listening
// for OpenFlow messages on conn.
func NewSwitch(stream *util.MessageStream, dpid net.HardwareAddr, app AppInterface) *OFSwitch {
var s *OFSwitch
if switchDb[dpid.String()] == nil {
log.Infoln("Openflow Connection for new switch:", dpid)
s = new(OFSwitch)
s.app = app
s.stream = stream
s.dpid = dpid
// Initialize the fgraph elements
s.initFgraph()
// Save it
switchDb[dpid.String()] = s
// Main receive loop for the switch
go s.receive()
} else {
log.Infoln("Openflow Connection for switch:", dpid)
s = switchDb[dpid.String()]
s.stream = stream
s.dpid = dpid
}
// send Switch connected callback
s.switchConnected()
// Return the new switch
return s
}
开发者ID:nikolayvoronchikhin,项目名称:netplugin,代码行数:36,代码来源:ofSwitch.go
示例8: OnDisconnect
// OnDisconnect event. Terminates MumbleDJ process or retries connection if
// automatic connection retries are enabled.
func (dj *MumbleDJ) OnDisconnect(e *gumble.DisconnectEvent) {
dj.Queue.Reset()
if viper.GetBool("connection.retry_enabled") &&
(e.Type == gumble.DisconnectError || e.Type == gumble.DisconnectKicked) {
logrus.WithFields(logrus.Fields{
"interval_secs": fmt.Sprintf("%d", viper.GetInt("connection.retry_interval")),
"attempts": fmt.Sprintf("%d", viper.GetInt("connection.retry_attempts")),
}).Warnln("Disconnected from server. Retrying connection...")
success := false
for retries := 0; retries < viper.GetInt("connection.retry_attempts"); retries++ {
logrus.Infoln("Retrying connection...")
if client, err := gumble.DialWithDialer(new(net.Dialer), viper.GetString("connection.address")+":"+viper.GetString("connection.port"), dj.GumbleConfig, dj.TLSConfig); err == nil {
dj.Client = client
logrus.Infoln("Successfully reconnected to the server!")
success = true
break
}
time.Sleep(time.Duration(viper.GetInt("connection.retry_interval")) * time.Second)
}
if !success {
dj.KeepAlive <- true
logrus.Fatalln("Could not reconnect to server. Exiting...")
}
} else {
dj.KeepAlive <- true
logrus.Fatalln("Disconnected from server. No reconnect attempts will be made.")
}
}
开发者ID:matthieugrieger,项目名称:mumbledj,代码行数:31,代码来源:mumbledj.go
示例9: doSetupOnOSX
func doSetupOnOSX(isMinimalSetupMode bool) error {
log.Infoln("Doing OS X specific setup")
log.Infoln("Checking required tools...")
if err := CheckIsHomebrewInstalled(isMinimalSetupMode); err != nil {
return errors.New(fmt.Sprint("Homebrew not installed or has some issues. Please fix these before calling setup again. Err:", err))
}
if err := PrintInstalledXcodeInfos(); err != nil {
return errors.New(fmt.Sprint("Failed to detect installed Xcode and Xcode Command Line Tools infos. Err:", err))
}
// if err := CheckIsXcodeCLTInstalled(); err != nil {
// return errors.New(fmt.Sprint("Xcode Command Line Tools not installed. Err:", err))
// }
// if err := checkIsAnsibleInstalled(); err != nil {
// return errors.New("Ansible failed to install")
// }
if err := CheckIsEnvmanInstalled(minEnvmanVersion); err != nil {
return errors.New(fmt.Sprint("Envman failed to install:", err))
}
if err := CheckIsStepmanInstalled(minStepmanVersion); err != nil {
return errors.New(fmt.Sprint("Stepman failed to install:", err))
}
log.Infoln("All the required tools are installed!")
return nil
}
开发者ID:andrewhavens,项目名称:bitrise,代码行数:27,代码来源:setup.go
示例10: doSetupToolkits
func doSetupToolkits() error {
log.Infoln("Checking Bitrise Toolkits...")
coreToolkits := toolkits.AllSupportedToolkits()
for _, aCoreTK := range coreToolkits {
toolkitName := aCoreTK.ToolkitName()
isInstallRequired, checkResult, err := aCoreTK.Check()
if err != nil {
return fmt.Errorf("Failed to perform toolkit check (%s), error: %s", toolkitName, err)
}
if isInstallRequired {
log.Infoln("No installed/suitable '" + toolkitName + "' found, installing toolkit ...")
if err := aCoreTK.Install(); err != nil {
return fmt.Errorf("Failed to install toolkit (%s), error: %s", toolkitName, err)
}
isInstallRequired, checkResult, err = aCoreTK.Check()
if err != nil {
return fmt.Errorf("Failed to perform toolkit check (%s), error: %s", toolkitName, err)
}
}
if isInstallRequired {
return fmt.Errorf("Toolkit (%s) still reports that it isn't (properly) installed", toolkitName)
}
log.Infoln(" * "+colorstring.Green("[OK]")+" "+toolkitName+" :", checkResult.Path)
log.Infoln(" version :", checkResult.Version)
}
return nil
}
开发者ID:bitrise-io,项目名称:bitrise,代码行数:33,代码来源:setup.go
示例11: doStop
func doStop(c *cli.Context, client *etcd.Client) {
cmd := &command.Command{
Id: time.Now().Format("20060102030405"),
Type: "remove",
Name: c.String("id"),
Service: c.String("service"),
Backend: c.String("backend"),
Cluster: c.String("cluster"),
Proto: c.String("proto"),
}
if cmd.Name == "" {
cmd.Image = c.String("image")
if cmd.Image == "" {
log.Fatalln("image name or container id is required!")
}
}
log.Infoln("generate a new command: ", cmd.Marshal())
if c.Bool("local") {
log.Infoln("just stop container on local host")
if err := cmd.Process(dockerClient(c), etcdClient(c), c.String("host"), c.GlobalString("prefix")); err != nil {
log.WithFields(log.Fields{
"error": err.Error(),
}).Fatalln("execute command failed.")
}
return
}
dispatchCommand(c, client, cmd)
}
开发者ID:jmptrader,项目名称:beacon,代码行数:31,代码来源:stop.go
示例12: waitForWatcher
func waitForWatcher(ctx context.Context, watcher *inotify.Watcher, match matcherFunc, tpl *template.Template, monitor bool) {
defer watcher.Close()
for {
select {
case <-ctx.Done(): // Timeout
os.Exit(2)
return
case ev := <-watcher.Event:
if !match(ev) {
break
}
if tpl != nil {
tpl.Execute(os.Stdout, ev)
log.Infoln()
} else {
log.Infoln(ev)
}
// Finish if not monitoring mode.
if !monitor {
return
}
case err := <-watcher.Error:
log.Fatal(err)
}
}
}
开发者ID:ceram1,项目名称:gonotify,代码行数:29,代码来源:watch.go
示例13: destroy
func destroy(c *cli.Context) {
log.Infoln("Destroy")
additionalEnvs, err := config.CreateEnvItemsModelFromSlice(MachineParamsAdditionalEnvs.Get())
if err != nil {
log.Fatalf("Invalid Environment parameter: %s", err)
}
configModel, err := config.ReadMachineConfigFileFromDir(MachineWorkdir.Get(), additionalEnvs)
if err != nil {
log.Fatalln("Failed to read Config file: ", err)
}
isOK, err := pathutil.IsPathExists(path.Join(MachineWorkdir.Get(), "Vagrantfile"))
if err != nil {
log.Fatalln("Failed to check 'Vagrantfile' in the WorkDir: ", err)
}
if !isOK {
log.Fatalln("Vagrantfile not found in the WorkDir!")
}
log.Infof("configModel: %#v", configModel)
if err := doCleanup(configModel, "will-be-destroyed"); err != nil {
log.Fatalf("Failed to Cleanup: %s", err)
}
if err := doDestroy(configModel); err != nil {
log.Fatalf("Failed to Destroy: %s", err)
}
log.Infoln("=> Destroy DONE - OK")
}
开发者ID:bitrise-tools,项目名称:bitrise-machine,代码行数:33,代码来源:destroy.go
示例14: SaveToFile
// SaveToFile ...
func SaveToFile(pth string, bitriseConf models.BitriseConfigModel) error {
if pth == "" {
return errors.New("No path provided")
}
file, err := os.Create(pth)
if err != nil {
return err
}
defer func() {
if err := file.Close(); err != nil {
log.Fatalln("[BITRISE] - Failed to close file:", err)
}
}()
contBytes, err := generateYAML(bitriseConf)
if err != nil {
return err
}
if _, err := file.Write(contBytes); err != nil {
return err
}
log.Println()
log.Infoln("=> Init success!")
log.Infoln("File created at path:", pth)
log.Infoln("With the content:")
log.Infoln(string(contBytes))
return nil
}
开发者ID:gitter-badger,项目名称:bitrise-cli,代码行数:32,代码来源:doInit.go
示例15: RunSetup
// RunSetup ...
func RunSetup(appVersion string, isMinimalSetupMode bool) error {
log.Infoln("[BITRISE_CLI] - Setup")
log.Infoln("Detected OS:", runtime.GOOS)
switch runtime.GOOS {
case "darwin":
if err := doSetupOnOSX(isMinimalSetupMode); err != nil {
return err
}
case "linux":
if err := doSetupOnLinux(); err != nil {
return err
}
default:
return errors.New("Sorry, unsupported platform :(")
}
if err := SaveSetupSuccessForVersion(appVersion); err != nil {
return fmt.Errorf("Failed to save setup-success into config file: %s", err)
}
// guide
log.Infoln("We're ready to rock!!")
fmt.Println()
return nil
}
开发者ID:andrewhavens,项目名称:bitrise,代码行数:27,代码来源:setup.go
示例16: checkIsAnsibleInstalled
func checkIsAnsibleInstalled() error {
progInstallPth, err := checkProgramInstalledPath("ansible")
if err != nil {
officialSiteURL := "http://www.ansible.com/home"
officialGitHubURL := "https://github.com/ansible/ansible"
log.Infoln("")
log.Infoln("Ansible was not found.")
log.Infoln("Ansible is used for system provisioning.")
log.Infoln("You can find more information on Ansible's official website:", officialSiteURL)
log.Infoln(" or on it's GitHub page:", officialGitHubURL)
log.Infoln("You can install Ansible through brew:")
log.Infoln("$ brew update && brew install ansible")
isInstall, err := goinp.AskForBool("Would you like to install Ansible right now?")
if err != nil {
return err
}
if !isInstall {
return errors.New("Ansible not found and install was not initiated.")
}
log.Infoln("$ brew update --verbose")
if err := bitrise.RunCommand("brew", "update", "--verbose"); err != nil {
return err
}
log.Infoln("$ brew install ansible")
if err := bitrise.RunCommand("brew", "install", "ansible"); err != nil {
return err
}
// just check again
return checkIsAnsibleInstalled()
}
log.Infoln(" * [OK] Ansible :", progInstallPth)
return nil
}
开发者ID:gitter-badger,项目名称:bitrise-cli,代码行数:35,代码来源:doSetup.go
示例17: logEvent
func logEvent(events fsevents.Event) {
// Split "file" flag separate "."
// Detection file extension
f := strings.Split(events.Path, ".")
if StringInSlice(f[len(f)-1], strings.Split(*file, ",")) {
note := ""
for bit, description := range noteDescription {
if events.Flags&bit == bit {
note += description + " "
}
}
log.Infoln("EventID:", events.ID)
log.Infoln("Path:", events.Path)
log.Infoln("Flags:", note)
for _, events := range noteDescription {
// switch event.Flags & eventType {
switch true {
case events == *event:
go execCommand(*command)
}
}
}
}
开发者ID:zchee,项目名称:_gow,代码行数:26,代码来源:gow.go
示例18: printAboutUtilityWorkflows
func printAboutUtilityWorkflows() {
log.Error("Utility workflows can't be triggered directly")
fmt.Println()
log.Infoln("Note about utility workflows:")
log.Infoln("Utility workflow names start with '_' (example: _my_utility_workflow),")
log.Infoln(" these can't be triggered directly but can be used by other workflows")
log.Infoln(" in the before_run and after_run blocks.")
}
开发者ID:viktorbenei,项目名称:bitrise,代码行数:8,代码来源:run.go
示例19: Initialize
func (sw Swarm) Initialize(servers []string) (err error) {
var clusterContainers []*engine.Container
var engines []docker.Docker
// Ensure the cluster is in Store
if err = sw.Store.Write("/cluster", "", ""); err != nil {
return err
}
// Nodes
for _, server := range servers {
// Connect to Docker
log.Infoln("Connecting to Docker on:", server)
eng, err := docker.New(server, "")
engines = append(engines, eng)
if err != nil {
return err
}
// Agent
if _, err = sw.agent(server, eng); err != nil {
return err
}
}
// Manager
var swarmManager *engine.Container
for _, container := range clusterContainers {
if container.Name == "swarm_manager" {
swarmManager = container
break
}
}
if swarmManager == nil {
i := utils.PickServer(servers)
if swarmManager, err = sw.manager(servers[i], engines[i]); err != nil {
return
}
}
// Connect manager
log.Infoln("Connecting to Swarm manager on:", "tcp://"+swarmManager.Addr())
for i := 0; i < 3; i++ {
// We have to wait swarm manager to init
time.Sleep(200 * time.Millisecond)
_, err = docker.New("tcp://"+swarmManager.Addr(), "")
if err == nil {
break
}
}
if err != nil {
return
}
return sw.Store.Write("manager", swarmManager.Addr(), "cluster/docker/swarm")
}
开发者ID:zanhsieh,项目名称:pipes,代码行数:57,代码来源:swarm.go
示例20: checkIsBitriseToolInstalled
func checkIsBitriseToolInstalled(toolname, minVersion string, isInstall bool) error {
doInstall := func() error {
installCmdLines := []string{
"curl -L https://github.com/bitrise-io/" + toolname + "/releases/download/" + minVersion + "/" + toolname + "-$(uname -s)-$(uname -m) > /usr/local/bin/" + toolname,
"chmod +x /usr/local/bin/" + toolname,
}
officialGithub := "https://github.com/bitrise-io/" + toolname
fmt.Println()
log.Warnln("No supported " + toolname + " version found.")
log.Infoln("You can find more information about "+toolname+" on it's official GitHub page:", officialGithub)
fmt.Println()
// Install
log.Infoln("Installing...")
fmt.Println(strings.Join(installCmdLines, "\n"))
if err := bitrise.RunBashCommandLines(installCmdLines); err != nil {
return err
}
// check again
return checkIsBitriseToolInstalled(toolname, minVersion, false)
}
// check whether installed
progInstallPth, err := CheckProgramInstalledPath(toolname)
if err != nil {
if !isInstall {
return err
}
return doInstall()
}
verStr, err := bitrise.RunCommandAndReturnStdout(toolname, "-version")
if err != nil {
log.Infoln("")
return errors.New("Failed to get version")
}
// version check
isVersionOk, err := bitrise.IsVersionGreaterOrEqual(verStr, minVersion)
if err != nil {
log.Error("Failed to validate installed version")
return err
}
if !isVersionOk {
log.Warn("Installed "+toolname+" found, but not a supported version: ", verStr)
if !isInstall {
return errors.New("Failed to install required version.")
}
log.Warn("Updating...")
return doInstall()
}
log.Infoln(" * "+colorstring.Green("[OK]")+" "+toolname+" :", progInstallPth)
log.Infoln(" version :", verStr)
return nil
}
开发者ID:viktorbeneitest,项目名称:bitrise,代码行数:57,代码来源:dependencies.go
注:本文中的github.com/Sirupsen/logrus.Infoln函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论