Skip to content

junkd0g/applogger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Applogger

Package junkd0g/applogger is a simple ndjson logger

Installing

go get -u github.com/junkd0g/applogger

Running the tests

go test ./...

Example

package main

import (
	"net/http"

	"github.com/gorilla/mux"
	"github.com/junkd0g/applogger"
)

func HelloWorld(w http.ResponseWriter, r *http.Request) {

	logger := applogger.AppLogger{Path: "/tmp/logger.ndjson"}
	logger.Initialise()

	response := "{ \"message\" : \"Hello World\"}"
	logger.Log("INFO", "main", "HelloWorld", response)

	w.Header().Set("Content-Type", "application/json")
	w.Write([]byte(response))
}

func main() {

	router := mux.NewRouter().StrictSlash(true)
	router.HandleFunc("/", HelloWorld)

	http.ListenAndServe(":8076", router)
}

Authors

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages