Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.
/ log4nova Public archive

Send logs from go microservices into nova

License

Notifications You must be signed in to change notification settings

Polarishq/log4nova

Repository files navigation

Log4Nova

A simple logging library for forwarding your logs into your Nova log store

Setting up Log4Nova

  1. Vendor this library into your go-service
  2. Vendor in the dependencies:
$ make dependencies
  1. Wire up the NovaHandler to your middleware chain with your Nova API Keys:
//Example for standing up the log4nova handler
func setupGlobalMiddleware(handler http.Handler) http.Handler {
	clientID := os.Getenv("NOVA_CLIENT_ID")
	clientSecret := os.Getenv("NOVA_CLIENT_SECRET")
	novaLogger := log4nova.NewNovaLogger(clientID, clientSecret)
    log4nova.NewNovaHandler(novaLogger,
        handlers.SomeOtherHandler(handler))
}

Usage

To log any data to your splunk instance, first initialize a log4nova instance:

	clientID := os.Getenv("NOVA_CLIENT_ID")
	clientSecret := os.Getenv("NOVA_CLIENT_SECRET")
	novaLogger := log4nova.NewNovaLogger(clientID, clientSecret)
	
	//Batch logs every 5 secs
	novaLogger.SendInterval = 5000
	
	//Mirror all data to stdout
	novaLogger.SendToStdOut = true
	
	//Start the logger.  If the logger is not started, logs will not be sent to the logstore
	novaLogger.Start()
	
	//Send my logs off to nova
	novaLogger.WithFields({
	    SomeField: "Some important value"    
    }).Errorf("Error! %v", e)
    
    //Stop the logger
    novaLogger.Stop()

Troubleshooting

TBD

About

Send logs from go microservices into nova

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published