Skip to content

Commit

Permalink
add logger.debug calls to dev and build
Browse files Browse the repository at this point in the history
  • Loading branch information
FredKSchott committed Oct 10, 2020
1 parent b342b71 commit fa4e76a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions snowpack/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ export async function command(commandOptions: CommandOptions) {

for (const runPlugin of config.plugins) {
if (runPlugin.run) {
logger.debug(`starting ${runPlugin.name} run() (isDev=${isDev})`);
const runJob = runPlugin
.run({
isDev: isDev,
Expand All @@ -328,6 +329,7 @@ export async function command(commandOptions: CommandOptions) {
}

// Write the `import.meta.env` contents file to disk
logger.debug(`generating meta files`);
await fs.writeFile(path.join(internalFilesBuildLoc, 'env.js'), generateEnvModule('production'));
if (getIsHmrEnabled(config)) {
await fs.writeFile(path.resolve(internalFilesBuildLoc, 'hmr-client.js'), HMR_CLIENT_CODE);
Expand Down
10 changes: 10 additions & 0 deletions snowpack/src/commands/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ export async function startServer(commandOptions: CommandOptions) {

if (config.devOptions.output === 'dashboard') {
// "dashboard": Pipe console methods to the logger, and then start the dashboard.
logger.debug(`attaching console.log listeners`);
console.log = (...args: [any, ...any[]]) => {
logger.info(util.format(...args));
};
Expand All @@ -248,6 +249,7 @@ export async function startServer(commandOptions: CommandOptions) {
console.error = (...args: [any, ...any[]]) => {
logger.error(util.format(...args));
};
logger.debug(`starting dashboard`);
paintDashboard(
messageBus,
config.plugins.map((p) => p.name),
Expand Down Expand Up @@ -324,6 +326,7 @@ export async function startServer(commandOptions: CommandOptions) {
let credentials: {cert: Buffer; key: Buffer} | undefined;
if (config.devOptions.secure) {
try {
logger.debug(`reading credentials`);
credentials = await readCredentials(cwd);
} catch (e) {
logger.error(
Expand All @@ -347,6 +350,7 @@ export async function startServer(commandOptions: CommandOptions) {

for (const runPlugin of config.plugins) {
if (runPlugin.run) {
logger.debug(`starting ${runPlugin.name} run() in watch/isDev mode`);
runPlugin
.run({
isDev: true,
Expand Down Expand Up @@ -915,6 +919,12 @@ export async function startServer(commandOptions: CommandOptions) {
};

const server = createServer((req, res) => {
// Attach a request logger.
res.on('finish', () => {
const {method, url} = req;
const {statusCode} = res;
logger.debug(`[${statusCode}] ${method} ${url}`);
});
/** Handle errors not handled in our requestHandler. */
function onUnhandledError(err: Error) {
logger.error(err.toString());
Expand Down

0 comments on commit fa4e76a

Please sign in to comment.