refactor: 替换 console.log 为统一日志工具(任务 3.2/20)
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
|
||||
import { Resend } from 'resend';
|
||||
import { z } from 'zod';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
const log = logger.child('ContactForm');
|
||||
|
||||
const companyEmail = process.env.COMPANY_EMAIL || 'contact@novalon.cn';
|
||||
|
||||
@@ -69,14 +72,14 @@ export async function submitContactForm(
|
||||
const data = validationResult.data;
|
||||
|
||||
if (data.website) {
|
||||
console.log('Honeypot field filled, rejecting request');
|
||||
log.warn('Honeypot field filled, rejecting request');
|
||||
return { success: true, message: '消息已发送' };
|
||||
}
|
||||
|
||||
if (data.submitTime) {
|
||||
const timeDiff = Date.now() - parseInt(data.submitTime);
|
||||
if (timeDiff < 2000) {
|
||||
console.log('Submission too fast:', timeDiff);
|
||||
log.warn('Submission too fast:', timeDiff);
|
||||
return { success: false, error: '提交过快,请稍后再试' };
|
||||
}
|
||||
}
|
||||
@@ -84,7 +87,7 @@ export async function submitContactForm(
|
||||
if (data.mathHash && data.mathTimestamp && data.mathAnswer !== undefined) {
|
||||
const expectedHash = btoa(`${data.mathAnswer}-${data.mathTimestamp}`);
|
||||
if (expectedHash !== data.mathHash) {
|
||||
console.log('Invalid math captcha');
|
||||
log.warn('Invalid math captcha');
|
||||
return { success: false, error: '验证码错误,请重新计算' };
|
||||
}
|
||||
}
|
||||
@@ -269,7 +272,7 @@ export async function submitContactForm(
|
||||
return { success: false, error: '邮件发送失败,请稍后重试' };
|
||||
}
|
||||
|
||||
console.log('Email sent successfully:', emailData);
|
||||
log.info('Email sent successfully:', emailData);
|
||||
return { success: true, message: '消息已发送' };
|
||||
} catch (error) {
|
||||
console.error('Contact form submission error:', error);
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
'use client';
|
||||
|
||||
import { useState, useEffect } from 'react';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
const log = logger.child('AdminUsers');
|
||||
import {
|
||||
Users as UsersIcon,
|
||||
Plus,
|
||||
@@ -96,7 +99,7 @@ export default function UsersPage() {
|
||||
|
||||
const handleDelete = async (userId: string) => {
|
||||
if (deletingUserId) {
|
||||
console.log('删除操作正在进行中,请勿重复点击');
|
||||
log.warn('删除操作正在进行中,请勿重复点击');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user