npm package: @pesalink/response-utils-package
Description: A shared response utils package that provides api response functions and integrates request and response logging
Author: Nicholas Kute
Latest version: 1.2.14

PesaLink Logger
The PesaLink Logger package provides utilities to enhance logging capabilities for your Node.js applications. It allows you to log method calls dynamically for class prototypes and supports advanced logging strategies such as AOP (Aspect-Oriented Programming). This package includes two main components: AOPLogger and AOPLoggerUtils.

Features
Dynamic Logging: Log all method calls on a class prototype.
Exclusion Support: Exclude specific methods from being logged.
Error-Only Logging: Configure methods to log only errors.
Custom Advice Types: Choose the logging strategy (around, before, after).
Utility-Driven Approach: Use either AOPLogger directly or the AOPLoggerUtils method logMethodsWithAOP.
Installation
Install the package using npm:

bash
Copy code
npm install pesalink-logger
Usage
1. Using AOPLogger Directly
AOPLogger is the core utility to log individual method calls on a class prototype. You can call it directly to configure logging for specific methods.

javascript
Copy code
const AOPLogger = require("pesalink-logger/aopLogger");

AOPLogger.logMethodCall(
  classPrototype, // The class prototype
  methodName,     // Name of the method to log
  className,      // Name of the class
  methodType,     // Optional: Type of method (e.g., "getAll" for error logging)
  adviceType,     // Optional: Type of advice (default: "around")
  classType       // Optional: Class type for custom logging
);
2. Using AOPLoggerUtils.logMethodsWithAOP
The logMethodsWithAOP method in AOPLoggerUtils simplifies logging for all methods in a class prototype, with options to exclude specific methods or log errors only for some.

javascript
Copy code
const { logMethodsWithAOP } = require("pesalink-logger/aopLoggerUtils");

logMethodsWithAOP(
  classPrototype,        // Prototype of the class
  excludedMethods = [],  // Methods to exclude from logging
  logErrorsOnly = [],    // Methods to log only errors (e.g., "getAll")
  className,             // Name of the class for logging context
  classType,             // Optional: Class type for custom strategies
  adviceType = "around"  // Optional: Advice type (default: "around")
);
## Parameters for logMethodsWithAOP
Parameter	Description
classPrototype	The prototype of the class whose methods you want to log.
excludedMethods	Array of method names to exclude from logging.
logErrorsOnly	Array of methods for which only errors should be logged (e.g., getAll).
className	The name of the class (used for logging context).
classType	The type of the class (optional, used in custom logging strategies).
adviceType	The type of advice (optional, default is "around" for method execution).
Example: Dynamic Logging
Below is an example demonstrating the use of AOPLoggerUtils to log method calls dynamically on a class:

```
const { logMethodsWithAOP } = require("pesalink-logger/aopLoggerUtils");

class MyService {
  constructor() {}

  fetchData() {
    console.log("Fetching data...");
  }

  saveData() {
    console.log("Saving data...");
  }

  getAll() {
    throw new Error("An error occurred while fetching all data!");
  }
}

// Exclude `saveData` and log only errors for `getAll`
logMethodsWithAOP(
  MyService.prototype,
  ["saveData"],        // Excluded methods
  ["getAll"],          // Log errors only
  "MyService"          // Class name
);

// Instantiate and test logging
const service = new MyService();
service.fetchData();
try {
  service.getAll();
} catch (error) {}
```

``Integration Notes
The AOPLogger class provides the low-level API for method call logging.
The AOPLoggerUtils.logMethodsWithAOP method wraps around AOPLogger to simplify configuration for dynamic logging of class prototypes.
Both utilities are included in the pesalink-logger package and can be used interchangeably based on your project needs.