logger := lager.NewLogger("example-app") logger.RegisterSink(lager.NewWriterSink(os.Stdout, lager.DEBUG)) err := someFunction() if err != nil { logger.Fatal("Error occurred", err) }
logger := lager.NewLogger("example-app") logger.RegisterSink(lager.NewWriterSink(os.Stdout, lager.DEBUG)) db, err := sql.Open("postgres", "dbname=exampledb user=exampleuser password=examplepass") if err != nil { logger.Fatal("Unable to connect to database", err) }In this example, the library is used to create a new logger and register a writer sink to log messages to the console. Then, the application tries to connect to a database and if an error occurs, the `Fatal` method is used to log the error message and exit the program with a non-zero exit code. Package library: go code.cloudfoundry.org.lager Logger Fatal is a part of the Lager logging framework, which is used in Cloud Foundry for logging.