mirror of
https://gitee.com/johng/gf
synced 2026-07-04 21:03:13 +08:00
improve rotation feature for package glog
This commit is contained in:
@ -1,20 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"time"
|
||||
"fmt"
|
||||
"github.com/gogf/gf/os/gfile"
|
||||
"github.com/gogf/gf/text/gregex"
|
||||
)
|
||||
|
||||
func main() {
|
||||
file, err := os.Create("/tmp/testfile")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
for {
|
||||
_, err = file.Write([]byte("test\n"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
time.Sleep(5 * time.Second)
|
||||
}
|
||||
fmt.Println(gfile.Basename("/tmp/1585227151172826000/access.20200326205231173924.log"))
|
||||
fmt.Println(
|
||||
gregex.IsMatchString(`.+\.\d{20}\.log`,
|
||||
gfile.Basename("/tmp/1585227151172826000/access.20200326205231173924.log")))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user