1
0
Fork 0
gallery-dl-archive-manager/log.js
2024-02-09 17:27:55 -05:00

17 lines
635 B
JavaScript

const options = { year: 'numeric', day: '2-digit', month: '2-digit', hour: '2-digit', 'minute': '2-digit', second: '2-digit' };
const osLocale = (process.env.LANG || process.env.LANGUAGE || process.env.LC_ALL || process.env.LC_MESSAGES).split('.')[0].replace('_', '-');
const dtFormat = Intl.DateTimeFormat(osLocale, options);
export const getTime = () => {
return dtFormat.format(new Date());
}
export const log = (src, msg) => {
const time = getTime();
console.log(`${time} : ${src} : ${msg}`);
};
export const error = (src, msg) => {
const time = new Date().toISOString();
console.error(`${time} : ${src} : ${msg}`);
}