# @odg/log

> Interface logs types

Latest version **1.20.0** (published 2026-08-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @odg/log
pnpm add @odg/log
yarn add @odg/log
bun add @odg/log
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.20.0 |
| Published | 2026-08-17 |
| First published | 2022-11-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 120 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Dragons Gamers |
| Maintainers | dragonsgamers |

## Links

- npm: https://www.npmjs.com/package/@odg/log
- Repository: https://github.com/ODGodinho/ODGMono
- Homepage: https://github.com/ODGodinho/ODGMono/tree/main/packages/log
- Issues: https://github.com/ODGodinho/ODGMono/issues
- npm.io page: https://npm.io/package/@odg/log

## Dependencies (2)

- [ansis](https://npm.io/package/ansis.md) ^4.3.1
- [@odg/exception](https://npm.io/package/@odg/exception.md) ^1.19.3

## Recent versions

- 1.20.0 (latest) — 2026-08-17
- 1.19.2 — 2026-08-02
- 1.19.1 — 2026-08-02
- 1.19.0 — 2026-07-31
- 1.18.3 — 2026-07-22
- 1.18.2 — 2026-07-17
- 1.18.1 — 2026-07-17
- 1.18.0 — 2026-07-17
- 1.17.1 — 2026-07-10
- 1.17.0 — 2026-07-07
- 1.16.1 — 2026-07-06
- 1.16.0 — 2026-06-25
- 1.15.2 — 2026-06-20
- 1.15.1 — 2026-06-20
- 1.15.0 — 2026-06-19
- … 27 more at https://npm.io/package/@odg/log/versions

## README

<h1 align="center">
    <a href="https://github.com/ODGodinho">
        <img
            src="https://raw.githubusercontent.com/ODGodinho/Stanley-TheTemplate/main/public/images/Stanley.jpg"
            alt="Stanley Imagem" width="500"
        />
    </a>
    <br />
    ODG Log Interface By Dragons Gamers
    <br />
</h1>

<h4 align="center">Log Package interface 🔊</h4>
<h5 align="center">Using Stanley</h5>

<p align="center">

[![codecov](https://codecov.io/gh/ODGodinho/ODGLog/branch/main/graph/badge.svg?token=JCLIEK2OFN)](https://codecov.io/gh/ODGodinho/ODGLog)
[![Stargazers](https://img.shields.io/github/stars/ODGodinho/ODGLog?color=F430A4)](https://github.com/ODGodinho/ODGLog/stargazers)
[![Made by ODGodinho](https://img.shields.io/badge/made%20by-ODGodinho-%2304A361)](https://www.linkedin.com/in/victor-alves-odgodinho/)
[![Forks](https://img.shields.io/github/forks/ODGodinho/ODGLog?color=CD4D34)](https://github.com/ODGodinho/ODGLog/network/members)
![Repository size](https://img.shields.io/github/repo-size/ODGodinho/ODGLog)
[![GitHub last commit](https://img.shields.io/github/last-commit/ODGodinho/ODGLog)](https://github.com/ODGodinho/ODGLog/commits/master)
[![License](https://img.shields.io/badge/license-MIT-brightgreen)](https://opensource.org/licenses/MIT)
[![StyleCI](https://github.styleci.io/repos/567544983/shield?branch=main)](https://github.styleci.io/repos/567544983?branch=main)

</p>

# Table of Contents

- [🎇 Benefits](#-benefits)
- [📗 Libraries](#-libraries)
- [📁 Dependencies](#-dependencies)
- [⏩ Get Started](#-get-started)
  - [🔘 Use Log Interface](#-use-log-interface)
- [📰 Usage](#-usage)
  - [🙈 Exception](#-exception)
  - [🔐 Implementation](#-implementation)
- [🍰 Free Sample](#-free-sample)
  - [🔉 Class Aware Log](#-class-aware-log)
  - [👀 Create Logger Class](#-create-logger-class)
- [💻 Prepare to develop](#-prepare-to-develop)
  - [📍 Start Project](#-start-project)
  - [📨 Build and Run](#-build-and-run)
  - [🧪 Teste Code](#-teste-code)

---

## 🎇 Benefits

- 🚀 Logs Pattern interface
- 🚨 Similar PHP psr-3

## 📗 Libraries

- [Node.js 16](https://nodejs.org/?n=dragonsgamers)
- [Typescript](https://www.typescriptlang.org/?n=dragonsgamers)
- [Eslint](https://eslint.org/?n=dragonsgamers)
- [ODG-Linter-JS](https://github.com/ODGodinho/ODG-Linter-Js?n=dragonsgamers)
- [EditorConfig](https://editorconfig.org/?n=dragonsgamers)
- [ReviewDog](https://github.com/reviewdog/action-eslint)

## 📁 Dependencies

- [Node.js](https://nodejs.org) 16 or later
- [Yarn](https://yarnpkg.com/) Optional/Recommended
- [ODG TsConfig](https://github.com/ODGodinho/tsconfig) Last Version
- [ODG Exception](https://github.com/ODGodinho/ODGException)

## ⏩ Get Started

---

### 🔘 Use Log Interface

Install in your project using this command

```powershell
yarn add @odg/log
```

### 📰 Usage

#### 📰 Exception

InvalidArgumentException dispatch if send invalid arguments

#### 🌎 Implementation

- LoggerAwareInterface Implements this if your class dependencies Logger
- LogLevel it is an enum with the types of logs
- LogLevelType is a list of log types
- LoggerInterface for create a logger class
- AbstractLogger Abstract class to logger implements only log function
- NullLogger Generic logger without action

### 🍰 Free Sample

#### 🔉 Class Aware Log

If you class dependencies LoggerInstance use interface `LoggerAwareInterface`

> if you prefer you can depend on the log class in your constructor

```typescript
import { LoggerAwareInterface, LoggerInterface } from "@odg/log";

export class LoggerAwareExample implements LoggerAwareInterface {

    private logger?: LoggerInterface;

    public setLogger(logger: LoggerInterface): void {
        this.logger = logger;
    }

    public runExampleClass(): void {
        try {
            // Anything code
        } catch (error) {
            this.logger?.debug(error);
        }
    }

}
```

#### 👀 Create Logger Class

```typescript
/**
 * This Example Logger using console.log
 *
 * @author Dragons Gamers <https://github.com/ODGodinho>
 */
export class ConsoleLogger extends AbstractLogger {

    /**
     * Logs with an arbitrary level.
     *
     * @param {LogLevel} level Log level
     * @param {unknown} message Message Log
     * @param {TContext} context Context Message replace
     *
     * @returns {Promise<void>}
     */
    public async log(level: LogLevel, message: unknown, context?: TContext): Promise<void> {
        const log = await this.parser(level, message, context); // Use this for plugins load

        return console.log(`Level: ${log.level} >> ${String(log.message)}`, log.context);
    }

}
```

## 💻 Prepare To Develop

Copy `.env.example` to `.env` and add the values according to your needs.

### 📍 Start Project

First install dependencies with the following command

```bash
bun install
# or
npm install
```

## 📨 Build and Run

To build the project, you can use the following command

> if you change files, you need to run `bun run build` and `bun run start` again

```bash
bun run build && bun run start
# or
bun run dev
```

## 🧪 Teste Code

To Test execute this command

```bash
bun run test
# or
bun run test:watch
```

---
_Source: https://npm.io/package/@odg/log · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
