Skip to content

GCP Cloud Logging Golang logger

License

Notifications You must be signed in to change notification settings

qurami/gcp-lolo-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gcp-lolo-go

GCP Cloud Logging logger, for Golang.

The idea behind this package is to provide the simplest way to log messages to Google Cloud Logging, without having to worry about the details of setting up the Google Cloud Logging client and/or affecting the current application structure.

Installation

go get github.com/qurami/gcp-lolo-go

Usage

This package works in combination with logrus, as follows:

	// Create a new logrus logger
	logger := logrus.New()

	// Set the log level (optional)
	logger.SetLevel(logrus.InfoLevel)

	// Create a new GCP hook
	logger, err := gcplologo.SetupGCPLogging("your-project-id", "your-logger-name")
	if err != nil {
		log.Fatalf("Failed to create GCP hook: %v", err)
	}

	// Use the logger
	logger.Info("This is an info message")

Please refer to the included demo application for a complete example.

Authentication

As the package exports logs on GCP Logging, you need some GCP credentials. You can provide them in the following ways:

  1. By setting either one of the following environment variables:
    • GOOGLE_APPLICATION_CREDENTIALS: the path to the local GCP credentials file, or
    • GCP_CREDENTIALS_JSON: a string containing the GCP credentials JSON
  2. By running the application within an environment that has the GCP credentials set up (e.g. a GCP VM, GCP Cloud Run, etc.)

Reference

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

About

GCP Cloud Logging Golang logger

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages