本文整理汇总了Golang中github.com/Sirupsen/logrus.Infoln函数的典型用法代码示例。如果您正苦于以下问题:Golang Infoln函数的具体用法?Golang Infoln怎么用?Golang Infoln使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Infoln函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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")
}
示例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
}
示例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
}
示例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
}
示例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")
}
}
示例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))
}
示例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
}
示例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.")
}
}
示例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
}
示例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
}
示例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)
}
示例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)
}
}
}
示例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")
}
示例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
}
示例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
}