All Projects → Zaelot-Inc → use-reducer-logger

Zaelot-Inc / use-reducer-logger

Licence: MIT license
A very basic logger for the useReducer function in the React Hooks API.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to use-reducer-logger

clue
a extremely high performance log library for android. 高性能的Android日志库
Stars: ✭ 27 (-69.66%)
Mutual labels:  logger, logging-library
BLogger
An easy to use modern C++14/17 async cross-platform logger which supports custom formatting/patterns, colored output, Unicode, file logging, log rotation & more!
Stars: ✭ 23 (-74.16%)
Mutual labels:  logger, logging-library
noodlog
🍜 Parametrized JSON logging library in Golang which lets you obfuscate sensitive data and marshal any kind of content.
Stars: ✭ 42 (-52.81%)
Mutual labels:  logger, logging-library
JJSwiftLog
Swift log library for all platform
Stars: ✭ 51 (-42.7%)
Mutual labels:  logger, logging-library
guzzle-log-middleware
A Guzzle middleware to log request and responses automatically
Stars: ✭ 61 (-31.46%)
Mutual labels:  logger, logger-middleware
RxLogs
An Android & Kotlin Reactive Advanced Logging Framework.
Stars: ✭ 12 (-86.52%)
Mutual labels:  logger, logging-library
l
Cross-platform html/io [L]ogger with simple API.
Stars: ✭ 26 (-70.79%)
Mutual labels:  logger, logging-library
Izumi
Productivity-oriented collection of lightweight fancy stuff for Scala toolchain
Stars: ✭ 423 (+375.28%)
Mutual labels:  logger, logging-library
Simple-Log
dnkpp.github.io/Simple-Log/
Stars: ✭ 13 (-85.39%)
Mutual labels:  logger, logging-library
beautiful logger
Yet another logger API in Java with beautiful features
Stars: ✭ 60 (-32.58%)
Mutual labels:  logger, logging-library
LogDNA-Android-Client
Android client for LogDNA
Stars: ✭ 22 (-75.28%)
Mutual labels:  logger, logging-library
Loggaby
📝 A simple, lightweight and customizable logger.
Stars: ✭ 20 (-77.53%)
Mutual labels:  logger, logging-library
Timber Elixir
🌲 Great Elixir logging made easy
Stars: ✭ 226 (+153.93%)
Mutual labels:  logger, logging-library
Flogs
An Advanced Logging Framework develop in flutter that provides quick & simple logging solution.
Stars: ✭ 158 (+77.53%)
Mutual labels:  logger, logging-library
Ring Log
Ring-Log是一个高效简洁的C++异步日志, 其特点是效率高(每秒支持至少125万+日志写入)、易拓展,尤其适用于频繁写日志的场景
Stars: ✭ 201 (+125.84%)
Mutual labels:  logger, logging-library
logger
Gin middleware/handler to logger url path using rs/zerolog
Stars: ✭ 119 (+33.71%)
Mutual labels:  logger, logger-middleware
Cocoadebug
iOS Debugging Tool 🚀
Stars: ✭ 3,769 (+4134.83%)
Mutual labels:  logger, logging-library
Quill
Asynchronous Low Latency C++ Logging Library
Stars: ✭ 422 (+374.16%)
Mutual labels:  logger, logging-library
sqlite micro logger arduino
Fast and Lean Sqlite database logger for Microcontrollers
Stars: ✭ 128 (+43.82%)
Mutual labels:  logger, logging-library
ratlog.js
🐀 Ratlog JavaScript library - Application Logging for Rats, Humans and Machines
Stars: ✭ 24 (-73.03%)
Mutual labels:  logger, logging-library

use-reducer-logger

A very very basic logger for the useReducer function in the React Hooks API. Inspired by redux-logger.

screenshot of logger

Usage

  1. Install with npm install use-reducer-logger --save-dev or yarn add use-reducer-logger -D
  2. Import logger with
import logger from 'use-reducer-logger';
  1. Wrap your reducer with logger before passing it to useReducer
const [state, dispatch] = useReducer(logger(reducer), initialState);

See Example

In a Dev Environment

You should only use this in a dev environment. So you could do something like this to apply the logger based on the env.

function reducer(state, action) {
  switch (action.type) {
    case 'increment':
      return {count: state.count + 1};
    case 'decrement':
      return {count: state.count - 1};
    default:
      throw new Error();
  }
}

const [state, dispatch] = useReducer(
  process.env.NODE_ENV === 'development' ? logger(reducer) : reducer,
  initialState
);

License

MIT see LICENSE.

Contributing

Contributions are welcome.

Sponsor

This repo is now sponsored/maintained by Zaelot Inc.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].