Add log_name field to enable custom log folder naming

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-11-08 17:23:59 +00:00
parent 63c80fe648
commit 6b4ca79293
6 changed files with 23 additions and 4 deletions

View File

@ -21,6 +21,7 @@ export class Crontab {
extra_schedules?: Array<{ schedule: string }>; extra_schedules?: Array<{ schedule: string }>;
task_before?: string; task_before?: string;
task_after?: string; task_after?: string;
log_name?: string;
constructor(options: Crontab) { constructor(options: Crontab) {
this.name = options.name; this.name = options.name;
@ -45,6 +46,7 @@ export class Crontab {
this.extra_schedules = options.extra_schedules; this.extra_schedules = options.extra_schedules;
this.task_before = options.task_before; this.task_before = options.task_before;
this.task_after = options.task_after; this.task_after = options.task_after;
this.log_name = options.log_name;
} }
} }
@ -84,4 +86,5 @@ export const CrontabModel = sequelize.define<CronInstance>('Crontab', {
extra_schedules: DataTypes.JSON, extra_schedules: DataTypes.JSON,
task_before: DataTypes.STRING, task_before: DataTypes.STRING,
task_after: DataTypes.STRING, task_after: DataTypes.STRING,
log_name: DataTypes.STRING,
}); });

View File

@ -476,8 +476,8 @@ export default class CronService {
`[panel][开始执行任务] 参数: ${JSON.stringify(params)}`, `[panel][开始执行任务] 参数: ${JSON.stringify(params)}`,
); );
let { id, command, log_path } = cron; let { id, command, log_path, log_name } = cron;
const uniqPath = await getUniqPath(command, `${id}`); const uniqPath = log_name || (await getUniqPath(command, `${id}`));
const logTime = dayjs().format('YYYY-MM-DD-HH-mm-ss-SSS'); const logTime = dayjs().format('YYYY-MM-DD-HH-mm-ss-SSS');
const logDirPath = path.resolve(config.logPath, `${uniqPath}`); const logDirPath = path.resolve(config.logPath, `${uniqPath}`);
if (log_path?.split('/')?.every((x) => x !== uniqPath)) { if (log_path?.split('/')?.every((x) => x !== uniqPath)) {

View File

@ -37,4 +37,5 @@ export const commonCronSchema = {
extra_schedules: Joi.array().optional().allow(null), extra_schedules: Joi.array().optional().allow(null),
task_before: Joi.string().optional().allow('').allow(null), task_before: Joi.string().optional().allow('').allow(null),
task_after: Joi.string().optional().allow('').allow(null), task_after: Joi.string().optional().allow('').allow(null),
log_name: Joi.string().optional().allow('').allow(null),
}; };

View File

@ -521,5 +521,8 @@
"远程仓库缓存": "Remote repository cache", "远程仓库缓存": "Remote repository cache",
"SSH 文件缓存": "SSH file cache", "SSH 文件缓存": "SSH file cache",
"清除依赖缓存": "Clean dependency cache", "清除依赖缓存": "Clean dependency cache",
"清除成功": "Clean successful" "清除成功": "Clean successful",
"日志名称": "Log Name",
"自定义日志文件夹名称,用于区分不同任务的日志,留空则自动生成": "Custom log folder name to distinguish logs from different tasks. Leave blank to auto-generate",
"请输入自定义日志文件夹名称": "Please enter a custom log folder name"
} }

View File

@ -521,5 +521,8 @@
"远程仓库缓存": "远程仓库缓存", "远程仓库缓存": "远程仓库缓存",
"SSH 文件缓存": "SSH 文件缓存", "SSH 文件缓存": "SSH 文件缓存",
"清除依赖缓存": "清除依赖缓存", "清除依赖缓存": "清除依赖缓存",
"清除成功": "清除成功" "清除成功": "清除成功",
"日志名称": "日志名称",
"自定义日志文件夹名称,用于区分不同任务的日志,留空则自动生成": "自定义日志文件夹名称,用于区分不同任务的日志,留空则自动生成",
"请输入自定义日志文件夹名称": "请输入自定义日志文件夹名称"
} }

View File

@ -180,6 +180,15 @@ const CronModal = ({
<Form.Item name="labels" label={intl.get('标签')}> <Form.Item name="labels" label={intl.get('标签')}>
<EditableTagGroup /> <EditableTagGroup />
</Form.Item> </Form.Item>
<Form.Item
name="log_name"
label={intl.get('日志名称')}
tooltip={intl.get(
'自定义日志文件夹名称,用于区分不同任务的日志,留空则自动生成',
)}
>
<Input placeholder={intl.get('请输入自定义日志文件夹名称')} />
</Form.Item>
<Form.Item <Form.Item
name="task_before" name="task_before"
label={intl.get('执行前')} label={intl.get('执行前')}