mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Rewritten minLogLevel feature
This commit is contained in:
@ -71,7 +71,7 @@ export function getDefaultPresets(directories) {
|
||||
|
||||
return presets;
|
||||
} catch (err) {
|
||||
console.log('Failed to get default presets', err);
|
||||
console.warn('Failed to get default presets', err);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@ -92,7 +92,7 @@ export function getDefaultPresetFile(filename) {
|
||||
const fileContent = fs.readFileSync(contentPath, 'utf8');
|
||||
return JSON.parse(fileContent);
|
||||
} catch (err) {
|
||||
console.log(`Failed to get default file ${filename}`, err);
|
||||
console.warn(`Failed to get default file ${filename}`, err);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -121,21 +121,21 @@ async function seedContentForUser(contentIndex, directories, forceCategories) {
|
||||
}
|
||||
|
||||
if (!contentItem.folder) {
|
||||
console.log(`Content file ${contentItem.filename} has no parent folder`);
|
||||
console.warn(`Content file ${contentItem.filename} has no parent folder`);
|
||||
continue;
|
||||
}
|
||||
|
||||
const contentPath = path.join(contentItem.folder, contentItem.filename);
|
||||
|
||||
if (!fs.existsSync(contentPath)) {
|
||||
console.log(`Content file ${contentItem.filename} is missing`);
|
||||
console.warn(`Content file ${contentItem.filename} is missing`);
|
||||
continue;
|
||||
}
|
||||
|
||||
const contentTarget = getTargetByType(contentItem.type, directories);
|
||||
|
||||
if (!contentTarget) {
|
||||
console.log(`Content file ${contentItem.filename} has unknown type ${contentItem.type}`);
|
||||
console.warn(`Content file ${contentItem.filename} has unknown type ${contentItem.type}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -144,12 +144,12 @@ async function seedContentForUser(contentIndex, directories, forceCategories) {
|
||||
contentLog.push(contentItem.filename);
|
||||
|
||||
if (fs.existsSync(targetPath)) {
|
||||
console.log(`Content file ${contentItem.filename} already exists in ${contentTarget}`);
|
||||
console.warn(`Content file ${contentItem.filename} already exists in ${contentTarget}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
fs.cpSync(contentPath, targetPath, { recursive: true, force: false });
|
||||
console.log(`Content file ${contentItem.filename} copied to ${contentTarget}`);
|
||||
console.info(`Content file ${contentItem.filename} copied to ${contentTarget}`);
|
||||
anyContentAdded = true;
|
||||
}
|
||||
|
||||
@ -182,12 +182,12 @@ export async function checkForNewContent(directoriesList, forceCategories = [])
|
||||
}
|
||||
|
||||
if (anyContentAdded && !contentCheckSkip && forceCategories?.length === 0) {
|
||||
console.log();
|
||||
console.log(`${color.blue('If you don\'t want to receive content updates in the future, set')} ${color.yellow('skipContentCheck')} ${color.blue('to true in the config.yaml file.')}`);
|
||||
console.log();
|
||||
console.info();
|
||||
console.info(`${color.blue('If you don\'t want to receive content updates in the future, set')} ${color.yellow('skipContentCheck')} ${color.blue('to true in the config.yaml file.')}`);
|
||||
console.info();
|
||||
}
|
||||
} catch (err) {
|
||||
console.log('Content check failed', err);
|
||||
console.error('Content check failed', err);
|
||||
}
|
||||
}
|
||||
|
||||
@ -331,7 +331,7 @@ async function downloadChubLorebook(id) {
|
||||
|
||||
if (!result.ok) {
|
||||
const text = await result.text();
|
||||
console.log('Chub returned error', result.statusText, text);
|
||||
console.error('Chub returned error', result.statusText, text);
|
||||
throw new Error('Failed to download lorebook');
|
||||
}
|
||||
|
||||
@ -355,7 +355,7 @@ async function downloadChubCharacter(id) {
|
||||
|
||||
if (!result.ok) {
|
||||
const text = await result.text();
|
||||
console.log('Chub returned error', result.statusText, text);
|
||||
console.error('Chub returned error', result.statusText, text);
|
||||
throw new Error('Failed to download character');
|
||||
}
|
||||
|
||||
@ -376,7 +376,7 @@ async function downloadPygmalionCharacter(id) {
|
||||
|
||||
if (!result.ok) {
|
||||
const text = await result.text();
|
||||
console.log('Pygsite returned error', result.status, text);
|
||||
console.error('Pygsite returned error', result.status, text);
|
||||
throw new Error('Failed to download character');
|
||||
}
|
||||
|
||||
@ -485,7 +485,7 @@ async function downloadJannyCharacter(uuid) {
|
||||
}
|
||||
}
|
||||
|
||||
console.log('Janny returned error', result.statusText, await result.text());
|
||||
console.error('Janny returned error', result.statusText, await result.text());
|
||||
throw new Error('Failed to download character');
|
||||
}
|
||||
|
||||
@ -577,7 +577,7 @@ async function downloadRisuCharacter(uuid) {
|
||||
|
||||
if (!result.ok) {
|
||||
const text = await result.text();
|
||||
console.log('RisuAI returned error', result.statusText, text);
|
||||
console.error('RisuAI returned error', result.statusText, text);
|
||||
throw new Error('Failed to download character');
|
||||
}
|
||||
|
||||
@ -673,11 +673,11 @@ router.post('/importURL', jsonParser, async (request, response) => {
|
||||
type = chubParsed?.type;
|
||||
|
||||
if (chubParsed?.type === 'character') {
|
||||
console.log('Downloading chub character:', chubParsed.id);
|
||||
console.info('Downloading chub character:', chubParsed.id);
|
||||
result = await downloadChubCharacter(chubParsed.id);
|
||||
}
|
||||
else if (chubParsed?.type === 'lorebook') {
|
||||
console.log('Downloading chub lorebook:', chubParsed.id);
|
||||
console.info('Downloading chub lorebook:', chubParsed.id);
|
||||
result = await downloadChubLorebook(chubParsed.id);
|
||||
}
|
||||
else {
|
||||
@ -692,7 +692,7 @@ router.post('/importURL', jsonParser, async (request, response) => {
|
||||
type = 'character';
|
||||
result = await downloadRisuCharacter(uuid);
|
||||
} else if (isGeneric) {
|
||||
console.log('Downloading from generic url.');
|
||||
console.info('Downloading from generic url.');
|
||||
type = 'character';
|
||||
result = await downloadGenericPng(url);
|
||||
} else {
|
||||
@ -708,7 +708,7 @@ router.post('/importURL', jsonParser, async (request, response) => {
|
||||
response.set('X-Custom-Content-Type', type);
|
||||
return response.send(result.buffer);
|
||||
} catch (error) {
|
||||
console.log('Importing custom content failed', error);
|
||||
console.error('Importing custom content failed', error);
|
||||
return response.sendStatus(500);
|
||||
}
|
||||
});
|
||||
@ -728,22 +728,22 @@ router.post('/importUUID', jsonParser, async (request, response) => {
|
||||
const uuidType = uuid.includes('lorebook') ? 'lorebook' : 'character';
|
||||
|
||||
if (isPygmalion) {
|
||||
console.log('Downloading Pygmalion character:', uuid);
|
||||
console.info('Downloading Pygmalion character:', uuid);
|
||||
result = await downloadPygmalionCharacter(uuid);
|
||||
} else if (isJannny) {
|
||||
console.log('Downloading Janitor character:', uuid.split('_')[0]);
|
||||
console.info('Downloading Janitor character:', uuid.split('_')[0]);
|
||||
result = await downloadJannyCharacter(uuid.split('_')[0]);
|
||||
} else if (isAICC) {
|
||||
const [, author, card] = uuid.split('/');
|
||||
console.log('Downloading AICC character:', `${author}/${card}`);
|
||||
console.info('Downloading AICC character:', `${author}/${card}`);
|
||||
result = await downloadAICCCharacter(`${author}/${card}`);
|
||||
} else {
|
||||
if (uuidType === 'character') {
|
||||
console.log('Downloading chub character:', uuid);
|
||||
console.info('Downloading chub character:', uuid);
|
||||
result = await downloadChubCharacter(uuid);
|
||||
}
|
||||
else if (uuidType === 'lorebook') {
|
||||
console.log('Downloading chub lorebook:', uuid);
|
||||
console.info('Downloading chub lorebook:', uuid);
|
||||
result = await downloadChubLorebook(uuid);
|
||||
}
|
||||
else {
|
||||
@ -756,7 +756,7 @@ router.post('/importUUID', jsonParser, async (request, response) => {
|
||||
response.set('X-Custom-Content-Type', uuidType);
|
||||
return response.send(result.buffer);
|
||||
} catch (error) {
|
||||
console.log('Importing custom content failed', error);
|
||||
console.error('Importing custom content failed', error);
|
||||
return response.sendStatus(500);
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user