Files
log-hunter/src/main/java/research/loghunter/entity/Pattern.java
2026-01-07 01:14:51 +09:00

59 lines
1.4 KiB
Java

package research.loghunter.entity;
import jakarta.persistence.*;
import lombok.*;
import java.time.LocalDateTime;
@Entity
@Table(name = "patterns")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class Pattern {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String name; // 패턴명 (예: NullPointer, DB Connection)
@Column(nullable = false, length = 1000)
private String regex; // 정규식
@Column(length = 1000)
private String excludeRegex; // 제외 정규식 (매칭되면 에러에서 제외)
@Column(nullable = false)
private String severity; // CRITICAL, ERROR, WARN
@Column(nullable = false)
private Integer contextLines; // 에러 전후 캡처할 라인 수
private String description; // 설명
@Column(nullable = false)
private Boolean active;
@Column(nullable = false, updatable = false)
private LocalDateTime createdAt;
private LocalDateTime updatedAt;
@PrePersist
protected void onCreate() {
createdAt = LocalDateTime.now();
updatedAt = LocalDateTime.now();
if (active == null) active = true;
if (contextLines == null) contextLines = 5;
if (severity == null) severity = "ERROR";
}
@PreUpdate
protected void onUpdate() {
updatedAt = LocalDateTime.now();
}
}