mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-20 03:32:29 +02:00
refactor: unify log format with new logger utility (#5994)
Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com>
This commit is contained in:
parent
faef753730
commit
770418f8d2
66 changed files with 717 additions and 650 deletions
|
@ -57,7 +57,7 @@ describe('DefaultSidebarItemsGenerator', () => {
|
|||
expect(sidebarSlice).toEqual([]);
|
||||
expect(consoleWarn).toHaveBeenCalledWith(
|
||||
expect.stringMatching(
|
||||
/No docs found in dir .: can't auto-generate a sidebar/,
|
||||
/.*\[WARNING\].* No docs found in .*\..*: can't auto-generate a sidebar\..*/,
|
||||
),
|
||||
);
|
||||
});
|
||||
|
|
|
@ -16,7 +16,7 @@ import type {
|
|||
} from './types';
|
||||
import {sortBy, last} from 'lodash';
|
||||
import {addTrailingSlash, posixPath} from '@docusaurus/utils';
|
||||
import chalk from 'chalk';
|
||||
import logger from '@docusaurus/logger';
|
||||
import path from 'path';
|
||||
import fs from 'fs-extra';
|
||||
import Yaml from 'js-yaml';
|
||||
|
@ -72,11 +72,7 @@ async function readCategoryMetadataFile(
|
|||
try {
|
||||
return validateCategoryMetadataFile(unsafeContent);
|
||||
} catch (e) {
|
||||
console.error(
|
||||
chalk.red(
|
||||
`The docs sidebar category metadata file looks invalid!\nPath: ${filePath}`,
|
||||
),
|
||||
);
|
||||
logger.error`The docs sidebar category metadata file path=${filePath} looks invalid!`;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -134,11 +130,7 @@ export const DefaultSidebarItemsGenerator: SidebarItemsGenerator = async ({
|
|||
const docs = allDocs.filter(isInAutogeneratedDir);
|
||||
|
||||
if (docs.length === 0) {
|
||||
console.warn(
|
||||
chalk.yellow(
|
||||
`No docs found in dir ${autogenDir}: can't auto-generate a sidebar.`,
|
||||
),
|
||||
);
|
||||
logger.warn`No docs found in path=${autogenDir}: can't auto-generate a sidebar.`;
|
||||
}
|
||||
return docs;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue