Skip to content

Commit

Permalink
warnings fixed (found by metalinter)
Browse files Browse the repository at this point in the history
  • Loading branch information
regorov committed Aug 27, 2015
1 parent 99228f3 commit 55c2f30
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
7 changes: 5 additions & 2 deletions README.md
Expand Up @@ -8,13 +8,16 @@ Golang package logwriter automates routine related to logging into files.
Initial version finished. Stabilization, testing and benchmarkign are going.

## Concepts
### Hot and Cold Log Files
#### Hot and Cold Log Files
There is a single **hot** log file. Usually file name is similar to daemon/service name and located in */var/log/servicename/*. There are **cold** log files. In accordance to rules specified by logwriter.Config,
logwriter freezes content of **hot** file by moving content to new **cold** file.

### Using sync.Mutex
#### Using sync.Mutex
If you don't need buffering (logwriter.Config.BufferSize==0) you can believe that file write executes synchronously.

#### Stop! It's not a *unix way
Well, everyone do not develop facebook or smth similar. If you don't want to

## Features
- [X] Folders for hot and cold log files configurable
- [X] Using fixed name of file with latest log items
Expand Down
7 changes: 3 additions & 4 deletions logwriter.go
Expand Up @@ -356,13 +356,13 @@ func (lw *LogWriter) runner(cfg Config) {
lw.done <- true
return
case _ = <-bufferFlushTimer.C:
lw.flushBuffer(true)
_ = lw.flushBuffer(true)

// Reset timer to compensate i/o time
_ = bufferFlushTimer.Reset(cfg.BufferFlushInterval)
break
case _ = <-fileFreezeTimer.C:
lw.freezeHotFile(true)
_ = lw.freezeHotFile(true)

// Reset timer to compensate i/o time
_ = fileFreezeTimer.Reset(cfg.FreezeInterval)
Expand All @@ -376,7 +376,7 @@ func (lw *LogWriter) runner(cfg Config) {
if prev.Day() != now.Day() {
prev = now

lw.freezeHotFile(true)
_ = lw.freezeHotFile(true)

if cfg.FreezeInterval != 0 {
_ = fileFreezeTimer.Reset(cfg.FreezeInterval)
Expand Down Expand Up @@ -525,7 +525,6 @@ func (lw *LogWriter) initHotFile() (err error) {
}

lw.filelen = fstat.Size()
fmt.Println("len", lw.filelen)

// register lw.f in io.MultiWriter()
lw.setMode(lw.config.Mode)
Expand Down
4 changes: 1 addition & 3 deletions logwriter_test.go
Expand Up @@ -124,11 +124,9 @@ func BenchmarkFileWriteBufferedBySlice(b *testing.B) {

buf := make([]byte, 1024*1024)
k := 0
j := 0
b.ResetTimer()
for i := 0; i < b.N; i++ {
j = copy(buf[k:], typicalLogItem)
k += j
k += copy(buf[k:], typicalLogItem)

if k > 1024*1024-1024 {
n, err := f.Write(buf[:k])
Expand Down

0 comments on commit 55c2f30

Please sign in to comment.