All Projects → 0x80 → Yurnalist

0x80 / Yurnalist

Licence: other
An elegant console reporter, borrowed from Yarn

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Yurnalist

Trail
Trail is a simple logging system for Java and Android. Create logs using the same API and the library will detect automatically in which platform the code is running.
Stars: ✭ 13 (-85.23%)
Mutual labels:  logging, logging-library
Log4cplus
log4cplus is a simple to use C++ logging API providing thread-safe, flexible, and arbitrarily granular control over log management and configuration. It is modelled after the Java log4j API.
Stars: ✭ 1,054 (+1097.73%)
Mutual labels:  logging, logging-library
Eliot
Eliot: the logging system that tells you *why* it happened
Stars: ✭ 874 (+893.18%)
Mutual labels:  logging, logging-library
Mex Vocabulary
MEX Vocabulary: a lightweight machine learning interchange format
Stars: ✭ 19 (-78.41%)
Mutual labels:  logging, logging-library
Node Draftlog
📜 Create updatable log lines into the terminal, and give life to your logs!
Stars: ✭ 1,117 (+1169.32%)
Mutual labels:  console, logging
Yii2 Telegram Log
Telegram log target for Yii 2
Stars: ✭ 24 (-72.73%)
Mutual labels:  logging, logging-library
Fliplog
fluent logging with verbose insight, colors, tables, emoji, filtering, spinners, progress bars, timestamps, capturing, stack traces, tracking, presets, & more...
Stars: ✭ 41 (-53.41%)
Mutual labels:  logging, spinner
Screenlog.js
Bring console.log on the screen
Stars: ✭ 591 (+571.59%)
Mutual labels:  logging, logging-library
Hslogger
Logging framework for Haskell
Stars: ✭ 60 (-31.82%)
Mutual labels:  logging, logging-library
Slog
Structured, contextual, extensible, composable logging for Rust
Stars: ✭ 1,068 (+1113.64%)
Mutual labels:  logging, logging-library
Logging Helpers
Basic template helpers for printing messages out to the console. Useful for debugging context in templates. Should work with any template engine.
Stars: ✭ 5 (-94.32%)
Mutual labels:  console, logging
Diary
📑 Zero-dependency, fast logging library for both Node and Browser.
Stars: ✭ 79 (-10.23%)
Mutual labels:  logging, logging-library
Electron Log
Just a simple logging module for your Electron application
Stars: ✭ 765 (+769.32%)
Mutual labels:  console, logging
Yii2 Slack Log
Pretty Slack log target for Yii 2
Stars: ✭ 24 (-72.73%)
Mutual labels:  logging, logging-library
Python Progressbar
Progressbar 2 - A progress bar for Python 2 and Python 3 - "pip install progressbar2"
Stars: ✭ 682 (+675%)
Mutual labels:  console, progress-bar
Loglevelnext
A modern logging library for Node.js that provides log level mapping to the console
Stars: ✭ 33 (-62.5%)
Mutual labels:  console, logging
Fern
Simple, efficient logging for Rust
Stars: ✭ 524 (+495.45%)
Mutual labels:  logging, logging-library
Nlog
NLog - Advanced and Structured Logging for Various .NET Platforms
Stars: ✭ 5,296 (+5918.18%)
Mutual labels:  logging, logging-library
Android Spinkit
Android loading animations
Stars: ✭ 8,096 (+9100%)
Mutual labels:  progress-bar, spinner
Evergreen
Most natural Swift logging
Stars: ✭ 75 (-14.77%)
Mutual labels:  logging, logging-library

Yurnalist

An elegant console reporter, borrowed from Yarn.

Introduction

Pretty console output makes developers happy and Yarn is doing a nice job. Yurnalist takes the internal console reporter code from Yarn and makes it available for use in other Node.js applications.

The current version is based on code from Yarn v1.13.0.

Yurnalist can be used to report many different things besides simple messages.

Features

  • log, info, warn, succes, error & command messages
  • progress bars
  • activity spinners
  • process steps
  • object inspection
  • lists
  • emojis
  • trees
  • tables
  • user question
  • user select
  • program header & footer

Install

yarn add yurnalist

Or if your prefer NPM

npm install yurnalist

How to use

Here is an example showing a combination of different reporter API functions.

import report from 'yurnalist'

/* A function to fake some async task */
function waitNumberOfSecs(secs) {
  return new Promise((resolve) => setTimeout(resolve, secs * 1000));
}

async function fetchSomething() {
  report.info('Please wait while I fetch something for you.');
  report.warn('It might take a little while though.');

  const spinner = report.activity();
  spinner.tick('I am on it!');

  try {
    await waitNumberOfSecs(1);
    spinner.tick('Still busy...');
    await waitNumberOfSecs(1);
    spinner.tick('Almost there...');
    await waitNumberOfSecs(1);
    report.success('Done!');
  } catch (err) {
    report.error(err);
  }

  spinner.end();
}

fetchSomething();

Requirements

Node >= 4

Examples

Examples showing different API functions are found in /examples. You can run them directly with node >= 7.6 (because of async/await syntax). For older versions you could use the --harmony flag, or otherwise Babel.

To run the activity example:

node examples/activity.js

Configuration

A normal import gives you a reporter instance configured with defaults for easy use. If you want something else you can call createReporter(options) to give you an instance with different options.

Options

These are the options of the reporter as defined by Flow:

type ReporterOptions = {
  verbose?: boolean,
  stdout?: Stdout,
  stderr?: Stdout,
  stdin?: Stdin,
  emoji?: boolean,
  noProgress?: boolean,
  silent?: boolean,
  nonInteractive?: boolean,
  peekMemoryCounter?: boolean
};

The defaults used are:

const defaults = {
  verbose: false,
  stdout: process.stdout,
  stderr: process.stderr,
  stdin: process.stdin,
  emoji: true,
  noProgress: false,
  silent: false,
  nonInteractive: false,
  peekMemoryCounter: false
}

The peekMemoryCounter is disabled by default. If you enable it, you'll have to call reporter.close() to stop its running timer. Otherwise your program will not exit. The memory counter can be used to display in the footer data.

Silent Mode and CI

Silent mode can be set via the options passed to createReporter. It disables output for various functions like info, list, activity and progress. The output from warning and error messages is not silenced.

Silent mode can also be enabled with the YURNALIST_SILENT environment variable.

In CI environments the output from activity and progress is disabled.

API

The API still needs some documentation, but most methods are straightforward. In the meantime you can also look at the examples and possibly even the tests.

The following functions are available:

table

step

inspect( thing: mixed )

Pretty-prints the thing.

list(title: string, items: Array, hints?: Object)

Generates a list of the provided items. Turns into a definition list if hints are provided.

Example of a simple list:

report.list('My grocery list', ['bananas', 'tulips', 'eggs', 'bamischijf']);

Outputs:

list My grocery list
   - bananas
   - tulips
   - eggs
   - bamischijf

Example with hints:

const items = ['bananas', 'tulips', 'eggs', 'bamischijf'];

const hints = {
  bananas: 'for baking',
  tulips: 'because it makes you happy',
  eggs: 'not the cheap ones though',
  bamischijf: 'if they have it',
};

report.list('My grocery list', items, hints);

Outputs:

list My grocery list
    - bananas
      for baking
   - tulips
      because it makes you happy
   - eggs
      not the cheap ones though
   - bamischijf
      if they have it

header

footer

log

success

error

info

command

warn

question

tree

activitySet

activity

select

progress

close

createReporter

Language

Yarn uses a language file for certain messages. For example if you try to skip a required question, or when you pick an invalid item from a select. This language file is not yet exposed in the Yurnalist API. The only supported language is English, as it is in Yarn at the moment.

I plan to make this configurable so that you can define your own messages in your own language .

Emojis

You can use Emojis in your output. Yurnalist should disable them if they are not allowed in the application environment.

Check:

Credits

Of course ❤️ and credits to all the contributers of Yarn. The ease with which I was able to extract this module from their codebase is proving some awesome engineering skills.

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].