Giter Club home page Giter Club logo

Comments (2)

vaibhav-kaushal avatar vaibhav-kaushal commented on July 18, 2024

Sample usage of log manager (not a working code, but gives a hint about how we would love it):

package main
import barkLogger github.com/techrail/bark/client
func init () {
	// log.Println("some log")
	// log.Printf("some importantlog: %v", )

	log := barkLogger.NewClient("http://bark.example.com:8080", "INFO", "Service_Name", "optional_session_name") // when you only have a client and the server is already running elsewhere

	/*
	HTTP POST http://bark.example.com:8080/insertSingle
	{
		"level": "info",
		"serviceName": "Service_Name",
		"sessionName": "currenthostname_or-Podname",
		"code": "000000",
		"message": "what was sent by the Errorf method",
		"moreData": {}
	}
	*/

	// Either the above code or the below one!

	// log := barkLogger.NewClientPlusServer("postgresql://user:pass@server:port/db_name", "INFO", "Service_Name") // When you want to start the server as part of the current program itself

	log.Error("Something bad happened") // Will send to bark AND print it as well with ERROR level message
	log.Errorf("Something bad happened: %v", err) // Will send the formatted message to bark AND print it as well with ERROR level message
	log.Printf("Something bad happened: %v\n", err) // Will send the formatted message to bark AND print it as well with default (INFO) level message


	log.Errorf("E#1KQWPR - Something bad happened: %v", err) // Will send the formatted message to bark AND print it as well with ERROR level message
	log.Errorf("I#1KQWPR - Something bad happened: %v", err) // Will send the formatted message to bark AND print it as well with ERROR level message
	log.Errorf("W#1KQWPR - Something bad happened: %v", err) // Will send the formatted message to bark AND print it as well with ERROR level message
	log.Errorf("P#1KQWPR - Something bad happened: %v", err) // Will send the formatted message to bark AND print it as well with ERROR level message

}

type AppError struct {
	HttpCode int
	Level string // info, warning, sfgsdfaf
	Code string // LMID like 1KQWVQ
	Message string // show to your user -> Internal error - cannot register user
	DevMsg string // show to only the developers -> DB constraint "unique code" clash
	Tym time.Time
	Data Json
	WrappedError *AppError
}

from bark.

itishrishikesh avatar itishrishikesh commented on July 18, 2024

This is completed with #63

from bark.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.