Skip to content

Inasayang/logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Usage

import (
    "github.com/Inasayang/logger"
)

Copy and Truncate

logger.Init("/var/log/{app}", "{app}", "info",nil)
cat << EOF > /etc/logrotate.d/{app}
/var/log/{app}/*.log {
    rotate 7
    daily
    compress
    copytruncate
}
EOF

Rename and Create

reloadCh := make(chan struct{}, 1)
logger.Init("/var/log/{app}", "{app}", "info",reloadCh)
...
capture user signal
...
cat << EOF > /etc/logrotate.d/{app}
/var/log/{app}/*.log {
    rotate 7
    daily
    compress
    create
    postrotate
        /usr/bin/kill -USR1 `pid of app`
    endscript
}
EOF
logrotate -f /etc/logrotate.d/{app}

About

logger for myself

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages