freeleaps-ops/first-class-pipeline/vars/log.groovy
2025-02-04 11:06:07 +08:00

22 lines
461 B
Groovy
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!groovy
import java.text.SimpleDateFormat
import java.util.Date
def getTimestamp() {
// 定义时间戳格式例如2023-10-05 14:30:00
def dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
return dateFormat.format(new Date())
}
def info(message) {
echo "[${getTimestamp()}] [INFO] ${message}"
}
def warn(message) {
echo "[${getTimestamp()}] [WARN] ${message}"
}
def error(message) {
echo "[${getTimestamp()}] [ERROR] ${message}"
}