Files
windows_exporter/internal/log/rotate_other.go
T
2026-10-15 16:40:05 +00:00

42 lines
1.2 KiB
Go

// SPDX-License-Identifier: Apache-2.0
//
// Copyright The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build !windows
package log
import "os"
// openLogFile opens path for appending. The exporter only runs on Windows;
// this keeps the rotation testable on other platforms.
func openLogFile(path string) (*os.File, error) {
return os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0o640)
}
// sameFile reports whether path still refers to file.
func sameFile(file *os.File, path string) (bool, error) {
fileInfo, err := file.Stat()
if err != nil {
return false, err
}
pathInfo, err := os.Stat(path)
if err != nil {
return false, err
}
return os.SameFile(fileInfo, pathInfo), nil
}