logzio

package module
v0.0.0-...-37b2415 Latest Latest
Warning

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

Go to latest
Published: May 8, 2018 License: Apache-2.0 Imports: 12 Imported by: 8

README

Logzio Golang API client

Sends logs to logz.io over HTTP

GoDoc Build Status Coverage Status Go Report

Installation

$ go get -u github.com/dougEfresh/logzio-go

Quick Start

package main

import (
"fmt"
"github.com/dougEfresh/logzio-go"
"os"
"time"
)

func main() {
  l, err := logzio.New(os.Args[1]) // Token is required
  if err != nil {
    panic(err)
  }
  msg := fmt.Sprintf("{ \"%s\": \"%s\"}", "message", time.Now().UnixNano())

  err = l.Send([]byte(msg))
  if err != nil {
     panic(err)
  }

  l.Stop() //logs are buffered on disk. Stop will drain the buffer
}

logzio sender is a low level lib meant to be integrated with other logging libs

Usage

Setting drain duration (flush logs on disk) : logzio.New(token, SetDrainDuration(time.Hour))

Setting url mode: logzio.New(token, SetUrl(ts.URL))

Setting debug mode: logzio.New(token, SetDebug(os.Stderr))

Setting queue dir: logzio.New(token, SetSetTempDirectory(os.Stderr))

Disk queue

Logzio go client uses goleveldb and goqueue as a persistent storage. Every 5 seconds logs are sent to logz.io (if any are available)

Examples

Uber Zap: zapz

GO kit: kitz

Prerequisites

go 1.x

Tests

$ go test -v

See travis.yaml for running benchmark tests

Deployment

Contributing

All PRs are welcome

Authors

License

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

Acknowledgments

TODO

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogzioSender

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

LogzioSender instance of the

func New

func New(token string, options ...SenderOptionFunc) (*LogzioSender, error)

New creates a new Logzio sender with a token and options

func (*LogzioSender) CloseIdleConnections

func (l *LogzioSender) CloseIdleConnections()

func (*LogzioSender) Drain

func (l *LogzioSender) Drain()

Drain - Send remaining logs

func (*LogzioSender) Send

func (l *LogzioSender) Send(payload []byte) error

Send the payload to logz.io

func (*LogzioSender) Stop

func (l *LogzioSender) Stop()

Stop will close the LevelDB queue and do a final drain

func (*LogzioSender) Sync

func (l *LogzioSender) Sync() error

Sync drains the queue

func (*LogzioSender) Write

func (l *LogzioSender) Write(p []byte) (n int, err error)

type Sender

type Sender LogzioSender

Sender Alias to LogzioSender

type SenderOptionFunc

type SenderOptionFunc func(*LogzioSender) error

SenderOptionFunc options for logz

func SetCheckDiskSpace

func SetCheckDiskSpace(check bool) SenderOptionFunc

SetDrainDiskThreshold to change the maximum used disk space

func SetDebug

func SetDebug(debug io.Writer) SenderOptionFunc

SetDebug mode and send logs to this writer

func SetDrainDiskThreshold

func SetDrainDiskThreshold(th int) SenderOptionFunc

SetDrainDiskThreshold to change the maximum used disk space

func SetDrainDuration

func SetDrainDuration(duration time.Duration) SenderOptionFunc

SetDrainDuration to change the interval between drains

func SetTempDirectory

func SetTempDirectory(dir string) SenderOptionFunc

SetTempDirectory Use this temporary dir

func SetUrl

func SetUrl(url string) SenderOptionFunc

SetUrl set the url which maybe different from the defaultUrl

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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