Notary Public Mystifier

    @drizzle-http/logging-interceptor
    TypeScript icon, indicating that this package has built-in type declarations

    3.1.0 • Public • Published

    Logging Interceptor · ci npm (scoped) GitHub license

    Drizzle-Http interceptor that logs HTTP requests and responses.
    The default Logger implementation uses Pino.

    Installation

    Make sure we have the core module @Drizzle-Http/core installed.

    npm i @drizzle-http/core
    npm i @drizzle-http/logging-interceptor
    

    Node

    Basic

    import { LoggingInterceptor } from '@drizzle-http/logging-interceptor'
    import { DrizzleBuilder } from "@drizzle-http/core";
    import { UndiciCallFactory } from "@drizzle-http/undici";
    
    const interceptor = new LoggingInterceptor()
    
    const api = DrizzleBuilder
      .newBuilder()
      .baseUrl(address)
      .callFactory(new UndiciCallFactory())
      .addInterceptor(interceptor)
      .build()
      .create(API)

    Customize

    import { LoggingInterceptor } from '@drizzle-http/logging-interceptor'
    import { Level } from "@drizzle-http/logging-interceptor";
    import { DrizzleBuilder } from "@drizzle-http/core";
    import { UndiciCallFactory } from "@drizzle-http/undici";
    
    const interceptor = new LoggingInterceptor({ level: Level.Body, logger: customLogger })
    interceptor.redactHeader('x-super-secret-header')
    interceptor.redactHeaders(['x-other-secret-header', 'x-one-more-secret-header'])
    
    const api = DrizzleBuilder
      .newBuilder()
      .baseUrl(address)
      .callFactory(new UndiciCallFactory())
      .addInterceptor(interceptor)
      .build()
      .create(API)

    Browser

    Basic

    import { BrowserLoggingInterceptor } from '@drizzle-http/logging-interceptor'
    
    const api = DrizzleBuilder
      .newBuilder()
      .baseUrl(address)
      .callFactory(new UndiciCallFactory())
      .addInterceptor(new BrowserLoggingInterceptor())
      .build()
      .create(API)

    It's not possible to change the logger implementation from BrowserLoggingInterceptor. It will use console.log.

    Install

    npm i @drizzle-http/logging-interceptor

    DownloadsWeekly Downloads

    22

    Version

    3.1.0

    License

    MIT

    Unpacked Size

    37.8 kB

    Total Files

    25

    Last publish

    Collaborators

    • vitor.salgado