insight_go

package module
v0.0.0-...-b7550eb Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2019 License: MIT Imports: 7 Imported by: 2

README

insight_go

Golang client library for InsightOPS

It is compatible with http://golang.org/pkg/log/#Logger and also implements http://golang.org/pkg/io/#Writer

GoDoc

Build Status

Usage

Add a new manual TCP token log at InsightOPS and copy the token.

Installation: go get github.com/Tweddle-SE-Team/insight_go

Note: The Logger is blocking, it can be easily run in a goroutine by calling go insight.Println(...)

package main

import "github.com/Tweddle-SE-Team/insight_go"

func main() {
	le, err := insight_go.Connect("eu", "XXXX-XXXX-XXXX-XXXX") // replace with token
	if err != nil {
		panic(err)
	}

	defer insight.Close()

	insight.Println("another test message")
}

Documentation

Overview

Package insight_go provides a Golang client library for logging to insightops over a TCP connection.

it uses an access token for sending log events.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

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

Logger represents a Logentries logger, it holds the open TCP connection, access token, prefix and flags.

all Logger operations are thread safe and blocking, log operations can be invoked in a non-blocking way by calling them from a goroutine.

Example
le, err := Connect("XXXX-XXXX-XXXX-XXXX") // replace with token
if err != nil {
	panic(err)
}

defer le.Close()

le.Println("another test message")
Output:

Example (Write)
le, err := Connect("XXXX-XXXX-XXXX-XXXX") // replace with token
if err != nil {
	panic(err)
}

defer le.Close()

fmt.Fprintln(le, "another test message")
Output:

func Connect

func Connect(region, token string) (*Logger, error)

Connect creates a new Logger instance and opens a TCP connection to insightops, The token can be generated at insightops by adding a new log, choosing manual configuration and token based TCP connection.

func (*Logger) Close

func (logger *Logger) Close() error

Close closes the TCP connection to insightops

func (*Logger) Fatal

func (logger *Logger) Fatal(v ...interface{})

Fatal is same as Print() but calls to os.Exit(1)

func (*Logger) Fatalf

func (logger *Logger) Fatalf(format string, v ...interface{})

Fatalf is same as Printf() but calls to os.Exit(1)

func (*Logger) Fatalln

func (logger *Logger) Fatalln(v ...interface{})

Fatalln is same as Println() but calls to os.Exit(1)

func (*Logger) Flags

func (logger *Logger) Flags() int

Flags returns the logger flags

func (*Logger) Output

func (logger *Logger) Output(calldepth int, s string) error

Output does the actual writing to the TCP connection

func (*Logger) Panic

func (logger *Logger) Panic(v ...interface{})

Panic is same as Print() but calls to panic

func (*Logger) Panicf

func (logger *Logger) Panicf(format string, v ...interface{})

Panicf is same as Printf() but calls to panic

func (*Logger) Panicln

func (logger *Logger) Panicln(v ...interface{})

Panicln is same as Println() but calls to panic

func (*Logger) Prefix

func (logger *Logger) Prefix() string

Prefix returns the logger prefix

func (*Logger) Print

func (logger *Logger) Print(v ...interface{})

Print logs a message

func (*Logger) Printf

func (logger *Logger) Printf(format string, v ...interface{})

Printf logs a formatted message

func (*Logger) Println

func (logger *Logger) Println(v ...interface{})

Println logs a message with a linebreak

func (*Logger) SetFlags

func (logger *Logger) SetFlags(flag int)

SetFlags sets the logger flags

func (*Logger) SetPrefix

func (logger *Logger) SetPrefix(prefix string)

SetPrefix sets the logger prefix

func (*Logger) Write

func (logger *Logger) Write(p []byte) (n int, err error)

Write writes a bytes array to the InsightOPS TCP connection, it adds the access token and prefix and also replaces line breaks with the unicode \u2028 character

Jump to

Keyboard shortcuts

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