mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 10:56:28 +00:00
5a3629badf
Added the ability to view and re-download leave application forms in the Employee History page (Leave, Permit, and Sick tabs) Added employee alpha stats and employee alpha detail in Employee Performance Page Added total WFO, WFH and WFS in Admin Summary Report Added batch import from Excel files in Admin Manual Attendance
24 lines
1.1 KiB
TypeScript
24 lines
1.1 KiB
TypeScript
// actions/logger.ts
|
|
"use server";
|
|
|
|
import { logger } from "@/lib/logger";
|
|
|
|
export type LogLevel = 'INFO' | 'WARN' | 'ERROR' | 'DEBUG' | 'API_REQ' | 'API_RES';
|
|
|
|
// This function receives the log from the browser and writes it to the server file
|
|
export async function sendLogToServer(level: LogLevel, message: string, data?: any) {
|
|
try {
|
|
// Route the log to the correct method in your existing server logger
|
|
switch (level) {
|
|
case 'INFO': logger.info(`[CLIENT] ${message}`, data); break;
|
|
case 'WARN': logger.warn(`[CLIENT] ${message}`, data); break;
|
|
case 'ERROR': logger.error(`[CLIENT] ${message}`, data); break;
|
|
case 'DEBUG': logger.debug(`[CLIENT] ${message}`, data); break;
|
|
case 'API_REQ': logger.apiReq(`[CLIENT] ${message}`, data); break;
|
|
case 'API_RES': logger.apiRes(`[CLIENT] ${message}`, data); break;
|
|
default: logger.info(`[CLIENT] ${message}`, data); break;
|
|
}
|
|
} catch (error) {
|
|
console.error("Failed to write client log to server:", error);
|
|
}
|
|
} |