go_gcp_logging_easycall

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2023 License: GPL-3.0 Imports: 4 Imported by: 0

README

gcp_logging_easycall

pkg-img

It helps you log your telemetry to google cloud logging without much effort, just import and use it.

Rationale

Deal with some google cloud libraries is sometimes painful and unclear code. We were looking for some telemetry snippet that could allow us just import it and call function to log our actions. The goal was to log our actions without code rewrites everytime we want. This Library does this with google cloud logging, allowing users just call a function and pass arguments

Dependencies

  • Google Cloud SDK (google-cloud-logging)

Features

  • Simple API.
  • Clean and tested code.
  • Supports different payloads

Install

Go version 1.14+

go get github.com/indicoinnovation/gcp_logging_easycall

##Example

import (
    gcpLogging "github.com/indicoinnovation/gcp_logging_easycall"
)

gcpProjectName := "your google cloud project"
loggerName := "the name to group your logs into"
message := &gcpLogging.Logger{
    User: "your user",
	Message: "your message",
	Reason: "A reason like err.Error()",
	RemoteIp: "the remote IP if applied",
	Method: "If applied the method used in this call",
	Urlpath: "",
	StatusCode: 200,
	RequestData: "json_data",
	ResponseData: "json_data",
	SessionId: "session_id"
}
severity := "alert" //If none of options applied then default severity will be logged

gcpLogging.Log(gcpProjectName, loggerName, message, severity)

Documentation

See these docs.

License

GNU General Public License v3.0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Log

func Log(project string, loggerName string, message interface{}, severity string, resourceName string, resourceLabels map[string]string)

Types

type Logger

type Logger struct {
	User         string      `json:"token"`
	Message      string      `json:"message"`
	Reason       string      `json:"reason"`
	RemoteIp     string      `json:"ipaddress"`
	Method       string      `json:"method"`
	Urlpath      string      `json:"route"`
	StatusCode   int         `json:"status_code"`
	RequestData  interface{} `json:"request_data"`
	ResponseData interface{} `json:"response_data"`
	SessionId    string      `json:"sessid"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL