open-index/open-npm huggingface dataset:
npm package: @magnolia-services/mgnl-logger
Description: A class for logging messages with different log levels.
Latest version: 0.0.1-alpha.1

# MagnoliaLogger

A class for logging messages with different log levels.

## Installation

```bash
npm install @magnolia-services/mgnl-logger
```

## Usage

```javascript
import MagnoliaLogger from "@magnolia-services/mgnl-logger";

const logger = new MagnoliaLogger(MyClass); // this

logger.debug("Debug message"); // Will log a message with log level DEBUG
logger.info("Info message"); // Will log a message with log level INFO
logger.warning("Warning message"); // Will log a message with log level WARNING
logger.error("Error message"); // Will log a message with log level ERROR
```

**The log level of the logger can be set by setting window.MgnlLogLevel. If window.MgnlLogLevel is not set, the default log level is LOG_LEVELS.ERROR.**

# API

## new MagnoliaLogger(clazz)

Creates a new MagnoliaLogger instance.

## clazz: (Object) The class to associate with this logger.

## setLogLevel(level)

Sets the log level of the logger.

## level: (number)

The log level to set. Must be one of the LOG_LEVELS values.

## LOG_LEVELS

The log levels that can be used with the logger.

- DEBUG: 0
- INFO: 1
- WARNING: 2
- ERROR: 3

## log(level, label, message, ...args)

Logs a message with the given log level.

- level: (number) The log level of the message.
- label: (string) The label to add to the log message.
- message: (string) The message to log.
- args: (any) Additional arguments to log.

## debug(message, ...args)

Logs a message with log level DEBUG.

- message: (string) The message to log.
- args: (any) Additional arguments to log.

## info(message, ...args)

Logs a message with log level INFO.

- message: (string) The message to log.
- args: (any) Additional arguments to log.

## warning(message, ...args)

Logs a message with log level WARNING.

- message: (string) The message to log.
- args: (any) Additional arguments to log.

## error(message, ...args)

Logs a message with log level ERROR.

- message: (string) The message to log.
- args: (any) Additional arguments to log.