INNER CODE UNIT · Go
logDestinationForDatabase
oracle/oracle-db-appdev-monitoring · alertlog/alertlog.go:84
func logDestinationForDatabase(logDestination, database string, perDatabaseFiles bool) string {
if !perDatabaseFiles {
return logDestination
}
dir := filepath.Dir(logDestination)
ext := filepath.Ext(logDestination)
base := strings.TrimSuffix(filepath.Base(logDestination), ext)
return filepath.Join(dir, fmt.Sprintf("%s-%s%s", base, database, ext))
}
// readLastMatchingLogRecord scans backward through the log file to find the latest record for a database.
// Shared log files may contain records from multiple databases, so they must be filtered by database name.
func readLastMatchingLogRecord(logDestination, database string, perDatabaseFiles bool) (LogRecord, error) {
file, err := os.Open(logDestination)
if err != nil {
return LogRecord{}, err
}