Log errors on elmah.io from Go(lang) web applications.
- Introduction
- Requirements
- Installation
- Usage
- Bugs / Feature Reporting
- Feedback
- Continuous Integration
- License
This package IS NOT OFFICIAL, meaning that nor the elmah.io team or any of their developers have worked on this. This is just a user made package to start logging errors on elmah.io, waiting for an official Go(lang) package. This means that i'm not affiliated with elmah.io in any means, and therefore any bug or missing feature on the package are not elmah.io's fault.
Also, this package gives just the raw basics for logging errors on elmah.io. For my personal use this is fine, however you can suggest changes or even contributing to them as described in the Feedback section of this file.
- Go 1.10 or higher. Although this package has no dependencies, so it should work on all versions of Go, is always recommended to have the latest version of the language installed.
- An elmah.io account
The recommended way to get started using the elmah.io Go package is by using dep
to install the dependency in your project.
dep ensure -add "github.com/jimiit92/elmah.io-go@~1.0.0"
To get started with the package, import the elmahio
package and use the Setup
function in your main
function:
import (
elmahio "github.com/gimignanof/elmahio-go"
)
err := elmahio.Setup("Your-API-Key", "Elmah.io-Log-Id")
You can also setup the Application Version and the Application Source using the SetupVersion
and SetupSource
functions:
elmahio.SetVersion(1.0)
elmahio.SetSource("Application Source")
To log the erorr on elmah.io automatically from a web function, you need to declare the function like this:
func handler(w http.ResponseWriter, r *http.Request) (*http.Response, error) {
// Do something and return a response,error pair
}
and then serve the function from the ElmahHandler
wrapped like this (the example uses the gorilla/mux package):
router.Handle("/", elmahio.ElmahHandler(handler))
Here is listed and example application that uses the elmah.io package and writes an error on elmah.io. The project uses the gorilla/mux package to create a rotuer and handle the route, however you are free to use any router package you want (or even none) as long as the handler function declaration remains the same and you can wrap it inside the ElmahHandler
middleware
New Features and bugs can be reported on the Issues tab
The elmah.io package is not feature complete, so any help is appreciated. You can clone and edit this repository to add as many features as you want. Keep in mind that each commit will be reviewed in order to mantain this package healty and to avoid malicious or un-necessary code. See our contribution guidelines for details.
The elmah.io package is licensed under the MIT License.