Skip to content

Pretty printing logs #480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Feb 17, 2022
Merged

Pretty printing logs #480

merged 11 commits into from
Feb 17, 2022

Conversation

caass
Copy link
Contributor

@caass caass commented Feb 16, 2022

Implement wrangler tail --pretty to output human-readable text instead of JSON. Here's a screenshot of it in use:

Screen Shot 2022-02-17 at 9 52 53 AM

You can see the output from two different requests, as well as a cron trigger.

For reference, the code used in this worker is:

export default {
  fetch(request) {
    switch (request.method) {
      case "GET":
        console.log("get request received");
        break;
      case "POST":
        console.warn("POST request received");
        break;
      case "PUT":
        console.error("PUT request received");
        break;
      default:
        throw new Error(`Recieved ${request.method} request`);
    }

    console.log("sending response");
    return new Response(request.method);
  },
};

The cron errors because i added a trigger while testing cron messages and then removed the handler -- but it demonstrates how cron logs look!

@caass caass requested a review from threepointone as a code owner February 16, 2022 18:29
@changeset-bot
Copy link

changeset-bot bot commented Feb 16, 2022

🦋 Changeset detected

Latest commit: 09d73b8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wrangler Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Feb 16, 2022

A wrangler prerelease is available for testing. You can install it in your project with:

npm install --save-dev https://prerelease-registry.developers.workers.dev/runs/1860779332/wrangler

Or you can try developing a worker directly with:

npx https://prerelease-registry.developers.workers.dev/runs/1860779332/wrangler dev path/to/script.js

@caass caass marked this pull request as draft February 16, 2022 21:58
@caass caass changed the title Refactoring in preparation for pretty mode Pretty printing logs Feb 17, 2022
@caass caass marked this pull request as ready for review February 17, 2022 16:15
Copy link
Contributor

@threepointone threepointone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I paired with @caass on a review, and pointed out nits, looks good otherwise! Tentatively approving.

@caass caass merged commit 10cb789 into main Feb 17, 2022
@caass caass deleted the tail-pretty branch February 17, 2022 20:14
@github-actions github-actions bot mentioned this pull request Feb 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants