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

hupwriter

package module
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2024 License: MIT Imports: 4 Imported by: 3

README

HUP acceptable io.Writer

PkgGoDev Actions/Go Go Report Card

Getting Started

Install and Upgrade
$ go get github.com/koron/hupwriter@latest
Usage
import (
    "github.com/koron/hupwriter"
    "log"
)

h := hupwriter.New("/var/log/myapp.log", "/var/pid/myapp.pid")
log.SetOutput(h)

Documentation

Overview

Package hupwriter provides wrapper of os.File.

The wrapper will close and reopen the file when a HUP signal is received. It allows easier log file rotation.

By logging to hupwriter you can create log files that can be used with log rotation management programs such as logrotate, newsyslog, or so.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HupWriter

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

HupWriter wraps os.File, and will close and reopen the file when a HUP signal is received.

func New

func New(name, pid string) *HupWriter

New creates a HupWriter with a file of name. It create PID file which records current process ID when pid is not empty.

func (*HupWriter) Close

func (h *HupWriter) Close() error

Close closes an underlying file, and stop to listening signals.

func (*HupWriter) Write

func (h *HupWriter) Write(p []byte) (int, error)

Write writes data to an underlying file.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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