本文整理汇总了Golang中github.com/cloudfoundry/gosteno.Init函数的典型用法代码示例。如果您正苦于以下问题:Golang Init函数的具体用法?Golang Init怎么用?Golang Init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Init函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: loadLoggerAndConfig
func loadLoggerAndConfig(c *cli.Context, component string) (logger.Logger, *gosteno.Logger, *config.Config) {
configPath := c.String("config")
if configPath == "" {
fmt.Printf("Config path required")
os.Exit(1)
}
conf, err := config.FromFile(configPath)
if err != nil {
fmt.Printf("Failed to load config: %s", err.Error())
os.Exit(1)
}
stenoConf := &gosteno.Config{
Sinks: []gosteno.Sink{
gosteno.NewIOSink(os.Stdout),
gosteno.NewSyslogSink("vcap.hm9000." + component),
},
Level: conf.LogLevel(),
Codec: gosteno.NewJsonCodec(),
}
gosteno.Init(stenoConf)
steno := gosteno.NewLogger("vcap.hm9000." + component)
hmLogger := logger.NewRealLogger(steno)
return hmLogger, steno, conf
}
开发者ID:johntdyer,项目名称:golang-devops-stuff,代码行数:27,代码来源:hm9000.go
示例2: InitLoggerFromConfig
func InitLoggerFromConfig(c *config.Config, logCounter *vcap.LogCounter) {
l, err := steno.GetLogLevel(c.Logging.Level)
if err != nil {
panic(err)
}
s := make([]steno.Sink, 0, 3)
if c.Logging.File != "" {
s = append(s, steno.NewFileSink(c.Logging.File))
} else {
s = append(s, steno.NewIOSink(os.Stdout))
}
if c.Logging.Syslog != "" {
s = append(s, steno.NewSyslogSink(c.Logging.Syslog))
}
s = append(s, logCounter)
stenoConfig := &steno.Config{
Sinks: s,
Codec: steno.NewJsonCodec(),
Level: l,
}
steno.Init(stenoConfig)
}
开发者ID:jungle0755,项目名称:gorouter,代码行数:27,代码来源:main.go
示例3: NewLogger
func NewLogger(verbose bool, logFilePath, name string, syslogNamespace string) *gosteno.Logger {
level := gosteno.LOG_INFO
if verbose {
level = gosteno.LOG_DEBUG
}
loggingConfig := &gosteno.Config{
Sinks: make([]gosteno.Sink, 1),
Level: level,
Codec: gosteno.NewJsonCodec(),
EnableLOC: true}
if strings.TrimSpace(logFilePath) == "" {
loggingConfig.Sinks[0] = gosteno.NewIOSink(os.Stdout)
} else {
loggingConfig.Sinks[0] = gosteno.NewFileSink(logFilePath)
}
if syslogNamespace != "" {
loggingConfig.Sinks = append(loggingConfig.Sinks, GetNewSyslogSink(syslogNamespace))
}
gosteno.Init(loggingConfig)
logger := gosteno.NewLogger(name)
logger.Debugf("Component %s in debug mode!", name)
return logger
}
开发者ID:lyuyun,项目名称:loggregator,代码行数:29,代码来源:logger.go
示例4: main
func main() {
flag.Parse()
if *version {
fmt.Printf("\n\nversion: %s\ngitSha: %s\n\n", versionNumber, gitSha)
return
}
level := gosteno.LOG_INFO
if *logLevel {
level = gosteno.LOG_DEBUG
}
loggingConfig := &gosteno.Config{
Sinks: make([]gosteno.Sink, 1),
Level: level,
Codec: gosteno.NewJsonCodec(),
EnableLOC: true}
if strings.TrimSpace(*logFilePath) == "" {
loggingConfig.Sinks[0] = gosteno.NewIOSink(os.Stdout)
} else {
loggingConfig.Sinks[0] = gosteno.NewFileSink(*logFilePath)
}
gosteno.Init(loggingConfig)
logger := gosteno.NewLogger("deaagent")
loggregatorClient := loggregatorclient.NewLoggregatorClient(*loggregatorAddress, logger, 4096)
agent := deaagent.NewAgent(*instancesJsonFilePath, logger)
agent.Start(loggregatorClient)
}
开发者ID:shageman,项目名称:loggregator,代码行数:32,代码来源:main.go
示例5: SetupLoggerFromConfig
func SetupLoggerFromConfig(c *config.Config) {
l, err := steno.GetLogLevel(c.Logging.Level)
if err != nil {
panic(err)
}
s := make([]steno.Sink, 0)
if c.Logging.File != "" {
s = append(s, steno.NewFileSink(c.Logging.File))
} else {
s = append(s, steno.NewIOSink(os.Stdout))
}
if c.Logging.Syslog != "" {
s = append(s, steno.NewSyslogSink(c.Logging.Syslog))
}
stenoConfig := &steno.Config{
Sinks: s,
Codec: steno.NewJsonCodec(),
Level: l,
}
steno.Init(stenoConfig)
log = steno.NewLogger("router.global")
}
开发者ID:jfarrell,项目名称:gorouter,代码行数:26,代码来源:logger.go
示例6: main
func main() {
flag.Parse()
level, err := gosteno.GetLogLevel(*logLevel)
if err != nil {
level = gosteno.LOG_INFO
}
loggingConfig := &gosteno.Config{
Sinks: []gosteno.Sink{
gosteno.NewIOSink(os.Stdout),
},
Level: level,
Codec: gosteno.NewJsonCodec(),
EnableLOC: true,
}
gosteno.Init(loggingConfig)
logger := gosteno.NewLogger("statsdinjector")
statsdMessageListener := statsdlistener.New(*statsdPort, logger)
statsdEmitter := statsdemitter.New(*metronPort, logger)
inputChan := make(chan *events.Envelope)
go statsdMessageListener.Run(inputChan)
statsdEmitter.Run(inputChan)
}
开发者ID:kei-yamazaki,项目名称:loggregator,代码行数:27,代码来源:main.go
示例7: main
func main() {
flag.Parse()
if *version {
fmt.Printf("\n\nversion: %s\ngitSha: %s\n\n", versionNumber, gitSha)
return
}
level := gosteno.LOG_INFO
if *logLevel {
level = gosteno.LOG_DEBUG
}
loggingConfig := &gosteno.Config{
Sinks: make([]gosteno.Sink, 1),
Level: level,
Codec: gosteno.NewJsonCodec(),
EnableLOC: true}
if strings.TrimSpace(*logFilePath) == "" {
loggingConfig.Sinks[0] = gosteno.NewIOSink(os.Stdout)
} else {
loggingConfig.Sinks[0] = gosteno.NewFileSink(*logFilePath)
}
gosteno.Init(loggingConfig)
logger := gosteno.NewLogger("loggregator")
listener := loggregator.NewAgentListener(*host, logger)
incomingData := listener.Start()
cfSink := loggregator.NewCfSink(incomingData, logger)
cfSink.Start()
}
开发者ID:shageman,项目名称:loggregator,代码行数:34,代码来源:main.go
示例8: setup_steno
func setup_steno(conf *proxy.ProxyConfig) {
level, err := steno.GetLogLevel(conf.LOGGING.LEVEL)
if err != nil {
panic(err)
}
log_path := conf.LOGGING.PATH
if log_path != "" {
os.MkdirAll(filepath.Dir(log_path), 0755)
}
sinks := make([]steno.Sink, 0)
if log_path != "" {
sinks = append(sinks, steno.NewFileSink(log_path))
} else {
sinks = append(sinks, steno.NewIOSink(os.Stdout))
}
stenoConfig := &steno.Config{
Sinks: sinks,
Codec: steno.NewJsonCodec(),
Level: level,
}
steno.Init(stenoConfig)
}
开发者ID:008by,项目名称:cf-services-contrib-release,代码行数:26,代码来源:logger.go
示例9: init
func init() {
steno.Init(&steno.Config{
Sinks: []steno.Sink{steno.NewIOSink(os.Stderr)},
Codec: steno.NewJsonCodec(),
Level: steno.LOG_ALL,
})
log = steno.NewLogger("directory_server_test")
}
开发者ID:9cc9,项目名称:dea_ng,代码行数:9,代码来源:log_test.go
示例10: main
func main() {
c := &gosteno.Config{
Sinks: []gosteno.Sink{
gosteno.NewIOSink(os.Stdout),
},
Level: gosteno.LOG_DEBUG,
Codec: gosteno.NewJsonPrettifier(0),
EnableLOC: true,
}
gosteno.Init(c)
logger := gosteno.NewLogger("atk_instances")
conf := config.NewConfig()
m := martini.Classic()
key, err := atkoauth2.TokenKey(conf.TokenKeyUrl)
if err != nil {
logger.Error(err.Error())
return
}
m.Handlers(
atkoauth2.ResourceServer(key),
martini.Logger(),
render.Renderer(render.Options{IndentJSON: true}),
)
m.Get("/rest/orgs/:id/atkinstances", func(params martini.Params, t *jwt.Token, r render.Render) {
cloudController := cc.NewRestCloudController(conf.ApiUrl, t.Raw)
spaceSummaryHelper := service.NewSpaceSummaryHelper()
srv := service.NewAtkListService(cloudController, spaceSummaryHelper)
if len(conf.CommonService) == 0 {
conf.CommonService = "postgres"
}
//TODO: check id param
instances, err := srv.GetAllInstances(conf.ServiceLabel,
conf.ScoringEngineLabel,
conf.CommonService,
params["id"])
if err != nil {
r.JSON(500, err.Error())
}
r.JSON(200, instances)
})
m.Run()
}
开发者ID:blkrs,项目名称:app-launcher-helper,代码行数:56,代码来源:main.go
示例11: init
func init() {
stenoConfig := &steno.Config{
Sinks: []steno.Sink{steno.NewIOSink(os.Stderr)},
Codec: steno.NewJsonCodec(),
Level: steno.LOG_ALL,
}
steno.Init(stenoConfig)
log = steno.NewLogger("common.logger")
}
开发者ID:hfeeki,项目名称:gorouter,代码行数:10,代码来源:init.go
示例12: Test
func Test(t *testing.T) {
config := &steno.Config{
Sinks: []steno.Sink{},
Codec: steno.NewJsonCodec(),
Level: steno.LOG_INFO,
}
steno.Init(config)
log = steno.NewLogger("test")
TestingT(t)
}
开发者ID:johnvilsack,项目名称:golang-stuff,代码行数:13,代码来源:helper_test.go
示例13: InitLog
func InitLog(logFile string) {
c := &steno.Config{
Level: steno.LOG_INFO,
Codec: steno.NewJsonCodec(),
EnableLOC: true,
}
if logFile == "" {
c.Sinks = []steno.Sink{steno.NewIOSink(os.Stdout)}
} else {
c.Sinks = []steno.Sink{steno.NewFileSink(logFile)}
}
steno.Init(c)
obj = steno.NewLogger("")
}
开发者ID:hayatoshimizuBSKYB,项目名称:vcap-services,代码行数:14,代码来源:logger.go
示例14: main
func main() {
stenoConfig := &steno.Config{
Sinks: []steno.Sink{steno.NewIOSink(os.Stderr)},
Codec: steno.NewJsonCodec(),
Level: steno.LOG_ALL,
}
steno.Init(stenoConfig)
log = steno.NewLogger("router.test")
s := true
log.Infof("test %s ", s)
p := &Proxy{}
p.Logger = steno.NewLogger("router.registry")
p.Infof("hello %s", "ss\n")
fmt.Printf("fmt world\n")
}
开发者ID:ndzj081221130,项目名称:router-src,代码行数:18,代码来源:hello.go
示例15: getLogger
func getLogger(debug bool) *gosteno.Logger {
if debug {
level := gosteno.LOG_DEBUG
loggingConfig := &gosteno.Config{
Sinks: make([]gosteno.Sink, 1),
Level: level,
Codec: gosteno.NewJsonCodec(),
EnableLOC: true,
}
loggingConfig.Sinks[0] = gosteno.NewIOSink(os.Stdout)
gosteno.Init(loggingConfig)
}
return gosteno.NewLogger("TestLogger")
}
开发者ID:narayana1208,项目名称:loggregator,代码行数:18,代码来源:base.go
示例16: loadLoggerAndConfig
func loadLoggerAndConfig(c *cli.Context, component string) (logger.Logger, *gosteno.Logger, *config.Config) {
configPath := c.String("config")
if configPath == "" {
fmt.Printf("Config path required")
os.Exit(1)
}
conf, err := config.FromFile(configPath)
if err != nil {
fmt.Printf("Failed to load config: %s", err.Error())
os.Exit(1)
}
sinks := make([]gosteno.Sink, 0, 3)
if conf.LogDirectory != "" {
logName := fmt.Sprintf("hm9000_%s.log", component)
logFile := path.Join(conf.LogDirectory, logName)
sinks = append(sinks, gosteno.NewFileSink(logFile))
} else {
sinks = append(sinks, gosteno.NewIOSink(os.Stdout))
}
sinks = append(sinks, gosteno.NewSyslogSink("vcap.hm9000."+component))
stenoConf := &gosteno.Config{
Sinks: sinks,
Level: conf.LogLevel(),
Codec: gosteno.NewJsonCodec(),
}
gosteno.Init(stenoConf)
steno := gosteno.NewLogger("vcap.hm9000." + component)
hmLogger := logger.NewRealLogger(steno)
debugAddr := c.String("debugAddr")
if debugAddr != "" {
_, err = cf_debug_server.Run(debugAddr, nil)
if err != nil {
hmLogger.Error("Failed to start debug server", err)
os.Exit(1)
}
}
return hmLogger, steno, conf
}
开发者ID:nagyistge,项目名称:hm9000,代码行数:44,代码来源:hm9000.go
示例17: setupStdoutLogger
func setupStdoutLogger() steno.Logger {
level, err := steno.GetLogLevel("debug")
if err != nil {
panic(err)
}
sinks := make([]steno.Sink, 0)
sinks = append(sinks, steno.NewIOSink(os.Stdout))
stenoConfig := &steno.Config{
Sinks: sinks,
Codec: steno.NewJsonCodec(),
Level: level,
}
steno.Init(stenoConfig)
return steno.NewLogger("mongodb_proxy")
}
开发者ID:008by,项目名称:cf-services-contrib-release,代码行数:19,代码来源:server.go
示例18: NewLogger
func NewLogger(file *os.File, level string) (Logger, error) {
if len(level) == 0 {
level = "debug"
}
logLevel, err := steno.GetLogLevel(level)
if err != nil {
return nil, err
}
out := steno.NewIOSink(file)
out.SetCodec(steno.NewJsonPrettifier(steno.EXCLUDE_DATA))
cnf := &steno.Config{
Sinks: []steno.Sink{out},
Level: logLevel,
Port: 8080, // TODO: parameterize?
EnableLOC: false,
}
steno.Init(cnf)
return steno.NewLogger("gonatsd"), nil
}
开发者ID:cloudfoundry-attic,项目名称:gonatsd,代码行数:23,代码来源:logging.go
示例19: SetupSteno
func SetupSteno(logConfig *LogConfig) {
level, err := steno.GetLogLevel(logConfig.Level)
if err != nil {
panic(err)
}
sinks := make([]steno.Sink, 0)
if logConfig.File != "" {
sinks = append(sinks, steno.NewFileSink(logConfig.File))
} else {
sinks = append(sinks, steno.NewIOSink(os.Stdout))
}
if logConfig.Syslog != "" {
sinks = append(sinks, steno.NewSyslogSink(logConfig.Syslog))
}
stenoConfig := &steno.Config{
Sinks: sinks,
Codec: steno.NewJsonCodec(),
Level: level,
}
steno.Init(stenoConfig)
}
开发者ID:9cc9,项目名称:dea_ng,代码行数:24,代码来源:logger.go
示例20: ServeHTTP
// the HTTP request is from dea push cmd, from 10.0.2.15:5678
func (p *Proxy) ServeHTTP(hrw http.ResponseWriter, req *http.Request) {
rw := responseWriter{
ResponseWriter: hrw,
Logger: p.Logger.Copy(),
}
// log for zjlog!
stenoConfig := &steno.Config{
Sinks: []steno.Sink{steno.NewIOSink(os.Stderr)},
Codec: steno.NewJsonCodec(),
Level: steno.LOG_ALL,
}
steno.Init(stenoConfig)
zlog = steno.NewLogger("router.test")
rw.Set("RemoteAddr", req.RemoteAddr)
rw.Set("Host", req.Host)
rw.Set("X-Forwarded-For", req.Header["X-Forwarded-For"]) //
rw.Set("X-Forwarded-Proto", req.Header["X-Forwarded-Proto"])
a := AccessLogRecord{
Request: req,
StartedAt: time.Now(),
}
if req.ProtoMajor != 1 && (req.ProtoMinor != 0 || req.ProtoMinor != 1) {
c, brw, err := rw.Hijack()
if err != nil {
panic(err)
}
fmt.Fprintf(brw, "HTTP/1.0 400 Bad Request\r\n\r\n")
brw.Flush()
c.Close()
return
}
start := time.Now()
// Return 200 OK for heartbeats from LB
if req.UserAgent() == "HTTP-Monitor/1.1" {
rw.WriteHeader(http.StatusOK)
fmt.Fprintln(rw, "ok")
return
}
rw.Infof("zhang:req= %s", req)
bytes, _ := ioutil.ReadAll(req.Body)
parentTx := ""
rootTx := ""
parentName := ""
parent_port := ""
subName := ""
invocationCtx := ""
cat := string(bytes)
var rm reqMessage
u_err := json.Unmarshal(bytes, &rm)
if u_err != nil {
rw.Infof("cat= %s", cat)
rw.Infof("!umarshal error %s ", u_err)
}
if len(rm.Params) > 0 {
str := string(rm.Params[0]) //居然index out of range
rw.Info(str)
arr := strings.Split(str, "|")
// rw.Infof("0=%s", arr[0])
// rw.Infof("1=%s",arr[1])
//
rootTx = arr[1]
parentTx = arr[2]
if len(arr) > 6 {
parentName = arr[3] // actually , this is current component
parent_port = arr[4]
subName = arr[5]
invocationCtx = arr[6]
}
rm.Params[0] = Param(arr[0]) //什么意思???
y, err := json.Marshal(rm)
if err != nil {
rw.Infof("marshal error %s ", err)
}
req.Body = ioutil.NopCloser(strings.NewReader(string(y))) //
} else {
rw.Infof("rm.Params == nil %s", rm.Params)
}
//
rw.Infof("mybody = %s", cat) // bufio.Reader
//所以,或许parentTx要在lookup前
//首先时获取backend,如果此处因为状态,返回nil,那么,就不会再有请求了。
x, ok := p.Lookup(req, rootTx) // get backend, if there is JSESSIONID , router to the same backend
if !ok {
p.Varz.CaptureBadRequest(req)
rw.WriteStatus(http.StatusNotFound)
return
//.........这里部分代码省略.........
开发者ID:ndzj081221130,项目名称:router-src,代码行数:101,代码来源:proxy.go
注:本文中的github.com/cloudfoundry/gosteno.Init函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论