Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import 'dotenv/config'
import winston from 'winston'
import DailyRotateFile from 'winston-daily-rotate-file'
import path from 'path'
// Sentry 初期化(環境変数で管理するのが一般的)
const SENTRY_DSN = process.env.SENTRY_DSN || ''
const useSentry = SENTRY_DSN.trim() !== ''
// if (useSentry) {
// SentryNode.init({
// dsn: SENTRY_DSN,
// environment: process.env.NODE_ENV || 'development',
// })
// }
const MAX_LOG_AGE = process.env.MAX_LOG_AGE || '7d' // 例: '365d', '5y'
const LOG_DIR = process.env.LOG_DIR || '/var/log/resume'
const customLevels = {
levels: {
fatal: 0,
error: 1,
warn: 2,
info: 3,
debug: 4,
trace: 5,
},
colors: {
fatal: 'red',
error: 'magenta',
warn: 'yellow',
info: 'green',
debug: 'blue',
trace: 'grey'
}
}
const transports = [
new DailyRotateFile({
level: 'trace',
filename: path.join(LOG_DIR, 'frontend-%DATE%.log'),
datePattern: 'YYYY-MM-DD',
maxSize: '10m',
maxFiles: MAX_LOG_AGE,
zippedArchive: true,
format: winston.format.combine(
winston.format.timestamp(),
winston.format.json()
)
}),
new winston.transports.Console({
level: 'trace',
format: winston.format.combine(
winston.format.timestamp(),
winston.format.json()
)
}),
// new Sentry({
// sentry: SentryNode,
// level: 'error', // ✅ ここで「エラー以上のみSentryへ送信」
// format: winston.format.json()
// })
]
// winston.addColors(customLevels.colors)
const logger = winston.createLogger({
levels: customLevels.levels,
level: 'trace', // ← 最低出力レベル(trace, debug, info, warn, error)
transports
})
export default logger
|