• k3_530446
  • 7MB
  • zip
  • 0
  • VIP专享
  • 0
  • 2022-04-14 19:51
用于Azure文件存储的Docker卷驱动程序 这是一个Docker Volume Driver,它使用将云上的文件共享作为卷挂载到Docker容器。 它使用Azure文件存储的网络文件共享( )功能。 为什么? 您可以创建可从一台主机无缝迁移到另一台主机的Docker容器。 您可以在不同主机上运行的多个容器之间共享卷。 用法 在部署此插件之前,请阅读以下文章: 并了解限制以及适合在Azure File Service上存储数据的应用程序类型。 安装 确保您在Azure上具有存储帐户(使用Azure CLI或门户)。 可以使用以下命令安装Docker管理的插件: $ docker plugin install jmaitrehenry/azurefile[:version] \ AZURE_STORAGE_ACCOUNT=xxx \ AZURE_STORAGE_ACCOUNT_KEY=yyy 上面命令中的[:version]组件被称为Docker标签,其值遵循语义版本控制模型。 省略版本等同于指定最新标签-插件的最新,稳定版本。 注意:存储帐户必须与虚拟机位
# Logrus <img src="" width="40" height="40" alt=":walrus:" class="emoji" title=":walrus:"/>&nbsp;[![Build Status](](;[![godoc reference](][godoc] Logrus is a structured logger for Go (golang), completely API compatible with the standard library logger. [Godoc][godoc]. **Please note the Logrus API is not yet stable (pre 1.0). Logrus itself is completely stable and has been used in many large deployments. The core API is unlikely to change much but please version control your Logrus to make sure you aren't fetching latest `master` on every build.** Nicely color-coded in development (when a TTY is attached, otherwise just plain text): ![Colored]( With `log.Formatter = new(logrus.JSONFormatter)`, for easy parsing by logstash or Splunk: ```json {"animal":"walrus","level":"info","msg":"A group of walrus emerges from the ocean","size":10,"time":"2014-03-10 19:57:38.562264131 -0400 EDT"} {"level":"warning","msg":"The group's number increased tremendously!", "number":122,"omg":true,"time":"2014-03-10 19:57:38.562471297 -0400 EDT"} {"animal":"walrus","level":"info","msg":"A giant walrus appears!", "size":10,"time":"2014-03-10 19:57:38.562500591 -0400 EDT"} {"animal":"walrus","level":"info","msg":"Tremendously sized cow enters the ocean.", "size":9,"time":"2014-03-10 19:57:38.562527896 -0400 EDT"} {"level":"fatal","msg":"The ice breaks!","number":100,"omg":true, "time":"2014-03-10 19:57:38.562543128 -0400 EDT"} ``` With the default `log.Formatter = new(&log.TextFormatter{})` when a TTY is not attached, the output is compatible with the [logfmt]( format: ```text time="2015-03-26T01:27:38-04:00" level=debug msg="Started observing beach" animal=walrus number=8 time="2015-03-26T01:27:38-04:00" level=info msg="A group of walrus emerges from the ocean" animal=walrus size=10 time="2015-03-26T01:27:38-04:00" level=warning msg="The group's number increased tremendously!" number=122 omg=true time="2015-03-26T01:27:38-04:00" level=debug msg="Temperature changes" temperature=-4 time="2015-03-26T01:27:38-04:00" level=panic msg="It's over 9000!" animal=orca size=9009 time="2015-03-26T01:27:38-04:00" level=fatal msg="The ice breaks!" err=&{0x2082280c0 map[animal:orca size:9009] 2015-03-26 01:27:38.441574009 -0400 EDT panic It's over 9000!} number=100 omg=true exit status 1 ``` #### Example The simplest way to use Logrus is simply the package-level exported logger: ```go package main import ( log "" ) func main() { log.WithFields(log.Fields{ "animal": "walrus", }).Info("A walrus appears") } ``` Note that it's completely api-compatible with the stdlib logger, so you can replace your `log` imports everywhere with `log ""` and you'll now have the flexibility of Logrus. You can customize it all you want: ```go package main import ( "os" log "" ) func init() { // Log as JSON instead of the default ASCII formatter. log.SetFormatter(&log.JSONFormatter{}) // Output to stderr instead of stdout, could also be a file. log.SetOutput(os.Stderr) // Only log the warning severity or above. log.SetLevel(log.WarnLevel) } func main() { log.WithFields(log.Fields{ "animal": "walrus", "size": 10, }).Info("A group of walrus emerges from the ocean") log.WithFields(log.Fields{ "omg": true, "number": 122, }).Warn("The group's number increased tremendously!") log.WithFields(log.Fields{ "omg": true, "number": 100, }).Fatal("The ice breaks!") // A common pattern is to re-use fields between logging statements by re-using // the logrus.Entry returned from WithFields() contextLogger := log.WithFields(log.Fields{ "common": "this is a common field", "other": "I also should be logged always", }) contextLogger.Info("I'll be logged with common and other field") contextLogger.Info("Me too") } ``` For more advanced usage such as logging to multiple locations from the same application, you can also create an instance of the `logrus` Logger: ```go package main import ( "" ) // Create a new instance of the logger. You can have any number of instances. var log = logrus.New() func main() { // The API for setting attributes is a little different than the package level // exported logger. See Godoc. log.Out = os.Stderr log.WithFields(logrus.Fields{ "animal": "walrus", "size": 10, }).Info("A group of walrus emerges from the ocean") } ``` #### Fields Logrus encourages careful, structured logging though logging fields instead of long, unparseable error messages. For example, instead of: `log.Fatalf("Failed to send event %s to topic %s with key %d")`, you should log the much more discoverable: ```go log.WithFields(log.Fields{ "event": event, "topic": topic, "key": key, }).Fatal("Failed to send event") ``` We've found this API forces you to think about logging in a way that produces much more useful logging messages. We've been in countless situations where just a single added field to a log statement that was already there would've saved us hours. The `WithFields` call is optional. In general, with Logrus using any of the `printf`-family functions should be seen as a hint you should add a field, however, you can still use the `printf`-family functions with Logrus. #### Hooks You can add hooks for logging levels. For example to send errors to an exception tracking service on `Error`, `Fatal` and `Panic`, info to StatsD or log to multiple places simultaneously, e.g. syslog. Logrus comes with [built-in hooks](hooks/). Add those, or your custom hook, in `init`: ```go import ( log "" "" // the package is named "aibrake" logrus_syslog "" "log/syslog" ) func init() { // Use the Airbrake hook to report errors that have Error severity or above to // an exception tracker. You can create custom hooks, see the Hooks section. log.AddHook(airbrake.NewHook(123, "xyz", "production")) hook, err := logrus_syslog.NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "") if err != nil { log.Error("Unable to connect to local syslog daemon") } else { log.AddHook(hook) } } ``` Note: Syslog hook also support connecting to local syslog (Ex. "/dev/log" or "/var/run/syslog" or "/var/run/log"). For the detail, please check the [syslog hook README](hooks/syslog/ | Hook | Description | | ----- | ----------- | | [Airbrake]( | Send errors to the Airbrake API V3. Uses the official [`gobrake`]( behind the scenes. | | [Airbrake "legacy"]( | Send errors to an exception tracking service compatible with the Airbrake API V2. Uses [`airbrake-go`]( behind the scenes. | | [Papertrail]( | Send errors to the [Papertrail]( hosted logging service via UDP. | | [Syslog]( | Send errors to remote syslog server. Uses standard library `log/syslog` behind the scenes. | | [Bugsnag]( | Send errors to the Bugsnag exception tracking service. | | [Sentry]( | Send errors to the Sentry error logging and aggregation service. | | [Hiprus]( | Send errors to a channel in hipchat. | | [Logrusly]( | Send logs to [Loggly](