本文整理汇总了Golang中github.com/cihub/seelog.LoggerFromConfigAsBytes函数的典型用法代码示例。如果您正苦于以下问题:Golang LoggerFromConfigAsBytes函数的具体用法?Golang LoggerFromConfigAsBytes怎么用?Golang LoggerFromConfigAsBytes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LoggerFromConfigAsBytes函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: dateTimeFormat
func dateTimeFormat() {
fmt.Println("Date time format")
testConfig := `
<seelog type="sync">
<outputs formatid="main">
<console/>
</outputs>
<formats>
<format id="main" format="%Date/%Time [%LEV] %Msg%n"/>
</formats>
</seelog>`
logger, err := log.LoggerFromConfigAsBytes([]byte(testConfig))
if err != nil {
fmt.Println(err)
}
loggerErr := log.ReplaceLogger(logger)
if loggerErr != nil {
fmt.Println(loggerErr)
}
log.Trace("Test message!")
}
开发者ID:cihub,项目名称:seelog-examples,代码行数:27,代码来源:formats_main.go
示例2: InitLog
// path can be ""
func InitLog(path string, debug bool) {
config := `
<seelog type="sync" minlevel="${minlevel}">
<outputs formatid="main">
<console/>
<!-- ${extra} -->
</outputs>
<formats>
<format id="main" format="[EQ-%LEV] %Date(15:04:05.00): %Msg (at %File:%Line) %n"/>
</formats>
</seelog>`
if path != "" {
extra := fmt.Sprintf("<file path=\"%s\"/>", path)
config = strings.Replace(config, "<!-- ${extra} -->",
extra, -1)
}
Debug = debug
if debug {
config = strings.Replace(config, "${minlevel}", "debug", -1)
} else {
config = strings.Replace(config, "${minlevel}", "info", -1)
}
logger, err := seelog.LoggerFromConfigAsBytes([]byte(config))
if err != nil {
panic(err)
}
seelog.ReplaceLogger(logger)
if path != "" {
seelog.Debugf("Initialized the logger for %s", path)
}
}
开发者ID:terminiter,项目名称:earthquake,代码行数:36,代码来源:log.go
示例3: NewLogs
func NewLogs() {
logger, err := log.LoggerFromConfigAsBytes([]byte(default_template))
if err != nil {
log.Criticalf("log config err: %v", err)
}
log.ReplaceLogger(logger)
}
开发者ID:DavidZhangqin,项目名称:goweb,代码行数:7,代码来源:logger.go
示例4: configLogger
func configLogger() {
config := `
<seelog type="sync">
<outputs>
<filter levels="trace">
<console formatid="skipped"/>
</filter>
<filter levels="debug">
<console formatid="unchanged"/>
</filter>
<filter levels="info">
<console formatid="plain"/>
</filter>
<filter levels="warn,error,critical">
<console formatid="error"/>
</filter>
</outputs>
<formats>
<format id="error" format="%EscM(31)%Msg%EscM(0)%n"/>
<format id="plain" format="%Msg%n"/>
<format id="unchanged" format="%EscM(32)%Msg%EscM(0)%n"/>
<format id="skipped" format="%EscM(34)%Msg%EscM(0)%n"/>
</formats>
</seelog>`
logger, err := log.LoggerFromConfigAsBytes([]byte(config))
if err != nil {
panic(err)
}
log.ReplaceLogger(logger)
}
开发者ID:hnakamur,项目名称:commango,代码行数:31,代码来源:main.go
示例5: configureLog
func configureLog() {
level := Get("lamp.log.level")
if level == "" {
level = "warn"
printVerboseMessage("Could not get log level from configuration, will use default \"warn\".")
}
logDir := os.Getenv(logDir)
var outPath string
logFile := Get("lamp.log.file")
if logFile == "" {
logFile = "lamp.log"
printVerboseMessage("Could not get log filename from configuration. \"lamp.log\" will be used as log filename.")
}
if logDir != "" {
outPath = logDir + sep + logFile
printVerboseMessage("Will write logs to: \n" + outPath)
} else {
outPath = lampHome() + "logs" + sep + logFile
printVerboseMessage("LAMP_LOGS_DIR environment variable is not set. Will write logs to: \n" + outPath)
}
logConfig := template(outPath, level)
logger, err := seelog.LoggerFromConfigAsBytes([]byte(logConfig))
if err != nil {
fmt.Printf("Error occured while configuring logger: %s\n", err.Error())
}
log.UseLogger(logger)
}
开发者ID:smcavoy-travelbird,项目名称:opsgenie-lamp,代码行数:30,代码来源:lamp_config.go
示例6: testFuncException
func testFuncException() {
fmt.Println("testFuncException")
testConfig := `
<seelog type="sync" minlevel="info">
<exceptions>
<exception funcpattern="*main.test*Except*" minlevel="error"/>
</exceptions>
<outputs>
<console/>
</outputs>
</seelog>`
logger, _ := log.LoggerFromConfigAsBytes([]byte(testConfig))
log.ReplaceLogger(logger)
log.Trace("NOT Printed")
log.Debug("NOT Printed")
log.Info("NOT Printed")
log.Warn("NOT Printed")
log.Error("Printed")
log.Critical("Printed")
log.Current.Trace("NOT Printed")
log.Current.Debug("NOT Printed")
log.Current.Info("NOT Printed")
log.Current.Warn("NOT Printed")
log.Current.Error("Printed")
log.Current.Critical("Printed")
}
开发者ID:cihub,项目名称:seelog-examples,代码行数:29,代码来源:exceptions_main.go
示例7: ConfigureLogger
// ConfigureLogger configures the new logger according to the configuration and sets it as the current logger.
func ConfigureLogger(testConfig []byte) {
loggr, err := seelog.LoggerFromConfigAsBytes([]byte(testConfig))
if err != nil {
fmt.Printf("error occured: %s\n", err.Error())
}
UseLogger(loggr)
}
开发者ID:tablexi,项目名称:opsgenie-go-sdk,代码行数:8,代码来源:log.go
示例8: setup_logging
func setup_logging() {
level := "info"
if *g_debug == true {
level = "debug"
}
config := fmt.Sprintf(`
<seelog type="sync" minlevel="%s">
<outputs formatid="main">
<console/>
</outputs>
<formats>
<format id="main" format="%%Date %%Time [%%LEVEL] %%File|%%FuncShort|%%Line: %%Msg%%n"/>
</formats>
</seelog>`, level)
logger, err := log.LoggerFromConfigAsBytes([]byte(config))
if err != nil {
fmt.Println("Failed to config logging:", err)
os.Exit(1)
}
log.ReplaceLogger(logger)
log.Info("Logging config is successful")
}
开发者ID:RouGang,项目名称:gossipd,代码行数:26,代码来源:gossipd.go
示例9: TestGosnmp
func TestGosnmp(t *testing.T) {
RegisterFailHandler(Fail)
pid := os.Getpid()
loggingConfig := fmt.Sprintf(`
<seelog>
<outputs>
<buffered size="10000" flushperiod="1000" formatid="debug">
<rollingfile type="size" filename="logs/debuglog.log" maxsize="10000000" maxrolls="10" />
</buffered>
</outputs>
<formats>
<format id="debug" format="%d %%Date(Mon Jan _2 15:04:05.000000) [%%LEV] %%File:%%Line %%Msg%%n"/>
</formats>
</seelog>`, pid)
logger, err := seelog.LoggerFromConfigAsBytes([]byte(loggingConfig))
if err != nil {
Fail(fmt.Sprintf("Couldn't initialize logger: %s", err))
}
defer logger.Flush()
testIdGenerator := make(chan string)
go func() {
for i := 0; ; i++ {
testIdGenerator <- fmt.Sprintf("test %-3d", i)
}
}()
setupV2cClientTest(logger, testIdGenerator)
SetupLowLevelContextTest(logger, testIdGenerator)
RunSpecs(t, "gosnmp Suite")
}
开发者ID:kortschak,项目名称:gosnmp,代码行数:29,代码来源:gosnmp_suite_test.go
示例10: SetupTestLogging
func SetupTestLogging() {
var appConfig = `
<seelog type="sync" minlevel='%s'>
<outputs formatid="scanner">
<filter levels="critical,error,warn,info">
<console formatid="scanner" />
</filter>
<filter levels="debug,trace">
<console formatid="debug" />
</filter>
</outputs>
<formats>
<format id="scanner" format="test: [%%LEV] %%Msg%%n" />
<format id="debug" format="test: [%%LEV] %%Func :: %%Msg%%n" />
</formats>
</seelog>
`
var config string
if testing.Verbose() {
config = fmt.Sprintf(appConfig, "trace")
} else {
config = fmt.Sprintf(appConfig, "info")
}
logger, err := log.LoggerFromConfigAsBytes([]byte(config))
if err != nil {
fmt.Println(err)
return
}
log.ReplaceLogger(logger)
}
开发者ID:Georgetown-IR-Lab,项目名称:ocr-correction,代码行数:34,代码来源:logging.go
示例11: loadAppConfig
func loadAppConfig() {
appConfig := `
<seelog minlevel="info">
<outputs formatid="common">
<rollingfile type="size" filename="/U8SOFT/turbocrm70/apache/logs/ws/roll.log" maxsize="100000" maxrolls="5"/>
<filter levels="critical">
<file path="/U8SOFT/turbocrm70/apache/logs/ws/critical.log" formatid="critical"/>
</filter>
<filter levels="error">
<file path="/U8SOFT/turbocrm70/apache/logs/ws/error.log" formatid="error"/>
</filter>
</outputs>
<formats>
<format id="common" format="%Date/%Time [%LEV] %Msg%n" />
<format id="critical" format="%File %FullPath %Func %Msg%n" />
<format id="error" format="%Date/%Time %File %FullPath %Func %Msg%n" />
</formats>
</seelog>`
logger, err := seelog.LoggerFromConfigAsBytes([]byte(appConfig))
if err != nil {
fmt.Println(err)
return
}
UseLogger(logger)
}
开发者ID:Albertcy,项目名称:heartbeattrace,代码行数:25,代码来源:logs.go
示例12: loadAppConfig
func loadAppConfig() {
appConfig := `
<seelog type="adaptive" mininterval="2000000" maxinterval="100000000" critmsgcount="500" minlevel="debug">
<exceptions>
<exception filepattern="test*" minlevel="error"/>
</exceptions>
<outputs formatid="all">
<file path="all.log"/>
<filter levels="info">
<console formatid="fmtinfo"/>
</filter>
<filter levels="error,critical" formatid="fmterror">
<console/>
<file path="errors.log"/>
</filter>
</outputs>
<formats>
<format id="fmtinfo" format="[%Level] [%Time] %Msg%n"/>
<format id="fmterror" format="[%LEVEL] [%Time] [%FuncShort @ %File.%Line] %Msg%n"/>
<format id="all" format="[%Level] [%Time] [@ %File.%Line] %Msg%n"/>
<format id="criticalemail" format="Critical error on our server!\n %Time %Date %RelFile %Func %Msg \nSent by Seelog"/>
</formats>
</seelog>
`
logger, err := seelog.LoggerFromConfigAsBytes([]byte(appConfig))
if err != nil {
fmt.Println(err)
return
}
UseLogger(logger)
}
开发者ID:ilahsa,项目名称:go,代码行数:31,代码来源:ulog.go
示例13: loadAppConf
func loadAppConf() {
// appConf := `<seelog />`
appConf := `
<seelog minlevel="warn">
<outputs formatid="common">
<rollingfile type="size" filename="/Users/winniewang/source/go-workspace/logs/roll.log" maxsize="100000" maxrolls="5"/>
<filter levels="critical">
<file path="/Users/winniewang/source/go-workspace/logs/critical.log" formatid="critical"/>
<smtp formatid="criticalemail" senderaddress="[email protected]" sendername="Zhou Zhefu" hostname="smtp.gmail.com" hostport="587" username="zhou.zhefu" password="5642326">
<recipient address="[email protected]"/>
</smtp>
</filter>
</outputs>
<formats>
<format id="common" format="%Date/%Time [%LEV] %Msg%n" />
<format id="critical" format="%File %FullPath %Func %Msg%n" />
<format id="criticalemail" format="Critical error on our server!\n %Time %Date %RelFile %Func %Msg \nSent by Seelog"/>
</formats>
</seelog>
`
logger, err := seelog.LoggerFromConfigAsBytes([]byte(appConf))
if err != nil {
fmt.Println(err)
return
}
UseLogger(logger)
}
开发者ID:zhouzhefu,项目名称:go-projects-src,代码行数:29,代码来源:custom-logger.go
示例14: createLogger
func createLogger(logName string) (seelog.LoggerInterface, error) {
conf, err := createLogConf(logName)
if err != nil {
fmt.Println("build log conf err", err)
os.Exit(1)
}
return seelog.LoggerFromConfigAsBytes(conf)
}
开发者ID:xiewenyu,项目名称:dsp,代码行数:8,代码来源:commons.go
示例15: setLogLevel
func setLogLevel(level string) {
if level != "error" && level != "warn" {
log.Infof("Setting log level '%s'.", level)
}
logConfig := fmt.Sprintf("<seelog minlevel='%s'>", level)
logger, _ := log.LoggerFromConfigAsBytes([]byte(logConfig))
log.ReplaceLogger(logger)
}
开发者ID:evaluation-alex,项目名称:gosync,代码行数:8,代码来源:main.go
示例16: initLoggerFromBytes
// initLoggerFromBytes initializes the logger using the specified configuration as bytes.
func initLoggerFromBytes(seelogConfig []byte) (logger T) {
var seelogger seelog.LoggerInterface
var err error
if seelogger, err = seelog.LoggerFromConfigAsBytes(seelogConfig); err != nil {
fmt.Println("Error parsing logger config:", err)
return nil
}
seelogDefault = seelogger
return withContext(seelogDefault)
}
开发者ID:aws,项目名称:amazon-ssm-agent,代码行数:11,代码来源:log.go
示例17: NewDefaultLogger
//Creates a new DefaultLogger that is configured to write messages to console with minimum log level Level.
func NewDefaultLogger(Level LogLevel) *DefaultLogger {
var config = fmt.Sprintf(`<seelog minlevel="%s">
<outputs formatid="main">
<console />
</outputs>
<formats>
<format id="main" format="%%Date/%%Time [%%LEVEL] %%Msg%%n"/>
</formats>
</seelog>`, Level)
logger, _ := log.LoggerFromConfigAsBytes([]byte(config))
return &DefaultLogger{Level, logger}
}
开发者ID:sunshine-zhd1229,项目名称:go_kafka_client,代码行数:14,代码来源:logger.go
示例18: rollingFileWriterManyRolls
func rollingFileWriterManyRolls() {
testConfig := `
<seelog>
<outputs>
<rollingfile type="size" filename="./log/manyrolls.log" maxsize="100" maxrolls="4" />
</outputs>
</seelog>
`
logger, _ := log.LoggerFromConfigAsBytes([]byte(testConfig))
log.ReplaceLogger(logger)
fmt.Println("Rolling file writer. Many rolls")
doLogBig()
}
开发者ID:Krave-n,项目名称:seelog-examples,代码行数:14,代码来源:outputs_main.go
示例19: LoadLogConfig
func LoadLogConfig(name string) {
config := `<seelog type="adaptive" mininterval="2000000" maxinterval="10000000" critmsgcount="5">
<outputs formatid="msg">
<file path="` + name + `.log"/>
</outputs>
<formats>
<format id="msg" format="%Time: %Msg%n"/>
</formats>
</seelog>`
logger, _ := log.LoggerFromConfigAsBytes([]byte(config))
log.ReplaceLogger(logger)
}
开发者ID:romovs,项目名称:viscum,代码行数:14,代码来源:dbg.go
示例20: stdFormat
func stdFormat() {
testConfig := `
<seelog type="sync">
<outputs formatid="main">
<console/>
</outputs>
<formats>
<format id="main" format=" %Date %Time - [%LEVEL] - %Msg - (%Func %File)%n"/>
</formats>
</seelog>`
logger, _ := log.LoggerFromConfigAsBytes([]byte(testConfig))
log.ReplaceLogger(logger)
}
开发者ID:santeriv,项目名称:gdrive-webdav,代码行数:14,代码来源:main.go
注:本文中的github.com/cihub/seelog.LoggerFromConfigAsBytes函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论