Debian Codegraph @

alt_exit.go

raw symbols SCIP
1 package logrusscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/
2
3 // The following code was sourced and modified from the
4 // https://github.com/tebeka/atexit package governed by the following license:
5 //
6 // Copyright (c) 2012 Miki Tebeka <[email protected]>.
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy of
9 // this software and associated documentation files (the "Software"), to deal in
10 // the Software without restriction, including without limitation the rights to
11 // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
12 // the Software, and to permit persons to whom the Software is furnished to do so,
13 // subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in all
16 // copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
20 // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
21 // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
22 // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
25 import (
26 "fmtscip-go gomod github.com/golang/go/src go1.13 fmt/"
27 "osscip-go gomod github.com/golang/go/src go1.13 os/"
28 )
29
30 var handlersscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/handlers. = []func(){}
31
32 func runHandlerscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/runHandler().(handler func()) {
33 defer func() {
34 if err := recover(); err != nil {
35 fmtscip-go gomod github.com/golang/go/src go1.13 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.13 fmt/Fprintln().(osscip-go gomod github.com/golang/go/src go1.13 os/.Stderrscip-go gomod github.com/golang/go/src go1.13 os/Stderr., "Error: Logrus exit handler error:", err)
36 }
37 }()
38
39 handler()
40 }
41
42 func runHandlersscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/runHandlers().() {
43 for _, handler := range handlersscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/handlers. {
44 runHandlerscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/runHandler().(handler)
45 }
46 }
47
48 // Exit runs all the Logrus atexit handlers and then terminates the program using os.Exit(code)
49 func Exitscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Exit().(code int) {
50 runHandlersscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/runHandlers().()
51 osscip-go gomod github.com/golang/go/src go1.13 os/.Exitscip-go gomod github.com/golang/go/src go1.13 os/Exit().(code)
52 }
53
54 // RegisterExitHandler appends a Logrus Exit handler to the list of handlers,
55 // call logrus.Exit to invoke all handlers. The handlers will also be invoked when
56 // any Fatal log entry is made.
57 //
58 // This method is useful when a caller wishes to use logrus to log a fatal
59 // message but also needs to gracefully shutdown. An example usecase could be
60 // closing database connections, or sending a alert that the application is
61 // closing.
62 func RegisterExitHandlerscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/RegisterExitHandler().(handler func()) {
63 handlersscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/handlers. = append(handlersscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/handlers., handler)
64 }
65
66 // DeferExitHandler prepends a Logrus Exit handler to the list of handlers,
67 // call logrus.Exit to invoke all handlers. The handlers will also be invoked when
68 // any Fatal log entry is made.
69 //
70 // This method is useful when a caller wishes to use logrus to log a fatal
71 // message but also needs to gracefully shutdown. An example usecase could be
72 // closing database connections, or sending a alert that the application is
73 // closing.
74 func DeferExitHandlerscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/DeferExitHandler().(handler func()) {
75 handlersscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/handlers. = append([]func(){handler}, handlersscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/handlers....)
76 }