mirror of
https://github.com/hempyhemp/hh-auto-reply.git
synced 2026-06-08 18:04:57 +00:00
🎨 refactor(logger): улучшаем форматирование и цвета в логгере для лучшей читаемости и консистентности.
All checks were successful
Deploy / deploy (push) Successful in 53s
All checks were successful
Deploy / deploy (push) Successful in 53s
🔧 fix(scraper): добавляем логирование URL и максимальной страницы для улучшения отладки.
This commit is contained in:
@@ -304,6 +304,8 @@ export async function applyToJobs(
|
|||||||
return Number(pageParam ?? 0)
|
return Number(pageParam ?? 0)
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
|
log.divider('CollectPageVacancies')
|
||||||
|
log.info('URL:', page.url())
|
||||||
log.info('Max page:', maxPage)
|
log.info('Max page:', maxPage)
|
||||||
for (let p = 1; p <= maxPage; p++) {
|
for (let p = 1; p <= maxPage; p++) {
|
||||||
const pageUrl = `https://hh.ru/search/vacancy?text=${encodeURIComponent(query)}&items_on_page=100&page=${p}`
|
const pageUrl = `https://hh.ru/search/vacancy?text=${encodeURIComponent(query)}&items_on_page=100&page=${p}`
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
const RESET = '\x1b[0m'
|
const RESET = '\x1B[0m'
|
||||||
const BOLD = '\x1b[1m'
|
const BOLD = '\x1B[1m'
|
||||||
const DIM = '\x1b[2m'
|
const DIM = '\x1B[2m'
|
||||||
|
|
||||||
const colors = {
|
const colors = {
|
||||||
gray: '\x1b[90m',
|
gray: '\x1B[97m',
|
||||||
green: '\x1b[32m',
|
green: '\x1B[92m',
|
||||||
yellow: '\x1b[33m',
|
yellow: '\x1B[93m',
|
||||||
red: '\x1b[31m',
|
red: '\x1B[91m',
|
||||||
cyan: '\x1b[36m',
|
cyan: '\x1B[96m',
|
||||||
magenta: '\x1b[35m',
|
magenta: '\x1B[95m',
|
||||||
blue: '\x1b[34m',
|
blue: '\x1B[94m',
|
||||||
white: '\x1b[37m',
|
white: '\x1B[97m',
|
||||||
}
|
}
|
||||||
|
|
||||||
const LEVELS = {
|
const LEVELS = {
|
||||||
info: { icon: '●', color: colors.cyan, label: 'INFO ' },
|
info: { icon: '●', color: colors.cyan, label: 'INFO ' },
|
||||||
success: { icon: '✔', color: colors.green, label: 'OK ' },
|
success: { icon: '✔', color: colors.green, label: 'OK ' },
|
||||||
warn: { icon: '▲', color: colors.yellow, label: 'WARN ' },
|
warn: { icon: '▲', color: colors.yellow, label: 'WARN ' },
|
||||||
error: { icon: '✖', color: colors.red, label: 'ERROR' },
|
error: { icon: '✖', color: colors.red, label: 'ERROR' },
|
||||||
debug: { icon: '◆', color: colors.magenta, label: 'DEBUG' },
|
debug: { icon: '◆', color: colors.magenta, label: 'DEBUG' },
|
||||||
llm: { icon: '◈', color: colors.blue, label: 'LLM ' },
|
llm: { icon: '◈', color: colors.blue, label: 'LLM ' },
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
type Level = keyof typeof LEVELS
|
type Level = keyof typeof LEVELS
|
||||||
@@ -39,7 +39,7 @@ function formatTag(tag: string): string {
|
|||||||
|
|
||||||
function formatArgs(args: unknown[]): string {
|
function formatArgs(args: unknown[]): string {
|
||||||
return args
|
return args
|
||||||
.map((a) =>
|
.map(a =>
|
||||||
typeof a === 'object' && a !== null
|
typeof a === 'object' && a !== null
|
||||||
? JSON.stringify(a, null, 2)
|
? JSON.stringify(a, null, 2)
|
||||||
: String(a),
|
: String(a),
|
||||||
@@ -56,26 +56,27 @@ function print(level: Level, tag: string, args: unknown[]): void {
|
|||||||
`${color}${formatArgs(args)}${RESET}`,
|
`${color}${formatArgs(args)}${RESET}`,
|
||||||
]
|
]
|
||||||
if (level === 'error') {
|
if (level === 'error') {
|
||||||
process.stderr.write(parts.join(' ') + '\n')
|
process.stderr.write(`${parts.join(' ')}\n`)
|
||||||
} else {
|
}
|
||||||
process.stdout.write(parts.join(' ') + '\n')
|
else {
|
||||||
|
process.stdout.write(`${parts.join(' ')}\n`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createLogger(tag: string) {
|
export function createLogger(tag: string) {
|
||||||
return {
|
return {
|
||||||
info: (...args: unknown[]) => print('info', tag, args),
|
info: (...args: unknown[]) => print('info', tag, args),
|
||||||
ok: (...args: unknown[]) => print('success', tag, args),
|
ok: (...args: unknown[]) => print('success', tag, args),
|
||||||
warn: (...args: unknown[]) => print('warn', tag, args),
|
warn: (...args: unknown[]) => print('warn', tag, args),
|
||||||
error: (...args: unknown[]) => print('error', tag, args),
|
error: (...args: unknown[]) => print('error', tag, args),
|
||||||
debug: (...args: unknown[]) => print('debug', tag, args),
|
debug: (...args: unknown[]) => print('debug', tag, args),
|
||||||
llm: (...args: unknown[]) => print('llm', tag, args),
|
llm: (...args: unknown[]) => print('llm', tag, args),
|
||||||
divider: (label?: string) => {
|
divider: (label?: string) => {
|
||||||
const line = '─'.repeat(58)
|
const line = '─'.repeat(58)
|
||||||
const text = label
|
const text = label
|
||||||
? `${DIM}${colors.gray}┌─ ${label} ${'─'.repeat(Math.max(0, 54 - label.length))}${RESET}`
|
? `${DIM}${colors.gray}┌─ ${label} ${'─'.repeat(Math.max(0, 54 - label.length))}${RESET}`
|
||||||
: `${DIM}${colors.gray}${line}${RESET}`
|
: `${DIM}${colors.gray}${line}${RESET}`
|
||||||
process.stdout.write(text + '\n')
|
process.stdout.write(`${text}\n`)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user