MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / LogStackTraces

Function LogStackTraces

base/util.go:1876–1891  ·  view source on GitHub ↗
(ctx context.Context, logDirectory string, stackTrace bytes.Buffer, timestamp string)

Source from the content-addressed store, hash-verified

1874}
1875
1876func LogStackTraces(ctx context.Context, logDirectory string, stackTrace bytes.Buffer, timestamp string) {
1877
1878 // log to console
1879 _, _ = fmt.Fprintf(os.Stderr, "Stack trace:\n%s\n", stackTrace.String())
1880
1881 err := writeStackTraceFile(ctx, logDirectory, timestamp, stackTrace)
1882 if err != nil {
1883 return
1884 }
1885
1886 rotatePath := filepath.Join(logDirectory, StackFilePrefix+"*.log")
1887 err = RotateFilenamesIfNeeded(rotatePath)
1888 if err != nil {
1889 WarnfCtx(ctx, "Error rotating stack trace files in path %s: %v", rotatePath, err)
1890 }
1891}
1892
1893func writeStackTraceFile(ctx context.Context, logDirectory, timestamp string, stackTrace bytes.Buffer) error {
1894 filename := filepath.Join(logDirectory, StackFilePrefix+timestamp+".log")

Callers 2

RegisterSignalHandlerFunction · 0.92

Calls 4

writeStackTraceFileFunction · 0.85
RotateFilenamesIfNeededFunction · 0.85
WarnfCtxFunction · 0.85
StringMethod · 0.65

Tested by 1