Skip to content

logHandler isn't logging anything #2153

@eloisetaylor5693

Description

Expected Behavior

When specifying loghandler AND forcing errors such as invalid requests to contentful, then errors should be logged.

      logHandler: (level: string, data) => {
        console.log('CONTENTFUL LOG', { level, data });
      },

Actual Behavior

when configuring with our winston logger, no logs seen:

    this.client = createClient({
      environment: 'abc',
      space: 'abc',
      accessToken: 'abc',
      logHandler: (level: string, data) => {
        Logger.log(level, 'Contentful log', {
          type: 'contentful',
          properties: {
            space: 'PIM',
            data,
          },
        });
      },
    });

when using console.log, no logs seen:

    this.client = createClient({
      environment: 'abc',
      space: 'abc',
      accessToken: 'abc',
      logHandler: (level: string, data) => {
        console.log('CONTENTFUL LOG', { level, data });
      },
    });

Possible Solution

Steps to Reproduce

  1. Configure log handler
  2. Break a request. Eg fields.slug[match] => fields.slugskjhgjkdshgj[match]
  3. no logging

Context

If contentful is logging useful debug info, I want that in my logs too

Environment

  • Language Version: v20.10.0
  • Package Manager Version: 10.2.3
  • Browser Version:
  • Operating System: 23.3.0 Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:44 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6000 arm64
  • Package Version: 10.6.5
  • Which API are you using?: Delivery

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions