fix lint errors about use of console and new() cache
This commit is contained in:
parent
6c2206ab72
commit
deff0c0f49
5 changed files with 34 additions and 16 deletions
|
|
@ -33,21 +33,21 @@ const themeColor = chalk.hex('#86b300');
|
|||
function greet() {
|
||||
if (!envOption.quiet) {
|
||||
//#region Misskey logo
|
||||
console.log(themeColor(' _____ _ _ '));
|
||||
console.log(themeColor('/ ___| | | | '));
|
||||
console.log(themeColor('\\ `--.| |__ __ _ _ __| | _____ _ _ '));
|
||||
console.log(themeColor(' `--. \\ \'_ \\ / _` | \'__| |/ / _ \\ | | |'));
|
||||
console.log(themeColor('/\\__/ / | | | (_| | | | < __/ |_| |'));
|
||||
console.log(themeColor('\\____/|_| |_|\\__,_|_| |_|\\_\\___|\\__, |'));
|
||||
console.log(themeColor(' __/ |'));
|
||||
console.log(themeColor(' |___/ '));
|
||||
logger.info(themeColor(' _____ _ _ '));
|
||||
logger.info(themeColor('/ ___| | | | '));
|
||||
logger.info(themeColor('\\ `--.| |__ __ _ _ __| | _____ _ _ '));
|
||||
logger.info(themeColor(' `--. \\ \'_ \\ / _` | \'__| |/ / _ \\ | | |'));
|
||||
logger.info(themeColor('/\\__/ / | | | (_| | | | < __/ |_| |'));
|
||||
logger.info(themeColor('\\____/|_| |_|\\__,_|_| |_|\\_\\___|\\__, |'));
|
||||
logger.info(themeColor(' __/ |'));
|
||||
logger.info(themeColor(' |___/ '));
|
||||
//#endregion
|
||||
|
||||
console.log(' Sharkey is an open-source decentralized microblogging platform.');
|
||||
console.log(chalk.rgb(255, 136, 0)(' If you like Sharkey, please donate to support development. https://opencollective.com/sharkey'));
|
||||
logger.info(' Sharkey is an open-source decentralized microblogging platform.');
|
||||
logger.info(chalk.rgb(255, 136, 0)(' If you like Sharkey, please donate to support development. https://opencollective.com/sharkey'));
|
||||
|
||||
console.log('');
|
||||
console.log(chalkTemplate`--- ${os.hostname()} {gray (PID: ${process.pid.toString()})} ---`);
|
||||
logger.info('');
|
||||
logger.info(chalkTemplate`--- ${os.hostname()} {gray (PID: ${process.pid.toString()})} ---`);
|
||||
}
|
||||
|
||||
bootLogger.info('Welcome to Sharkey!');
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ import { DI } from '@/di-symbols.js';
|
|||
import { TimeService } from '@/core/TimeService.js';
|
||||
import { InternalEventService } from '@/core/InternalEventService.js';
|
||||
|
||||
// This is the one place that's *supposed* to new() up caches.
|
||||
/* eslint-disable no-restricted-syntax */
|
||||
|
||||
export type ManagedMemoryKVCache<T> = Managed<MemoryKVCache<T>>;
|
||||
export type ManagedMemorySingleCache<T> = Managed<MemorySingleCache<T>>;
|
||||
export type ManagedRedisKVCache<T> = Managed<RedisKVCache<T>>;
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ export class QuantumKVCache<T> implements Iterable<readonly [key: string, value:
|
|||
services: QuantumCacheServices,
|
||||
opts: QuantumKVOpts<T>,
|
||||
) {
|
||||
// OK: we forward all management calls to the inner cache.
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
this.memoryCache = new MemoryKVCache(opts.lifetime, services);
|
||||
this.fetcher = opts.fetcher;
|
||||
this.bulkFetcher = opts.bulkFetcher;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ export class RedisKVCache<T> {
|
|||
) {
|
||||
this.redisClient = services.redisClient;
|
||||
this.lifetime = opts.lifetime;
|
||||
// OK: we forward all management calls to the inner cache.
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
this.memoryCache = new MemoryKVCache(opts.memoryCacheLifetime, services);
|
||||
this.fetcher = opts.fetcher ?? (() => { throw new Error('fetch not supported - use get/set directly'); });
|
||||
this.toRedisConverter = opts.toRedisConverter ?? ((value) => JSON.stringify(value));
|
||||
|
|
@ -150,6 +152,8 @@ export class RedisSingleCache<T> {
|
|||
) {
|
||||
this.redisClient = services.redisClient;
|
||||
this.lifetime = opts.lifetime;
|
||||
// OK: we forward all management calls to the inner cache.
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
this.memoryCache = new MemorySingleCache(opts.memoryCacheLifetime, services);
|
||||
|
||||
this.fetcher = opts.fetcher ?? (() => { throw new Error('fetch not supported - use get/set directly'); });
|
||||
|
|
@ -198,7 +202,7 @@ export class RedisSingleCache<T> {
|
|||
|
||||
@bindThis
|
||||
public clear(): void {
|
||||
this.memoryCache.delete();
|
||||
this.memoryCache.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -233,6 +237,7 @@ export class RedisSingleCache<T> {
|
|||
@bindThis
|
||||
public dispose(): void {
|
||||
this.clear();
|
||||
this.memoryCache.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,10 +3,18 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { LoggerService } from '@/core/LoggerService.js';
|
||||
import type Logger from '@/logger.js';
|
||||
|
||||
export class I18n<T extends Record<string, any>> {
|
||||
private readonly logger: Logger;
|
||||
public locale: T;
|
||||
|
||||
constructor(locale: T) {
|
||||
constructor(
|
||||
loggerService: LoggerService,
|
||||
locale: T,
|
||||
) {
|
||||
this.logger = loggerService.getLogger('i18n');
|
||||
this.locale = locale;
|
||||
|
||||
//#region BIND
|
||||
|
|
@ -26,8 +34,8 @@ export class I18n<T extends Record<string, any>> {
|
|||
}
|
||||
}
|
||||
return str;
|
||||
} catch (e) {
|
||||
console.warn(`missing localization '${key}'`);
|
||||
} catch {
|
||||
this.logger.warn(`missing localization '${key}'`);
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue