本文整理汇总了Golang中github.com/Sirupsen/logrus.GetLevel函数的典型用法代码示例。如果您正苦于以下问题:Golang GetLevel函数的具体用法?Golang GetLevel怎么用?Golang GetLevel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetLevel函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestLoadDaemonCliConfigWithLogLevel
func TestLoadDaemonCliConfigWithLogLevel(t *testing.T) {
c := &daemon.Config{}
common := &cli.CommonFlags{}
f, err := ioutil.TempFile("", "docker-config-")
if err != nil {
t.Fatal(err)
}
configFile := f.Name()
f.Write([]byte(`{"log-level": "warn"}`))
f.Close()
flags := mflag.NewFlagSet("test", mflag.ContinueOnError)
flags.String([]string{"-log-level"}, "", "")
loadedConfig, err := loadDaemonCliConfig(c, flags, common, configFile)
if err != nil {
t.Fatal(err)
}
if loadedConfig == nil {
t.Fatalf("expected configuration %v, got nil", c)
}
if loadedConfig.LogLevel != "warn" {
t.Fatalf("expected warn log level, got %v", loadedConfig.LogLevel)
}
if logrus.GetLevel() != logrus.WarnLevel {
t.Fatalf("expected warn log level, got %v", logrus.GetLevel())
}
}
开发者ID:supasate,项目名称:docker,代码行数:30,代码来源:daemon_test.go
示例2: ReadBinary
// ReadBinary reads bytes into a Report.
//
// Will decompress the binary if gzipped is true, and will use the given
// codecHandle to decode it.
func (rep *Report) ReadBinary(r io.Reader, gzipped bool, codecHandle codec.Handle) error {
var err error
var compressedSize, uncompressedSize uint64
// We have historically had trouble with reports being too large. We are
// keeping this instrumentation around to help us implement
// weaveworks/scope#985.
if log.GetLevel() == log.DebugLevel {
r = byteCounter{next: r, count: &compressedSize}
}
if gzipped {
r, err = gzip.NewReader(r)
if err != nil {
return err
}
}
if log.GetLevel() == log.DebugLevel {
r = byteCounter{next: r, count: &uncompressedSize}
}
if err := codec.NewDecoder(r, codecHandle).Decode(&rep); err != nil {
return err
}
log.Debugf(
"Received report sizes: compressed %d bytes, uncompressed %d bytes (%.2f%%)",
compressedSize,
uncompressedSize,
float32(compressedSize)/float32(uncompressedSize)*100,
)
return nil
}
开发者ID:CNDonny,项目名称:scope,代码行数:34,代码来源:marshal.go
示例3: TestDisableDebug
func TestDisableDebug(t *testing.T) {
DisableDebug()
if os.Getenv("DEBUG") != "" {
t.Fatalf("expected DEBUG=\"\", got %s\n", os.Getenv("DEBUG"))
}
if logrus.GetLevel() != logrus.InfoLevel {
t.Fatalf("expected log level %v, got %v\n", logrus.InfoLevel, logrus.GetLevel())
}
}
开发者ID:CadeLaRen,项目名称:docker-3,代码行数:9,代码来源:debug_test.go
示例4: TestDebugMode
func (s *ConfigTestSuite) TestDebugMode(c *C) {
type AnonConfig struct {
Debug bool `json:"Debug"`
}
utils.WriteJsonFile(AnonConfig{Debug: true}, s.configPath)
LoadSettingsFromFile()
c.Assert(log.GetLevel(), Equals, log.DebugLevel)
utils.WriteJsonFile(AnonConfig{Debug: false}, s.configPath)
// Not need to reset because the conf file exists and loading it will overwrite
LoadSettingsFromFile()
c.Assert(log.GetLevel(), Equals, log.InfoLevel)
}
开发者ID:slok,项目名称:daton,代码行数:13,代码来源:load_test.go
示例5: TestClientDebugEnabled
func TestClientDebugEnabled(t *testing.T) {
defer utils.DisableDebug()
clientFlags.Common.FlagSet.Parse([]string{"-D"})
clientFlags.PostParse()
if os.Getenv("DEBUG") != "1" {
t.Fatal("expected debug enabled, got false")
}
if logrus.GetLevel() != logrus.DebugLevel {
t.Fatalf("expected logrus debug level, got %v", logrus.GetLevel())
}
}
开发者ID:CrocdileChan,项目名称:docker,代码行数:13,代码来源:docker_test.go
示例6: TestEnableDebug
func TestEnableDebug(t *testing.T) {
defer func() {
os.Setenv("DEBUG", "")
logrus.SetLevel(logrus.InfoLevel)
}()
EnableDebug()
if os.Getenv("DEBUG") != "1" {
t.Fatalf("expected DEBUG=1, got %s\n", os.Getenv("DEBUG"))
}
if logrus.GetLevel() != logrus.DebugLevel {
t.Fatalf("expected log level %v, got %v\n", logrus.DebugLevel, logrus.GetLevel())
}
}
开发者ID:CadeLaRen,项目名称:docker-3,代码行数:13,代码来源:debug_test.go
示例7: rquloop
func (n *node) rquloop() {
for {
time.Sleep(rqudelay)
now := time.Now()
n.pqs.mux.RLock()
for k, v := range n.pqs.queues {
v.L.Lock()
_, exist := v.queue[v.waitingSeqid]
if v.maxseqid > v.waitingSeqid && !exist && v.waitTime.Before(now.Add(-rqudelay)) {
senderid, connid := unpacketKey(k)
waiting := v.waitingSeqid
v.waitTime = now.Add(rqudelay)
go func() {
n.write(&packet{
Senderid: senderid,
Connid: connid,
Seqid: waiting,
Cmd: rqu,
Time: now.UnixNano(),
})
if logrus.GetLevel() >= logrus.DebugLevel {
logrus.WithFields(logrus.Fields{
"Connid": connid,
"StillWaiting": waiting,
"role": n.role(),
}).Debugln("send packet request")
}
}()
}
v.L.Unlock()
}
n.pqs.mux.RUnlock()
}
}
开发者ID:tomasen,项目名称:trafcacc,代码行数:34,代码来源:node.go
示例8: findContainers
func (c *Command) findContainers(client *docker.Client) ([]docker.APIContainers, error) {
results, err := client.ListContainers(docker.ListContainersOptions{})
if err != nil {
return nil, err
}
stopped := make([]docker.APIContainers, 0)
for _, container := range results {
if log.GetLevel() >= log.DebugLevel {
b, err := json.Marshal(&container)
if err == nil {
log.Debugln("check container: ", string(b))
}
}
if c.Name != "" && !strings.HasPrefix(container.ID, c.Name) {
continue
} else if c.Image != "" && container.Image != c.Image {
continue
}
log.WithFields(log.Fields{
"id": container.ID,
}).Debugln("find target container.")
stopped = append(stopped, container)
}
return stopped, nil
}
开发者ID:jmptrader,项目名称:beacon,代码行数:28,代码来源:command.go
示例9: EnvmanRun
// EnvmanRun ...
func EnvmanRun(envstorePth, workDirPth string, cmd []string) (int, error) {
logLevel := log.GetLevel().String()
args := []string{"--loglevel", logLevel, "--path", envstorePth, "run"}
args = append(args, cmd...)
return cmdex.RunCommandInDirAndReturnExitCode(workDirPth, "envman", args...)
}
开发者ID:andrewhavens,项目名称:bitrise,代码行数:8,代码来源:run.go
示例10: TestWithLevel
// TestWithLevel run callable with changed logging output and log level
func TestWithLevel(level string, callable func(*bytes.Buffer)) {
originalLevel := logrus.GetLevel()
defer logrus.SetLevel(originalLevel)
SetLevel(level)
Test(callable)
}
开发者ID:xyntrix,项目名称:go-carbon,代码行数:8,代码来源:logger.go
示例11: listen
func (s *serv) listen() {
switch s.proto {
case tcp:
ln, err := net.Listen("tcp", s.addr)
if err != nil {
logrus.Fatalln("net.Listen error", s.addr, err)
}
s.setalive()
if logrus.GetLevel() >= logrus.DebugLevel {
logrus.Debugln("listen to", s.addr)
}
go acceptTCP(ln, s.tcphandler)
case udp:
udpaddr, err := net.ResolveUDPAddr("udp", s.addr)
if err != nil {
logrus.Fatalln("net.ResolveUDPAddr error", s.addr, err)
}
udpconn, err := net.ListenUDP("udp", udpaddr)
if err != nil {
logrus.Fatalln("net.ListenUDP error", udpaddr, err)
}
s.setalive()
go func() {
for {
s.udphandler(udpconn)
}
}()
}
}
开发者ID:tomasen,项目名称:trafcacc,代码行数:33,代码来源:server.go
示例12: runCharon
func runCharon(logFile string) {
// Ignore error
os.Remove("/var/run/charon.vici")
args := []string{}
for _, i := range strings.Split("dmn|mgr|ike|chd|cfg|knl|net|asn|tnc|imc|imv|pts|tls|esp|lib", "|") {
args = append(args, "--debug-"+i)
if logrus.GetLevel() == logrus.DebugLevel {
args = append(args, "3")
} else {
args = append(args, "1")
}
}
cmd := exec.Command("charon", args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if logFile != "" {
output, err := os.OpenFile(logFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
logrus.Fatalf("Failed to log to file %s: %v", logFile, err)
}
defer output.Close()
cmd.Stdout = output
cmd.Stderr = output
}
cmd.SysProcAttr = &syscall.SysProcAttr{
Pdeathsig: syscall.SIGTERM,
}
logrus.Fatalf("charon exited: %v", cmd.Run())
}
开发者ID:ibuildthecloud,项目名称:rancher-net,代码行数:34,代码来源:ipsec.go
示例13: ExecuteWithOutput
// ExecuteWithOutput executes a command. If logrus's verbosity level is set to
// debug, it will continuously output the command's output while it waits.
func ExecuteWithOutput(cmd *exec.Cmd) (outStr string, err error) {
// connect to stdout and stderr for filtering purposes
errPipe, err := cmd.StderrPipe()
if err != nil {
log.WithFields(log.Fields{
"cmd": cmd.Args,
}).Fatal("Couldn't connect to command's stderr")
}
outPipe, err := cmd.StdoutPipe()
if err != nil {
log.WithFields(log.Fields{
"cmd": cmd.Args,
}).Fatal("Couldn't connect to command's stdout")
}
_ = bufio.NewReader(errPipe)
outReader := bufio.NewReader(outPipe)
// start the command and filter the output
if err = cmd.Start(); err != nil {
return "", err
}
outScanner := bufio.NewScanner(outReader)
for outScanner.Scan() {
outStr += outScanner.Text() + "\n"
if log.GetLevel() == log.DebugLevel {
fmt.Println(outScanner.Text())
}
}
err = cmd.Wait()
return outStr, err
}
开发者ID:lokinell,项目名称:microservices-infrastructure,代码行数:33,代码来源:mi-deploy.go
示例14: SendMessage
func (server *Server) SendMessage(ctx context.Context, in *pb.Message) (*pb.SendMessageResponse, error) {
if in.Language == "" {
in.Language = server.Config.DefaultLanguage
}
n := len(in.Targets)
logrus.Debugf("SendMessage with event='%s' and language='%s' to #%d target(s)", in.Event, in.Language, n)
results := make([]*pb.MessageTargetResponse, 0)
ch := make(chan drivers.DriverResult, 1)
go server.send(ctx, in, ch)
for i := 0; i < n; i++ {
r := <-ch
resp := &pb.MessageTargetResponse{
Target: string(r.Type),
Output: "Success",
}
if r.Err != nil {
resp.Output = r.Err.Error()
}
results = append(results, resp)
}
if logrus.GetLevel() >= logrus.DebugLevel {
for _, t := range results {
logrus.Debugf("SendMessage output[%s]= %s", t.Target, t.Output)
}
}
return pb.NewMessageResponse(results), nil
}
开发者ID:otsimo,项目名称:simple-notifications,代码行数:28,代码来源:service.go
示例15: ServeHTTP
func (s *CacheHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
var uid string
if session, ok := SessionFromContext(req.Context()); ok {
uid = session.Token.UidString()
} else {
sendRequestProblem(w, req, http.StatusBadRequest, errors.New("CacheHandler no UID"))
return
}
if req.Method == "GET" && infoCollectionsRoute.MatchString(req.URL.Path) { // info/collections
s.infoCollection(uid, w, req)
} else if req.Method == "GET" && infoConfigurationRoute.MatchString(req.URL.Path) { // info/configuration
s.infoConfiguration(uid, w, req)
} else {
// clear the cache for the user
if req.Method == "POST" || req.Method == "PUT" || req.Method == "DELETE" {
if log.GetLevel() == log.DebugLevel {
log.WithFields(log.Fields{
"uid": uid,
}).Debug("CacheHandler clear")
}
s.cache.Set(uid, nil)
}
s.handler.ServeHTTP(w, req)
return
}
}
开发者ID:mozilla-services,项目名称:go-syncstorage,代码行数:28,代码来源:cacheHandler.go
示例16: debugCmdFuncInfo
func debugCmdFuncInfo(c *cli.Context) {
if log.GetLevel() < log.DebugLevel {
return
}
// get function name
dbgMsg := ""
pc, _, _, ok := runtime.Caller(1)
if ok {
dbgMsg = runtime.FuncForPC(pc).Name()
i := strings.LastIndex(dbgMsg, "/")
if i != -1 {
dbgMsg = dbgMsg[i+1:]
}
} else {
dbgMsg = "<unknown function name>"
}
dbgMsg = fmt.Sprintf("func %s", dbgMsg)
// get used flags
for _, flag := range c.FlagNames() {
dbgMsg = fmt.Sprintf("%s\n\t%s=%+v", dbgMsg, flag, c.Generic(flag))
}
log.Debugf(dbgMsg)
}
开发者ID:odacremolbap,项目名称:concerto,代码行数:25,代码来源:cmd_helper.go
示例17: initConfigWrite
// Initialize the repo to be used to announce/write config.
// A seperate repo is initialized to read incoming announcements
func initConfigWrite(networkCidr *net.IPNet, hostIface, gitRepoURL string) {
var err error
if !pathExists(EndpointPushSubDir) {
log.Debugf("[ %s ] dir not found, creating it..", EndpointPushSubDir)
if err = CreatePaths(EndpointPushSubDir); err != nil {
log.Fatalf("Could not create the directory [ %s ]: %s", EndpointPushSubDir, err)
} else {
log.Warnf("Succesfully created the config path [ %s ]", EndpointPushSubDir)
}
}
// Create the cache subdirectories
time.Sleep(1 * time.Second)
localEndpointIP, _ := getIfaceAddrStr(hostIface)
// Fun Go fact: using a + with sprintf is faster then %s since it uses reflection
endpointFile := fmt.Sprintf(localEndpointIP + dotjson)
log.Debugf("The endpoint file name is [ %s ] ", endpointFile)
log.Debugf("Anouncing this endpoint using the source [ %s ] and advertsing network [ %s ] to datastore file [ %s ]", networkCidr, localEndpointIP, endpointFile)
endpointConfig := &LocalEndpoint{
Endpoint: localEndpointIP,
Network: networkCidr.String(),
Meta: "",
}
var configAnnounce []LocalEndpoint
configAnnounce = append(configAnnounce, *endpointConfig)
marshallConfig(configAnnounce, configFormat, endpointFile)
if log.GetLevel().String() == "debug" {
printPretty(configAnnounce, "json")
}
// Parse the repo name
defer gitPushConfig()
}
开发者ID:nerdalert,项目名称:gitnet-overlay,代码行数:33,代码来源:git_writes.go
示例18: EnvmanEnvstoreTest
// EnvmanEnvstoreTest ...
func EnvmanEnvstoreTest(pth string) error {
logLevel := log.GetLevel().String()
args := []string{"--loglevel", logLevel, "--path", pth, "print"}
cmd := exec.Command("envman", args...)
cmd.Stderr = os.Stderr
return cmd.Run()
}
开发者ID:bazscsa,项目名称:bitrise-cli,代码行数:8,代码来源:run.go
示例19: createBitriseCallArgs
func createBitriseCallArgs(bitriseCommandToUse, inventoryBase64, configBase64, runParamJSONBase64, workflowNameOrTriggerPattern string) []string {
logLevel := log.GetLevel().String()
retArgs := []string{
"--loglevel", logLevel,
}
if len(runParamJSONBase64) > 0 {
// new style, all params in one (Base64 encoded) JSON
retArgs = append(retArgs, bitriseCommandToUse, "--json-params-base64", runParamJSONBase64)
} else {
// old style, separate params
retArgs = append(retArgs, bitriseCommandToUse, workflowNameOrTriggerPattern)
}
// config / bitrise.yml
retArgs = append(retArgs, "--config-base64", configBase64)
// inventory / secrets
if inventoryBase64 != "" {
retArgs = append(retArgs, "--inventory-base64", inventoryBase64)
}
return retArgs
}
开发者ID:bitrise-tools,项目名称:bitrise-bridge,代码行数:25,代码来源:run.go
示例20: handleWithGlobalMiddlewares
// handleWithGlobalMiddlwares wraps the handler function for a request with
// the server's global middlewares. The order of the middlewares is backwards,
// meaning that the first in the list will be evaluated last.
func (s *Server) handleWithGlobalMiddlewares(handler httputils.APIFunc) httputils.APIFunc {
next := handler
handleVersion := middleware.NewVersionMiddleware(dockerversion.Version, api.DefaultVersion, api.MinVersion)
next = handleVersion(next)
if s.cfg.EnableCors {
handleCORS := middleware.NewCORSMiddleware(s.cfg.CorsHeaders)
next = handleCORS(next)
}
handleUserAgent := middleware.NewUserAgentMiddleware(s.cfg.Version)
next = handleUserAgent(next)
// Only want this on debug level
if s.cfg.Logging && logrus.GetLevel() == logrus.DebugLevel {
next = middleware.DebugRequestMiddleware(next)
}
if len(s.cfg.AuthorizationPluginNames) > 0 {
s.authZPlugins = authorization.NewPlugins(s.cfg.AuthorizationPluginNames)
handleAuthorization := middleware.NewAuthorizationMiddleware(s.authZPlugins)
next = handleAuthorization(next)
}
return next
}
开发者ID:contiv,项目名称:docker,代码行数:30,代码来源:middleware.go
注:本文中的github.com/Sirupsen/logrus.GetLevel函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论