Skip to content
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

Improve logging #27

Closed
wants to merge 1 commit into from
Closed

Improve logging #27

wants to merge 1 commit into from

Conversation

WilmsJochen
Copy link
Contributor

No description provided.

Copy link

PR review

‼️ It seems that you can still improve the quality of your PR. Have a look into this:

❌ Avoid console.log statements

Using console.log statements in production code is not recommended as it can lead to unstructured logging and difficulty in debugging. Instead, using a structured logging utility helps in maintaining consistency and provides better control over log levels and outputs.

Here's how you can replace console.log with a logger from the utils:

filename: demo-microservice/src/services/exampleService.js

// Import the logger utility
const logger = require('../utils/logger');

// Replace console.log with logger
function exampleFunction() {
    // Old code
    // console.log('This is a log message');

    // New code
    logger.info('This is a log message');
}

By using a structured logger, you ensure that all log messages are consistent and easier to manage.

❌ Never log business data on info level

Logging business data at the info level can expose sensitive information and clutter the logs, making it harder to debug issues. Using debug level logging for business data ensures that this information is only available when needed for troubleshooting and not in regular operation logs.

Here's how you can make the change:

filename: demo-microservice/src/services/exampleService.js

// Original code
console.log('Business data:', result);

// Updated code
console.debug('Business data:', result);

This change ensures that business data is logged at the debug level, adhering to best practices for logging sensitive information.

sidenote:

✅ Deployment & testing pipelines
❌ Docker file structure:
   Your Dockerfile is missing from the repository. Ensure it is placed at the root level of the project. Additionally, follow the provided example closely, including using multiple build stages, not running as root, and maintaining the order of commands.
✅ File structure based on example repo
✅ Usage of proper tests [Unit tests, Postman etc.]
❌ General coding guidelines:
   - Updated Readme File:
      The README.md file is incomplete. It should contain setup instructions and how to run the application.
   - Use Retries for External APIs:
      No evidence of retries in API calls. Implement retry logic for external API calls.
⚠️ This repo is currently not following company guidelines.

You might want to look into this so I prepared some PR's to bring it up to date.

Generated by Firstmate to make sure you can focus on coding new features.

@WilmsJochen
Copy link
Contributor Author

@firstmate please fix

@wvl94 wvl94 closed this Sep 12, 2024
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