forked from revel/log15
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
70 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// +build appengine | ||
|
||
package log15 | ||
|
||
import "sync" | ||
|
||
// swapHandler wraps another handler that may be swapped out | ||
// dynamically at runtime in a thread-safe fashion. | ||
type swapHandler struct { | ||
handler interface{} | ||
lock sync.RWMutex | ||
} | ||
|
||
func (h *swapHandler) Log(r *Record) error { | ||
h.lock.RLock() | ||
defer h.lock.RUnlock() | ||
|
||
return h.handler.(Handler).Log(r) | ||
} | ||
|
||
func (h *swapHandler) Swap(newHandler Handler) { | ||
h.lock.Lock() | ||
defer h.lock.Unlock() | ||
|
||
h.handler = newHandler | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// +build !appengine | ||
|
||
package log15 | ||
|
||
import ( | ||
"sync/atomic" | ||
"unsafe" | ||
) | ||
|
||
// swapHandler wraps another handler that may be swapped out | ||
// dynamically at runtime in a thread-safe fashion. | ||
type swapHandler struct { | ||
handler unsafe.Pointer | ||
} | ||
|
||
func (h *swapHandler) Log(r *Record) error { | ||
return (*(*Handler)(atomic.LoadPointer(&h.handler))).Log(r) | ||
} | ||
|
||
func (h *swapHandler) Swap(newHandler Handler) { | ||
atomic.StorePointer(&h.handler, unsafe.Pointer(&newHandler)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// +build !go1.3 | ||
// +build !go1.3 appengine | ||
|
||
package stack | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Based on ssh/terminal: | ||
// Copyright 2013 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// +build appengine | ||
|
||
package term | ||
|
||
// IsTty always returns false on AppEngine. | ||
func IsTty(fd uintptr) bool { | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters