@shutootaki/gwm
Version:
git worktree manager CLI
47 lines • 1.32 kB
JavaScript
import { isTestEnvironment } from './common/index.js';
/**
* ANSI カラーコード
*/
const colors = {
green: '\x1b[32m',
red: '\x1b[31m',
yellow: '\x1b[33m',
gray: '\x1b[90m',
reset: '\x1b[0m',
bold: '\x1b[1m',
};
/**
* 色付きログユーティリティを作成
*
* @param suppressInTest true の場合、テスト環境ではログを出力しない
*/
export function createLogger(suppressInTest = true) {
const shouldLog = () => !suppressInTest || !isTestEnvironment();
return {
success: (message) => {
if (shouldLog()) {
console.log(`${colors.green}${message}${colors.reset}`);
}
},
error: (message) => {
if (shouldLog()) {
console.error(`${colors.red}${message}${colors.reset}`);
}
},
info: (message) => {
if (shouldLog()) {
console.log(`${colors.gray}${message}${colors.reset}`);
}
},
warn: (message) => {
if (shouldLog()) {
console.warn(`${colors.yellow}${message}${colors.reset}`);
}
},
};
}
/**
* デフォルトロガー(テスト環境では出力抑制)
*/
export const logger = createLogger(true);
//# sourceMappingURL=logger.js.map