2015-04-22 22:54:31 +00:00
|
|
|
// Copyright (C) 2015 The Syncthing Authors.
|
|
|
|
//
|
|
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
2017-02-09 06:52:18 +00:00
|
|
|
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
2015-04-22 22:54:31 +00:00
|
|
|
|
|
|
|
package sync
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"strconv"
|
|
|
|
"time"
|
|
|
|
|
2016-11-05 02:31:52 +00:00
|
|
|
"github.com/syncthing/syncthing/lib/logger"
|
2015-04-22 22:54:31 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2016-12-17 14:37:11 +00:00
|
|
|
threshold = 100 * time.Millisecond
|
2015-10-03 15:25:21 +00:00
|
|
|
l = logger.DefaultLogger.NewFacility("sync", "Mutexes")
|
|
|
|
|
|
|
|
// We make an exception in this package and have an actual "if debug { ...
|
|
|
|
// }" variable, as it may be rather performance critical and does
|
|
|
|
// nonstandard things (from a debug logging PoV).
|
2023-12-11 21:06:45 +00:00
|
|
|
debug = logger.DefaultLogger.ShouldDebug("sync")
|
2015-04-22 22:54:31 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2018-01-15 13:33:52 +00:00
|
|
|
if n, _ := strconv.Atoi(os.Getenv("STLOCKTHRESHOLD")); n > 0 {
|
2016-11-05 02:31:52 +00:00
|
|
|
threshold = time.Duration(n) * time.Millisecond
|
|
|
|
}
|
2018-01-15 13:33:52 +00:00
|
|
|
l.Debugf("Enabling lock logging at %v threshold", threshold)
|
2015-10-03 15:25:21 +00:00
|
|
|
}
|