Bumps the minor-and-patch group with 9 updates: | Package | From | To | | --- | --- | --- | | [github.com/nats-io/nats-server/v2](https://github.com/nats-io/nats-server) | `2.14.4` | `2.14.5` | | [github.com/nats-io/nats.go](https://github.com/nats-io/nats.go) | `1.52.0` | `1.53.1` | | [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) | `2.32.0` | `2.32.1` | | [github.com/sirupsen/logrus](https://github.com/sirupsen/logrus) | `1.9.4` | `1.10.0` | | [golang.org/x/crypto](https://github.com/golang/crypto) | `0.54.0` | `0.55.0` | | [golang.org/x/image](https://github.com/golang/image) | `0.44.0` | `0.45.0` | | [golang.org/x/net](https://github.com/golang/net) | `0.57.0` | `0.58.0` | | [golang.org/x/text](https://github.com/golang/text) | `0.40.0` | `0.41.0` | | google.golang.org/protobuf | `1.36.11` | `1.36.12` | Updates `github.com/nats-io/nats-server/v2` from 2.14.4 to 2.14.5 - [Release notes](https://github.com/nats-io/nats-server/releases) - [Changelog](https://github.com/nats-io/nats-server/blob/main/RELEASES.md) - [Commits](https://github.com/nats-io/nats-server/compare/v2.14.4...v2.14.5) Updates `github.com/nats-io/nats.go` from 1.52.0 to 1.53.1 - [Release notes](https://github.com/nats-io/nats.go/releases) - [Commits](https://github.com/nats-io/nats.go/compare/v1.52.0...v1.53.1) Updates `github.com/onsi/ginkgo/v2` from 2.32.0 to 2.32.1 - [Release notes](https://github.com/onsi/ginkgo/releases) - [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/ginkgo/compare/v2.32.0...v2.32.1) Updates `github.com/sirupsen/logrus` from 1.9.4 to 1.10.0 - [Release notes](https://github.com/sirupsen/logrus/releases) - [Changelog](https://github.com/sirupsen/logrus/blob/master/CHANGELOG.md) - [Commits](https://github.com/sirupsen/logrus/compare/v1.9.4...v1.10.0) Updates `golang.org/x/crypto` from 0.54.0 to 0.55.0 - [Commits](https://github.com/golang/crypto/compare/v0.54.0...v0.55.0) Updates `golang.org/x/image` from 0.44.0 to 0.45.0 - [Commits](https://github.com/golang/image/compare/v0.44.0...v0.45.0) Updates `golang.org/x/net` from 0.57.0 to 0.58.0 - [Commits](https://github.com/golang/net/compare/v0.57.0...v0.58.0) Updates `golang.org/x/text` from 0.40.0 to 0.41.0 - [Release notes](https://github.com/golang/text/releases) - [Commits](https://github.com/golang/text/compare/v0.40.0...v0.41.0) Updates `google.golang.org/protobuf` from 1.36.11 to 1.36.12 --- updated-dependencies: - dependency-name: github.com/nats-io/nats-server/v2 dependency-version: 2.14.5 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: minor-and-patch - dependency-name: github.com/nats-io/nats.go dependency-version: 1.53.1 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: minor-and-patch - dependency-name: github.com/onsi/ginkgo/v2 dependency-version: 2.32.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: minor-and-patch - dependency-name: github.com/sirupsen/logrus dependency-version: 1.10.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: minor-and-patch - dependency-name: golang.org/x/crypto dependency-version: 0.55.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: minor-and-patch - dependency-name: golang.org/x/image dependency-version: 0.45.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: minor-and-patch - dependency-name: golang.org/x/net dependency-version: 0.58.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: minor-and-patch - dependency-name: golang.org/x/text dependency-version: 0.41.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: minor-and-patch - dependency-name: google.golang.org/protobuf dependency-version: 1.36.12 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: minor-and-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
77 lines
2.7 KiB
Go
77 lines
2.7 KiB
Go
package logrus
|
|
|
|
// The following code was sourced and modified from the
|
|
// https://github.com/tebeka/atexit package governed by the following license:
|
|
//
|
|
// Copyright (c) 2012 Miki Tebeka <miki.tebeka@gmail.com>.
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
// this software and associated documentation files (the "Software"), to deal in
|
|
// the Software without restriction, including without limitation the rights to
|
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
// the Software, and to permit persons to whom the Software is furnished to do so,
|
|
// subject to the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included in all
|
|
// copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
var handlers = []func(){}
|
|
|
|
func runHandler(handler func()) {
|
|
defer func() {
|
|
if err := recover(); err != nil {
|
|
fmt.Fprintln(os.Stderr, "Error: Logrus exit handler error:", err)
|
|
}
|
|
}()
|
|
|
|
handler()
|
|
}
|
|
|
|
func runHandlers() {
|
|
for _, handler := range handlers {
|
|
runHandler(handler)
|
|
}
|
|
}
|
|
|
|
// Exit runs all the Logrus atexit handlers and then terminates the program using os.Exit(code)
|
|
func Exit(code int) {
|
|
runHandlers()
|
|
os.Exit(code)
|
|
}
|
|
|
|
// RegisterExitHandler appends a Logrus Exit handler to the list of handlers,
|
|
// call logrus.Exit to invoke all handlers. The handlers will also be invoked when
|
|
// any Fatal log entry is made.
|
|
//
|
|
// This method is useful when a caller wishes to use logrus to log a fatal
|
|
// message but also needs to gracefully shutdown. An example usecase could be
|
|
// closing database connections, or sending an alert that the application is
|
|
// closing.
|
|
func RegisterExitHandler(handler func()) {
|
|
handlers = append(handlers, handler)
|
|
}
|
|
|
|
// DeferExitHandler prepends a Logrus Exit handler to the list of handlers,
|
|
// call logrus.Exit to invoke all handlers. The handlers will also be invoked when
|
|
// any Fatal log entry is made.
|
|
//
|
|
// This method is useful when a caller wishes to use logrus to log a fatal
|
|
// message but also needs to gracefully shutdown. An example usecase could be
|
|
// closing database connections, or sending an alert that the application is
|
|
// closing.
|
|
func DeferExitHandler(handler func()) {
|
|
handlers = append([]func(){handler}, handlers...)
|
|
}
|