creek

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

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

Go to latest
Published: Jul 26, 2016 License: MIT Imports: 7 Imported by: 1

README

Creek GoDoc License Go Report Card Build Status

A simple log rotator for Go on Linux platforms.

Usage

Creek is meant to be used with the standard log library.

The New method accepts a file to log to, as well as the max size, in megabytes, of each log file before rolling.

Sample usage:

package main

import (
	"log"

	"creek"
)

func main() {
	// Create a new logger that stores to a http.log file
	// with a max size of 10 MB before rolling over.
	logger := log.New(creek.New("/var/log/your_app/http.log", 10), "Logged: ", log.Lshortfile|log.LstdFlags)

	// Print to the log.
	logger.Println("Testing the log file")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct {
	Filename string // the file to log to
	MaxSize  int64  // max file size in MB
	// contains filtered or unexported fields
}

Logger defines our custom Logger type.

func New

func New(filename string, maxSize int64) *Logger

New creates a new creek logger.

func (*Logger) Write

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

Write satisfies the io.Writer interface.

Jump to

Keyboard shortcuts

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