本文整理汇总了Golang中github.com/cihub/seelog.LoggerFromConfigAsString函数的典型用法代码示例。如果您正苦于以下问题:Golang LoggerFromConfigAsString函数的具体用法?Golang LoggerFromConfigAsString怎么用?Golang LoggerFromConfigAsString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LoggerFromConfigAsString函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Init
// ロガーの初期化処理を行う
//
// param ; dir ログファイルの出力先ディレクトリ。
//
// param : name ログファイルの種別(例:master、servant)。
//
// param : identifer ロック用ファイルに(付与する識別ID(例:servantはListePort)。
//
// param : level 出力ログレベル(trace,debug,info,warn,error,criticalのいずれかを指定)
//
// param : maxSizeKB ログファイルの最大サイズ。この値を超えるとログローテーションが発生する。
//
// param : maxRolls ログファイルの最大世代数
//
// param : timeoutSec ロックのタイムアウト秒
//
// return : エラー情報を返す。
func Init(dir string, name string, identifer string, level string, maxSizeKB int, maxRolls int, timeoutSec int) error {
var lockErr error
lockName := lockHeader + name
if identifer != "" {
lockName = lockName + "_" + identifer
}
lockName = lockName + ".lock"
locker, lockErr = util.InitLock(lockName)
if lockErr != nil {
return lockErr
}
if timeoutSec > 0 {
lockTimeout = timeoutSec * 1000
}
logfile := fmt.Sprintf("%s%c%s.log", dir, os.PathSeparator, name)
if err := makeFileIfNotExist(logfile); err != nil {
Term()
return err
}
config := generateConfigString(logfile, level, maxSizeKB, maxRolls)
logger, err := seelog.LoggerFromConfigAsString(config)
if err != nil {
Term()
return err
}
seelog.ReplaceLogger(logger)
valid = true
return nil
}
开发者ID:unikk,项目名称:cuto,代码行数:50,代码来源:log.go
示例2: setInitLogging
func setInitLogging(logLevel string) {
logLevel = strings.ToLower(logLevel)
testConfig := `
<seelog type="sync" minlevel="`
testConfig = testConfig + logLevel
testConfig = testConfig + `">
<outputs formatid="main">
<filter levels="error">
<file path="./log/gopa.log"/>
</filter>
<console formatid="main" />
</outputs>
<formats>
<format id="main" format="[%Date(01-02) %Time] [%LEV] [%File:%Line,%FuncShort] %Msg%n"/>
</formats>
</seelog>`
logger, err := log.LoggerFromConfigAsString(testConfig)
if err != nil {
log.Error("init config error,", err)
}
err = log.ReplaceLogger(logger)
if err != nil {
log.Error("init config error,", err)
}
}
开发者ID:medcl,项目名称:elasticsearch-migration,代码行数:28,代码来源:log.go
示例3: configureLogging
func configureLogging(verbose bool) {
minLevel := "info"
if verbose {
minLevel = "trace"
}
logger, err := log.LoggerFromConfigAsString(fmt.Sprintf(`
<seelog minlevel="%s">
<outputs formatid="out">
<console />
</outputs>
<formats>
<format id="out" format="%%Date %%Time [%%LEVEL] %%Msg%%n" />
</formats>
</seelog>
`, minLevel))
if err != nil {
panic(err)
}
log.ReplaceLogger(logger)
}
开发者ID:keis,项目名称:docker-ec2-metadata,代码行数:25,代码来源:main.go
示例4: main
func main() {
defer log.Flush()
flag.Parse()
args := flag.Args()
if len(args) == 0 {
usage(actions(nil))
os.Exit(1)
}
logger, err := log.LoggerFromConfigAsString(config.Logger())
if err != nil {
die(err)
}
log.ReplaceLogger(logger)
init, err := engine.New()
if err != nil {
die(err)
}
log.Info(args[0])
actions := actions(init)
action, ok := actions[args[0]]
if !ok {
usage(actions)
os.Exit(1)
}
err = action.function()
if err != nil {
die(err)
}
}
开发者ID:ColBT,项目名称:amazon-ecs-init,代码行数:32,代码来源:ecs-init.go
示例5: InitDefaultSyncLogConfig
func InitDefaultSyncLogConfig() {
logger, err := log.LoggerFromConfigAsString(DEFAULT_SYNC_LOG_CONFIG)
if err != nil {
panic(err)
}
log.ReplaceLogger(logger)
}
开发者ID:netvl,项目名称:imaged,代码行数:7,代码来源:logging.go
示例6: DisableLogs
func DisableLogs() {
logger, err := log.LoggerFromConfigAsString(DEFAULT_DISABLE_LOGS_CONFIG)
if err != nil {
panic(err)
}
log.ReplaceLogger(logger)
}
开发者ID:netvl,项目名称:imaged,代码行数:7,代码来源:logging.go
示例7: ServeHttp
// ServeHttp serves IAM Role Credentials for Tasks being managed by the agent.
func ServeHttp(credentialsManager credentials.Manager, containerInstanceArn string, cfg *config.Config) {
// Create and initialize the audit log
// TODO Use seelog's programmatic configuration instead of xml.
logger, err := log.LoggerFromConfigAsString(audit.AuditLoggerConfig(cfg))
if err != nil {
log.Errorf("Error initializing the audit log: %v", err)
// If the logger cannot be initialized, use the provided dummy seelog.LoggerInterface, seelog.Disabled.
logger = log.Disabled
}
auditLogger := audit.NewAuditLog(containerInstanceArn, cfg, logger)
server := setupServer(credentialsManager, auditLogger)
for {
utils.RetryWithBackoff(utils.NewSimpleBackoff(time.Second, time.Minute, 0.2, 2), func() error {
// TODO, make this cancellable and use the passed in context;
err := server.ListenAndServe()
if err != nil {
log.Errorf("Error running http api: %v", err)
}
return err
})
}
}
开发者ID:witsoej,项目名称:amazon-ecs-agent,代码行数:26,代码来源:handler.go
示例8: SetupLogger
func SetupLogger() {
logger, err := log.LoggerFromConfigAsString(loggerConfig())
if err == nil {
log.ReplaceLogger(logger)
} else {
log.Error(err)
}
}
开发者ID:concourse,项目名称:docker-image-resource,代码行数:8,代码来源:seelog.go
示例9: reloadLogConfig
func reloadLogConfig() {
logger, err := seelog.LoggerFromConfigAsString(loggerConfig())
if err == nil {
seelog.ReplaceLogger(logger)
} else {
seelog.Error(err)
}
}
开发者ID:Dataman-Cloud,项目名称:zookeeper-helper,代码行数:9,代码来源:log.go
示例10: init
func init() {
logger, err := log.LoggerFromConfigAsString(logConfig)
if err != nil {
fmt.Printf("Could not load seelog configuration: %s\n", err)
return
}
log.ReplaceLogger(logger)
}
开发者ID:philipsoutham,项目名称:cqlc,代码行数:10,代码来源:column_generator.go
示例11: initLogging
// Initialize logging from command arguments.
func initLogging(configFile string) {
var err error
log.RegisterReceiver("stderr", &CustomReceiver{})
if configFile == "" {
logger, err = log.LoggerFromConfigAsString(defaultLoggingConfig)
checkLogFatal("Failed to load default logging configuration: %s", err)
} else {
logger, err = log.LoggerFromConfigAsFile(configFile)
checkLogFatal("Failed to initialize custom logging file %s: %s", configFile, err)
}
}
开发者ID:jawher,项目名称:admin,代码行数:12,代码来源:logging.go
示例12: main
func main() {
logger, err := log.LoggerFromConfigAsString("<seelog type=\"asynctimer\" asyncinterval=\"500000000\"/>")
checkFail(err)
log.ReplaceLogger(logger)
defer log.Flush()
println("start")
log.Info("Hello from Seelog!")
time.Sleep(time.Second * 10)
}
开发者ID:jmptrader,项目名称:goexample,代码行数:11,代码来源:seelog.go
示例13: initLoggerFactory
// Init logger factory.
func initLoggerFactory() error {
c.LoggerFactory = map[string]Log.LoggerInterface{}
for loggerName, config := range c.Config.Logger { // convert logger config to inst
if logInstance, err := Log.LoggerFromConfigAsString(config); err == nil {
c.LoggerFactory[loggerName] = logInstance
} else {
return err
}
}
return nil
}
开发者ID:youngsn,项目名称:go-framework,代码行数:13,代码来源:init.go
示例14: main
func main() {
defer seelog.Flush()
seelog.LoggerFromConfigAsString("formatid=\"debug\"")
flag.Parse()
cfg := FtpCfg{*host, *user, *pw, *port}
fClient, err := NewFtpClient(cfg)
if err != nil {
panic(err)
}
iClient, err := NewInfluxClient(*surl, *db)
if err != nil {
panic(err)
}
files := make([]*FtpToInflux, 0)
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
line := scanner.Text()
seelog.Tracef("Handle line '%s'", line)
if strings.HasPrefix(line, commentPrefix) {
//Comment
continue
}
splittedLine := strings.Split(line, space)
if len(splittedLine) != 2 {
seelog.Warnf("Line '%s' has not exactly one space", line)
continue
}
data := &FtpToInflux{splittedLine[0], strings.Split(splittedLine[1], sep)}
files = append(files, data)
}
for _, f := range files {
seelog.Tracef("Start with file '%s'!", f.Filename)
buf, err := fClient.Download(f.Filename)
if err != nil {
seelog.Warnf("Error downloading file '%s': %v", f.Filename, err)
continue
}
datas := Transform(buf)
err = iClient.Write(datas, f.Measurements)
if err != nil {
seelog.Warnf("Error writing Data: %v", err)
continue
}
seelog.Tracef("File '%s' downloaded and written to %d measurements!", f.Filename, len(f.Measurements))
}
}
开发者ID:espang,项目名称:examples,代码行数:52,代码来源:main.go
示例15: main
func main() {
cluster := gocql.NewCluster("127.0.0.1")
cluster.Keyspace = "system"
session, err := cluster.CreateSession()
defer session.Close()
if err != nil {
log.Critical(err)
}
traceSession, err := cluster.CreateSession()
defer session.Close()
if err != nil {
log.Critical(err)
}
// Create a new logger instance that we adjust the stack depth for to get
// more meaningful frames
logger, err := log.LoggerFromConfigAsString(
`<seelog>
<outputs>
<console formatid="fmt"/>
</outputs>
<formats>
<format id="fmt" format="%Date(Jan 02 2006 03:04:05.000) [%LEVEL] %File:%Line - %Msg%n"/>
</formats>
</seelog>
`)
logger.SetAdditionalStackDepth(2)
if err != nil {
log.Critical(err)
}
writer := NewTraceWriter(traceSession, logger)
tracer := gocql.NewTraceWriter(traceSession, writer)
session.SetTrace(tracer)
var count int
iter := session.Query(`select count(*) from schema_keyspaces`).Iter()
iter.Scan(&count)
err = iter.Close()
if err != nil {
log.Critical(err)
}
log.Infof("This instance has %d keyspaces", count)
}
开发者ID:relops,项目名称:gocql-tracing-example,代码行数:51,代码来源:main.go
示例16: init
func init() {
_, console = config.GetStringMapBool("log", "console")
_, appendfile = config.GetStringMapBool("log", "appendfile")
_, file = config.GetStringMapString("log", "file")
if file == "" {
file = "./log/omega-es.log"
}
logger, err := log.LoggerFromConfigAsString(logConfig())
if err == nil {
log.ReplaceLogger(logger)
} else {
log.Error(err)
}
}
开发者ID:yiqguo,项目名称:LogCollect,代码行数:14,代码来源:log.go
示例17: init
func init() {
opts.AdvertizedVersion = VERSION
opts.Version = printVersionAndExit
// We might want to make this overridable
logger, err := log.LoggerFromConfigAsString(logConfig)
if err != nil {
fmt.Printf("Could not load seelog configuration: %s\n", err)
return
}
log.ReplaceLogger(logger)
}
开发者ID:relops,项目名称:rmq,代码行数:14,代码来源:rmq.go
示例18: initForTest
func initForTest() {
config := `
<seelog type="sync" minlevel="trace">
<outputs formatid="common">
<console />
</outputs>
<formats>
<format id="common" format="2015-04-01 12:34:56.789 [%LEV] %Msg%n"/>
</formats>
</seelog>`
logger, _ := seelog.LoggerFromConfigAsString(config)
mutex = new(sync.Mutex)
seelog.ReplaceLogger(logger)
isValid = true
}
开发者ID:unirita,项目名称:gocutoweb,代码行数:15,代码来源:log_test.go
示例19: initForTest
func initForTest() {
config := `
<seelog type="sync" minlevel="trace">
<outputs formatid="common">
<console />
</outputs>
<formats>
<format id="common" format="2015-04-01 12:34:56.789 [%LEV] %Msg%n"/>
</formats>
</seelog>`
logger, _ := seelog.LoggerFromConfigAsString(config)
locker, _ = util.InitLock(lockName)
seelog.ReplaceLogger(logger)
valid = true
}
开发者ID:unikk,项目名称:cuto,代码行数:15,代码来源:log_test.go
示例20: InstallTestLoggerWithLogLevel
// InstallTestLogger will install a logger with appropriate configuration for the current testing setup. It returns a
// the logger that was overwritten; this should be restored (via a call to RestoreLogger) at the conclusion of the test.
func InstallTestLoggerWithLogLevel(t testing.TB, logLevel string) log.LoggerInterface {
golog.SetOutput(ioutil.Discard)
loggerIdNum++
loggerId := fmt.Sprintf("testLogger%d", loggerIdNum)
log.RegisterReceiver(loggerId, &testLogger{tb: t})
config := fmt.Sprintf(testLoggerConfigTemplate, logLevel, loggerId)
if logger, err := log.LoggerFromConfigAsString(config); err != nil {
panic(err)
} else {
stashed := log.Current
log.ReplaceLogger(logger)
return stashed
}
}
开发者ID:choirudin2210,项目名称:platform-layer,代码行数:19,代码来源:suite.go
注:本文中的github.com/cihub/seelog.LoggerFromConfigAsString函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论