pnp / pnp/cli-microsoft365

Standardizing logging across commands

Open
#5,931 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

epic needs design
Dominant language
TypeScript
Stars
1.5k
Forks
413
Avg merge
5d 6h
Merged PRs (30d)
21

Description

We're aiming to enhance the clarity and consistency of verbose and debug messages across our commands. This effort will help make our logging more uniform and informative. Below is the first draft of some guidelines on how and when to implement each type of logging.

Verbose Logging

  • Prefix each log entry with a timestamp to aid in debugging and tracing. Format: [YYYY-MM-DD HH:MM:SS] Message
    • Here I would even look into coloring the timestamp clearly to make it more visual.
    • Maybe even work out some logic where we add some more whitespace after each log.
  • Begin each command with a concise description of its action, e.g., [2024-03-23 15:45:15] Listing all Teams Apps...
  • Log each API endpoint called, e.g., [2024-03-23 15:45:30] GET: "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps?$filter=distributionMethod eq 'organization'"

Debug Logging

  • Focus on logging internal processes, such as received options, token validity, the complete API request being made, and timing reports.
  • Avoid adding custom logs in commandAction to explain actions being performed. If they want to do this, it should be a verbose log instead.

To facilitate the changes suggested for verbose logging, I propose adding a new property to Logger, such as logger.logVerbose. This will allow us to centralize the logic for checking the verbose flag and formatting messages with a timestamp in cli.ts. Consequently, writing verbose messages within commandAction will become more straightforward.

Implementation Steps

  • Explore NPM packages for logging usage.
  • Finalize the guidelines.
  • Define the next steps.
    ...
  • Apply these changes to each command.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing cli.ts, Logger, and existing commandAction logging, then explore the NPM logging packages mentioned in the issue. The guidelines still need to be finalized before implementation; done would mean agreed verbose and debug behavior applied consistently across each command.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli, tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.