Skip to content

Crown-Commercial-Service/digitalmarketplace-utils

This branch is 1 commit ahead of main.

Folders and files

NameName
Last commit message
Last commit date
Jan 16, 2024
Jan 16, 2024
Feb 19, 2019
Jan 16, 2024
Feb 26, 2021
Oct 15, 2021
Mar 17, 2021
Oct 15, 2021
Jun 17, 2019
May 12, 2021
Oct 15, 2021
Nov 27, 2017
Mar 5, 2021
Oct 15, 2021
Dec 10, 2019
Sep 25, 2017
Oct 15, 2021
Sep 21, 2018
Oct 15, 2021
Jul 21, 2024
Mar 13, 2023
Feb 26, 2021

Repository files navigation

Digital Marketplace utils

Python 3.8

What's in here?

  • Digital Marketplace API clients
  • Formatting utilities for Digital Marketplace
  • Digital Marketplace logging for Flask using JSON Logging
  • Utility functions/libraries for Amazon S3, Mailchimp, Notify, Cloudwatch
  • Helper code for Flask configuration
  • A formed version of Flask Feature Flags

Logging from applications

When logging from applications you should write your message as a format string and pass any required arguments to the log method in the extra named argument. This allows our logging to use them as separate fields in our JSON logs making it much easier to search and aggregate on them.

logger.info("the user {user_id} did the thing '{thing}'", extra={
    'user_id': user_id, 'thing': thing
})

Note that apart from not getting the benefit, passing the formatted message can be dangerous. User generated content may be passed, unescaped to the .format method.

Versioning

Releases of this project follow semantic versioning, ie

Given a version number MAJOR.MINOR.PATCH, increment the:

  • MAJOR version when you make incompatible API changes,
  • MINOR version when you add functionality in a backwards-compatible manner, and
  • PATCH version when you make backwards-compatible bug fixes.

To make a new version:

  • update the version in the dmutils/__init__.py file
  • if you are making a major change, also update the change log;

When the pull request is merged a GitHub Action will tag the new version.

Licence

Unless stated otherwise, the codebase is released under the MIT License. This covers both the codebase and any sample code in the documentation.

The documentation is © Crown copyright and available under the terms of the Open Government 3.0 licence.