# @colorfy-software/logify

> Simple wrapper for sending logs

Latest version **1.1.0** (published 2023-04-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @colorfy-software/logify
pnpm add @colorfy-software/logify
yarn add @colorfy-software/logify
bun add @colorfy-software/logify
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2023-04-24 |
| First published | 2022-03-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 27.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | colorfy-software |
| Maintainers | colorfy-software |

## Links

- npm: https://www.npmjs.com/package/@colorfy-software/logify
- Repository: https://github.com/colorfy-software/logify
- Homepage: https://github.com/colorfy-software/logify#readme
- Issues: https://github.com/colorfy-software/logify/issues
- npm.io page: https://npm.io/package/@colorfy-software/logify

## Recent versions

- 1.1.0 (latest) — 2023-04-24
- 1.0.7 — 2022-03-07
- 1.0.6 — 2022-03-07
- 1.0.5 — 2022-03-07
- 1.0.4 — 2022-03-07
- 1.0.3 — 2022-03-07
- 1.0.2 — 2022-03-02
- 1.0.1 — 2022-03-01
- 1.0.0 — 2022-03-01

## README

# @colorfy-software/logify

> This is a simple wrapper for sending logs

[![NPM](https://img.shields.io/npm/v/@colorfy-software/logify.svg)](https://www.npmjs.com/package/@colorfy-software/logify) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

# Installation

    $ yarn add @colorfy-software/logify

# Usage

## Creating a logger

```typescript
// core/logging-core.ts

import { MMKV } from 'react-native-mmkv'
import Logify from '@colorfy-software/logify'

interface CustomErrorType {
  message: string
  code: number
}

export const logsStorage = new MMKV({ id: 'logs' })

const logger = new Logify<CustomErrorType>({
  endpoint: 'http://some-endpoint.com',
  // Can be an object or a function, get's added to each log
  defaultParams: {
    userId: getUserId(),
    source: 'app'
  },
  // Error here has CustomErrorType | DefaultErrorType(from lib), can parse error to be something useful
  parseError: (error) => {
    // do stuff with error
    return parsedErrorMessage
  },
  // Condition if logs should be sent to server. Can be a function. Defaults to true
  shouldSendLogsIf: !__DEV__,
  // Condition if logs should be shown in console. Can be a function. Defaults to true
  shouldLogToConsoleIf: true,
  // Possibility to edit colors that are printed to console
  printColors: {
    debug: '#FFFFFF',
    info: '#ADD8E6',
    warn: '#FFA500',
    error: '#FF0000',
    fatal: '#FF0000',
  },
  // Storage configuration
  storage: {
    key: 'logs',
    getItem: (key: string): string | null => logsStorage.getString(key) ?? null,
    setItem: (key: string, value: string) => logsStorage.set(key, value),
  }
})

export default logger
```

## Using the logger

```typescript
// any-file.ts

import core from '../core'

core.logger.error('userRegistrationError', gigyaError)
```

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