|
| 1 | +/* |
| 2 | + * Copyright 2025 The Go-Spring Authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package log |
| 18 | + |
| 19 | +//type Action interface { |
| 20 | +// Execute() error |
| 21 | +//} |
| 22 | +// |
| 23 | +//type RenameAction struct { |
| 24 | +//} |
| 25 | +// |
| 26 | +//type CompressAction struct { |
| 27 | +//} |
| 28 | +// |
| 29 | +//type RollingPolicy interface { |
| 30 | +// Rollover(m RollingFileManager) |
| 31 | +//} |
| 32 | +// |
| 33 | +//type SizeBasedRollingPolicy struct { |
| 34 | +// MaxFileSize int64 |
| 35 | +//} |
| 36 | +// |
| 37 | +//func (r *SizeBasedRollingPolicy) Rollover(m RollingFileManager) { |
| 38 | +// if m.Size() >= r.MaxFileSize { |
| 39 | +// m.Rollover() |
| 40 | +// } |
| 41 | +//} |
| 42 | +// |
| 43 | +//type TimeBasedRollingPolicy struct { |
| 44 | +// Interval int64 |
| 45 | +//} |
| 46 | +// |
| 47 | +//func (r *TimeBasedRollingPolicy) Rollover(m RollingFileManager) { |
| 48 | +// nowTime := (time.Now().Unix() / r.Interval) * r.Interval |
| 49 | +// if m.NextTime() <= nowTime { |
| 50 | +// m.Rollover() |
| 51 | +// } |
| 52 | +//} |
| 53 | +// |
| 54 | +//type SizeAndTimeBasedRollingPolicy struct { |
| 55 | +// SizeBasedRollingPolicy |
| 56 | +// TimeBasedRollingPolicy |
| 57 | +//} |
| 58 | +// |
| 59 | +//func (r *SizeAndTimeBasedRollingPolicy) Rollover(m RollingFileManager) { |
| 60 | +// nowTime := (time.Now().Unix() / r.Interval) * r.Interval |
| 61 | +// if m.NextTime() <= nowTime || m.Size() >= r.MaxFileSize { |
| 62 | +// m.Rollover() |
| 63 | +// } |
| 64 | +//} |
| 65 | +// |
| 66 | +//type RollingFileManager interface { |
| 67 | +// NextTime() int64 |
| 68 | +// Size() int64 |
| 69 | +// Rollover() |
| 70 | +// Write(p []byte) (n int, err error) |
| 71 | +// Close() |
| 72 | +//} |
| 73 | +// |
| 74 | +////type RollingFileManager struct { |
| 75 | +//// size int64 |
| 76 | +//// file *os.File |
| 77 | +////} |
| 78 | +//// |
| 79 | +////func OpenRollingFile(fileName string) (*RollingFileManager, error) { |
| 80 | +//// file, err := os.OpenFile(fileName, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0666) |
| 81 | +//// if err != nil { |
| 82 | +//// return nil, err |
| 83 | +//// } |
| 84 | +//// stat, err := file.Stat() |
| 85 | +//// if err != nil { |
| 86 | +//// return nil, err |
| 87 | +//// } |
| 88 | +//// return &RollingFileManager{ |
| 89 | +//// size: stat.Size(), |
| 90 | +//// file: file, |
| 91 | +//// }, nil |
| 92 | +////} |
| 93 | +//// |
| 94 | +////func (f *RollingFileManager) rollover() { |
| 95 | +//// |
| 96 | +////} |
| 97 | +//// |
| 98 | +////func (f *RollingFileManager) Write(p []byte) (n int, err error) { |
| 99 | +//// return f.file.Write(p) |
| 100 | +////} |
| 101 | +//// |
| 102 | +////func (f *RollingFileManager) Close() { |
| 103 | +//// f.file.Sync() |
| 104 | +//// f.file.Close() |
| 105 | +////} |
0 commit comments