~juju-qa/ubuntu/xenial/juju/xenial-2.0-beta3

« back to all changes in this revision

Viewing changes to src/gopkg.in/inconshreveable/log15.v2/handler_appengine.go

  • Committer: Martin Packman
  • Date: 2016-03-30 19:31:08 UTC
  • mfrom: (1.1.41)
  • Revision ID: martin.packman@canonical.com-20160330193108-h9iz3ak334uk0z5r
Merge new upstream source 2.0~beta3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// +build appengine
2
 
 
3
 
package log15
4
 
 
5
 
import "sync"
6
 
 
7
 
// swapHandler wraps another handler that may be swapped out
8
 
// dynamically at runtime in a thread-safe fashion.
9
 
type swapHandler struct {
10
 
        handler interface{}
11
 
        lock    sync.RWMutex
12
 
}
13
 
 
14
 
func (h *swapHandler) Log(r *Record) error {
15
 
        h.lock.RLock()
16
 
        defer h.lock.RUnlock()
17
 
 
18
 
        return h.handler.(Handler).Log(r)
19
 
}
20
 
 
21
 
func (h *swapHandler) Swap(newHandler Handler) {
22
 
        h.lock.Lock()
23
 
        defer h.lock.Unlock()
24
 
 
25
 
        h.handler = newHandler
26
 
}