All Projects → ilya1st → rotatewriter

ilya1st / rotatewriter

Licence: MIT license
Writter for internal golang log library or for rs/zerolog which has normal smooth nonblocking rotate

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to rotatewriter

Rotate 3d
3D Rotation image along specific axes
Stars: ✭ 81 (+406.25%)
Mutual labels:  rotation
Circlr
Animation rotation via scroll, mouse and touch events
Stars: ✭ 159 (+893.75%)
Mutual labels:  rotation
xmca
Maximum Covariance Analysis in Python
Stars: ✭ 41 (+156.25%)
Mutual labels:  rotation
Androiduigesturerecognizer
AndroidGestureRecognizer is an Android implementation of the Apple's UIGestureRecognizer framework
Stars: ✭ 119 (+643.75%)
Mutual labels:  rotation
Aginterfaceinteraction
library performs interaction with UI interface
Stars: ✭ 156 (+875%)
Mutual labels:  rotation
Vue Free Transform
VueJS Free transform tool component
Stars: ✭ 172 (+975%)
Mutual labels:  rotation
React Native Amazing Cropper
Image cropper for react native using Animated API
Stars: ✭ 67 (+318.75%)
Mutual labels:  rotation
virtualGizmo3D
Virtual GIZMO - 3D object manipulator / orientator, via mouse, with pan and dolly/zoom features
Stars: ✭ 36 (+125%)
Mutual labels:  rotation
Jqueryrotate
jQueryRotate - plugin to rotate images by any angle cross-browse with animation support
Stars: ✭ 157 (+881.25%)
Mutual labels:  rotation
maks
Motion Averaging
Stars: ✭ 52 (+225%)
Mutual labels:  rotation
Ucrop
Image Cropping Library for Android
Stars: ✭ 11,003 (+68668.75%)
Mutual labels:  rotation
React Native Easy Gestures
React Native Gestures. Support: Drag, Scale and Rotate a Component.
Stars: ✭ 153 (+856.25%)
Mutual labels:  rotation
Igrphototweaks
Drag, Rotate, Scale and Crop
Stars: ✭ 212 (+1225%)
Mutual labels:  rotation
React Rotation
React rotation component
Stars: ✭ 102 (+537.5%)
Mutual labels:  rotation
scenario
Agent simulation in Jupyter
Stars: ✭ 17 (+6.25%)
Mutual labels:  rotation
Live Tools
Live-Tools is a library project which aims to convert some Android features to LiveData
Stars: ✭ 75 (+368.75%)
Mutual labels:  rotation
Complex.js
A complex number library
Stars: ✭ 165 (+931.25%)
Mutual labels:  rotation
logger
Gin middleware/handler to logger url path using rs/zerolog
Stars: ✭ 119 (+643.75%)
Mutual labels:  zerolog
yolov5 obb
yolov5 + csl_label.(Oriented Object Detection)(Rotation Detection)(Rotated BBox)基于yolov5的旋转目标检测
Stars: ✭ 1,105 (+6806.25%)
Mutual labels:  rotation
Tourism Demo
Flutter app backed by Redux, shows animations, internationalization (i18n), ClipPath, fonts and others...
Stars: ✭ 232 (+1350%)
Mutual labels:  rotation

Rotation log writer

Build StatusGo Report Card

This is log writer to support rotation.

Note: logs directory in library intended for testing purposes

Usage

Example

You can use RotateWriter as standard golang log writer or use as zerolog writer.

Example for zerolog case:

package main

import (
    "fmt"
    "os"
    "os/signal"
    "syscall"
    "time"

    "github.com/ilya1st/rotatewriter"
    "github.com/rs/zerolog"
)

func main() {
    // this is for test
    writer, err := rotatewriter.NewRotateWriter("./logs/test.log", 8)
    if err != nil {
        panic(err)
    }
    sighupChan := make(chan os.Signal, 1)
    signal.Notify(sighupChan, syscall.SIGHUP)
    go func() {
        for {
            _, ok := <-sighupChan
            if !ok {
                return
            }
            fmt.Println("Log rotation")
            writer.Rotate(nil)
        }
    }()
    logger := zerolog.New(writer).With().Timestamp().Logger()
    fmt.Println("Just run in another console and look into logs directory:\n$ killall -HUP rotateexample")
    for {
        logger.Info().Msg("test")
        time.Sleep(500 * time.Millisecond)
    }
}

rotatewriter.NewRotateWriter() arguments

First argument is full log filename.

Second argument - number of files to store.

If it's 0 - writer just reopen file. This is for cases you use logrotate instrument around your app

rotatewriter.Rotate()

You call it when you need rotation. It has specific locks do not run rotation twice in same moment. you may pass callback tu function to know rotation is ready.

rotatewriter.RotationInProgress()

You can determine is rotation operation in progress or not if you need

Why

This package was inspired by lumberjack - but there is an issue with blocking while log rotation and it's overloaded with features as size counting, gzip but I need just correctly handle reopen.

Install

go get github.com/ilya1st/rotatewriter
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].