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)
|
||||
})),
|
||||
)
|
||||
log.divider('CollectPageVacancies')
|
||||
log.info('URL:', page.url())
|
||||
log.info('Max page:', maxPage)
|
||||
for (let p = 1; p <= maxPage; p++) {
|
||||
const pageUrl = `https://hh.ru/search/vacancy?text=${encodeURIComponent(query)}&items_on_page=100&page=${p}`
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
const RESET = '\x1b[0m'
|
||||
const BOLD = '\x1b[1m'
|
||||
const DIM = '\x1b[2m'
|
||||
const RESET = '\x1B[0m'
|
||||
const BOLD = '\x1B[1m'
|
||||
const DIM = '\x1B[2m'
|
||||
|
||||
const colors = {
|
||||
gray: '\x1b[90m',
|
||||
green: '\x1b[32m',
|
||||
yellow: '\x1b[33m',
|
||||
red: '\x1b[31m',
|
||||
cyan: '\x1b[36m',
|
||||
magenta: '\x1b[35m',
|
||||
blue: '\x1b[34m',
|
||||
white: '\x1b[37m',
|
||||
gray: '\x1B[97m',
|
||||
green: '\x1B[92m',
|
||||
yellow: '\x1B[93m',
|
||||
red: '\x1B[91m',
|
||||
cyan: '\x1B[96m',
|
||||
magenta: '\x1B[95m',
|
||||
blue: '\x1B[94m',
|
||||
white: '\x1B[97m',
|
||||
}
|
||||
|
||||
const LEVELS = {
|
||||
@@ -39,7 +39,7 @@ function formatTag(tag: string): string {
|
||||
|
||||
function formatArgs(args: unknown[]): string {
|
||||
return args
|
||||
.map((a) =>
|
||||
.map(a =>
|
||||
typeof a === 'object' && a !== null
|
||||
? JSON.stringify(a, null, 2)
|
||||
: String(a),
|
||||
@@ -56,9 +56,10 @@ function print(level: Level, tag: string, args: unknown[]): void {
|
||||
`${color}${formatArgs(args)}${RESET}`,
|
||||
]
|
||||
if (level === 'error') {
|
||||
process.stderr.write(parts.join(' ') + '\n')
|
||||
} else {
|
||||
process.stdout.write(parts.join(' ') + '\n')
|
||||
process.stderr.write(`${parts.join(' ')}\n`)
|
||||
}
|
||||
else {
|
||||
process.stdout.write(`${parts.join(' ')}\n`)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +76,7 @@ export function createLogger(tag: string) {
|
||||
const text = label
|
||||
? `${DIM}${colors.gray}┌─ ${label} ${'─'.repeat(Math.max(0, 54 - label.length))}${RESET}`
|
||||
: `${DIM}${colors.gray}${line}${RESET}`
|
||||
process.stdout.write(text + '\n')
|
||||
process.stdout.write(`${text}\n`)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user