tslint changes

This commit is contained in:
Jeremy Simpson
2019-08-30 01:52:40 -07:00
parent 7603879d35
commit 7f7efbb94b
446 changed files with 70650 additions and 70661 deletions
+50 -50
View File
@@ -11,95 +11,95 @@ import { ID } from './db';
const { reset, gray, magenta, cyan, green, yellow, red } = chalk;
function format(color: (text: string) => string) {
//'[{{timestamp}}] [{{title}}] {{message}} ({{file}}:{{line}})',
return [
reset('['),
gray('{{timestamp}}'),
reset('] ['),
color('{{title}}'),
reset('] {{message}} '),
gray('({{file}}:{{line}})'),
].join('');
//'[{{timestamp}}] [{{title}}] {{message}} ({{file}}:{{line}})',
return [
reset('['),
gray('{{timestamp}}'),
reset('] ['),
color('{{title}}'),
reset('] {{message}} '),
gray('({{file}}:{{line}})'),
].join('');
}
export const logger = console({
level: 0,
dateformat: 'mmm dd HH:MM:ss',
format: [
format(reset),
{
trace: format(cyan),
debug: format(magenta),
info: format(green),
warn: format(yellow),
error: format(red),
}
],
level: 0,
dateformat: 'mmm dd HH:MM:ss',
format: [
format(reset),
{
trace: format(cyan),
debug: format(magenta),
info: format(green),
warn: format(yellow),
error: format(red),
}
],
} as any);
const daily = dailyfile({
root: pathTo('logs'),
maxLogFiles: 14,
dateformat: 'HH:MM:ss',
format: '{{timestamp}} {{message}}', // ({{file}}:{{line}})
root: pathTo('logs'),
maxLogFiles: 14,
dateformat: 'HH:MM:ss',
format: '{{timestamp}} {{message}}', // ({{file}}:{{line}})
} as any);
export function log(message: string) {
daily.info(message);
daily.info(message);
}
export function formatMessage(accountId: ID, type: string, message: string) {
return `[${accountId}]${type}\t${message}`;
return `[${accountId}]${type}\t${message}`;
}
export function systemMessage(accountId: ID, message: string) {
return formatMessage(accountId, '[system]', message);
return formatMessage(accountId, '[system]', message);
}
function adminMessage(accountId: ID, message: string) {
return formatMessage(accountId, '[admin]', message);
return formatMessage(accountId, '[admin]', message);
}
export function system(accountId: ID, message: string) {
log(systemMessage(accountId, message));
log(systemMessage(accountId, message));
}
export function admin(accountId: ID, message: string) {
log(adminMessage(accountId, message));
log(adminMessage(accountId, message));
}
export function logPatreon(message: string) {
log(formatMessage('patreon', '', message));
log(formatMessage('patreon', '', message));
}
export function logServer(message: string) {
log(formatMessage('server', '', message));
log(formatMessage('server', '', message));
}
export function logPerformance(message: string) {
log(formatMessage('performance', '', message));
log(formatMessage('performance', '', message));
}
export function chat(
server: ServerConfig, client: IClient, text: string, type: ChatType, ignored: boolean, target: IClient | undefined
server: ServerConfig, client: IClient, text: string, type: ChatType, ignored: boolean, target: IClient | undefined
) {
let prefix = getChatPrefix(type);
let mod = '';
let prefix = getChatPrefix(type);
let mod = '';
if (ignored) {
mod = '[ignored]';
} else if (isMutedOrShadowed(client)) {
mod = '[muted]';
} else if (client.accountSettings.ignorePublicChat && isPublicChat(type)) {
mod = '[ignorepub]';
}
if (ignored) {
mod = '[ignored]';
} else if (isMutedOrShadowed(client)) {
mod = '[muted]';
} else if (client.accountSettings.ignorePublicChat && isPublicChat(type)) {
mod = '[ignorepub]';
}
if (type === ChatType.Whisper) {
prefix += `[${target ? `${target.accountId}${target.shadowed ? '][shadowed' : ''}` : 'undefined'}] `;
}
if (type === ChatType.Whisper) {
prefix += `[${target ? `${target.accountId}${target.shadowed ? '][shadowed' : ''}` : 'undefined'}] `;
}
const message = formatMessage(
client.accountId, `[${server.id}][${client.map.id || 'main'}][${client.characterName}]${mod}`, `${prefix}${text}`);
const message = formatMessage(
client.accountId, `[${server.id}][${client.map.id || 'main'}][${client.characterName}]${mod}`, `${prefix}${text}`);
log(message);
log(message);
}