Help us shape the future of Go! Take the 2026 Go Developer Survey

logging

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 13 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DATADOG_API_KEY string
View Source
var DATADOG_LOGS bool
View Source
var DATADOG_LOGS_URL string
View Source
var DATADOG_METRICS bool
View Source
var DATADOG_METRICS_URL string
View Source
var DATADOG_SERVICE_NAME string
View Source
var DATADOG_SOURCE string
View Source
var DATADOG_STAGE string
View Source
var DATADOG_VERSION string
View Source
var ERROR_FILE_LOCATION string

Initialize config variables

View Source
var LOCAL_LOGS bool
View Source
var LOCAL_LOGS_LOCATION string
View Source
var LOG_LEVEL string
View Source
var Log loggerWrapper

Initialize the global logger variable.

Functions

func CreateDialOptionsFromCtx added in v1.0.5

func CreateDialOptionsFromCtx(ctx *ContextMap) (opts *websocket.DialOptions, err error)

CreateDialOptionsFromCtx creates websocket dial options from the given ContextMap.

Parameters:

  • ctx: the logging context map containing metadata values

Returns:

  • opts: the websocket dial options with the attached metadata
  • err: an error if the metadata creation fails

func CreateMetaDataFromCtx added in v1.0.5

func CreateMetaDataFromCtx(ctx *ContextMap, ctxWithCancel context.Context) (ctxWithMetaData context.Context, err error)

CreateMetaDataFromCtx creates gRPC metadata from the given ContextMap and attaches it to the provided context.

Parameters:

  • ctx: the logging context map containing metadata values
  • ctxWithCancel: the gRPC context to which the metadata will be attached

Returns:

  • ctxWithMetaData: the new gRPC context with the attached metadata
  • err: an error if the metadata creation or attachment fails

func InitLogger

func InitLogger(GlobalConfig *config.Config)

InitLogger initializes the global logger.

The function creates a new zap logger with the specified configuration and sets the global logger variable to the new logger.

Parameters:

  • GlobalConfig: The global configuration from the config package.

Types

type Config

type Config struct {
	ErrorFileLocation string
	LogLevel          string
	LocalLogs         bool
	LocalLogsLocation string
	DatadogLogs       bool
	DatadogSource     string
	DatadogStage      string
	DatadogVersion    string
	DatadogService    string
	DatadogAPIKey     string
	DatadogLogsURL    string
	DatadogMetrics    bool
	DatadogMetricsURL string
}

Config represents the configuration for the logging package.

type ContextKey

type ContextKey string

ContextKey defines the supported context keys.

const (
	InstructionGuid ContextKey = "instructionGuid"
	WorkflowId      ContextKey = "workflowId"
	WorkflowRunId   ContextKey = "workflowRunId"
	UserId          ContextKey = "userId"
	AdapterType     ContextKey = "adapterType"
	WatchFolderPath ContextKey = "watchFolderPath"
	WatchFilePath   ContextKey = "watchFilePath"
	ReaderGuid      ContextKey = "readerGuid"
	ClientGuid      ContextKey = "clientGuid"
	Action          ContextKey = "action"
	Rest_Call_Id    ContextKey = "restCallId"
	Rest_Call       ContextKey = "restCall"
	UserMail        ContextKey = "userMail"
)

type ContextMap

type ContextMap struct {
	// contains filtered or unexported fields
}

ContextMap represents a context for managing key-value pairs with specific context keys. It allows setting, retrieving, and copying context data associated with various keys.

func CreateCtxFromHeader added in v1.0.5

func CreateCtxFromHeader(request *http.Request) (ctx *ContextMap, err error)

CreateCtxFromHeader creates a ContextMap from HTTP request headers.

Parameters:

  • request: the HTTP request containing the headers

Returns:

  • ctx: the logging context map created from the headers
  • err: an error if the header extraction or deserialization fails

func CreateCtxFromMetaData added in v1.0.5

func CreateCtxFromMetaData(ctxWithMetaData context.Context) (ctx *ContextMap, err error)

CreateCtxFromMetaData creates a ContextMap from gRPC metadata in the provided context.

Parameters:

  • ctxWithMetaData: the gRPC context containing the metadata

Returns:

  • ctx: the logging context map created from the metadata
  • err: an error if the metadata extraction or deserialization fails

func (*ContextMap) Copy

func (ctx *ContextMap) Copy() *ContextMap

Copy function copies the current contextMap so new uses of Set do not overwrite existing values

Returns:

  • *ContextMap: A copy of the current ContextMap.

func (*ContextMap) Get

func (ctx *ContextMap) Get(key ContextKey) (interface{}, bool)

Get function retrieves the value for a ContextKey

Parameters:

  • key: The ContextKey for which to retrieve the value.

Returns:

  • interface{}: The value associated with the specified ContextKey.
  • bool: A boolean indicating whether the ContextKey exists.

func (*ContextMap) Set

func (ctx *ContextMap) Set(key ContextKey, value interface{})

Set function sets ContextKeys equal to any value

type Metric

type Metric struct {
	Metric    string     `json:"metric"`
	Type      int        `json:"type"`
	Points    []Point    `json:"points"`
	Resources []Resource `json:"resources"`
}

Metric represents a time series metric.

type Metrics

type Metrics struct {
	Series []Metric `json:"series"`
}

Metrics represents a collection of metrics.

type Point

type Point struct {
	Timestamp int64   `json:"timestamp"`
	Value     float64 `json:"value"`
}

Point represents a data point in a time series metric.

type Resource

type Resource struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

Resource represents a named resource associated with a metric.

Jump to

Keyboard shortcuts

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