mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-02 14:38:49 +00:00
21 lines
735 B
TypeScript
21 lines
735 B
TypeScript
import { Logger } from 'pino';
|
|
import loggerModule from '../services/logger';
|
|
import { GetUptimeFormattedParams } from '../../types/utilTypes';
|
|
import { formatDuration } from './formattingUtils';
|
|
|
|
export const getUptimeFormatted = ({ executionId }: GetUptimeFormattedParams): string => {
|
|
const logger: Logger = loggerModule.child({
|
|
module: 'utilSystem',
|
|
name: 'getUptimeFormatted',
|
|
executionId: executionId
|
|
});
|
|
|
|
try {
|
|
const uptimeInSeconds: number = parseFloat(process.uptime().toFixed(0));
|
|
return formatDuration(uptimeInSeconds * 1000);
|
|
} catch (error) {
|
|
logger.error('Error retrieving or transforming uptime to formatted string.', error);
|
|
throw error;
|
|
}
|
|
};
|