All Projects → WoLfulus → Zoya

WoLfulus / Zoya

Licence: mit
Truly highly composable logging utility

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Zoya

Saw
Fast, multi-purpose tool for AWS CloudWatch Logs
Stars: ✭ 1,071 (+823.28%)
Mutual labels:  cli, json, logs, color
Jl
jl — JSON Logs, a development tool for working with structured JSON logging.
Stars: ✭ 194 (+67.24%)
Mutual labels:  cli, json, logging, logs
Rz Go
Ripzap - Fast and 0 allocs leveled JSON logger for Go ⚡️. Dependency free.
Stars: ✭ 256 (+120.69%)
Mutual labels:  json, logging, logs
Jsome
✨ Make your JSON look AWESOME
Stars: ✭ 179 (+54.31%)
Mutual labels:  json, color, colors
Autoserver
Create a full-featured REST/GraphQL API from a configuration file
Stars: ✭ 188 (+62.07%)
Mutual labels:  cli, json, server
Ponzu
Headless CMS with automatic JSON API. Featuring auto-HTTPS from Let's Encrypt, HTTP/2 Server Push, and flexible server framework written in Go.
Stars: ✭ 5,373 (+4531.9%)
Mutual labels:  cli, json, server
Cabin
🌲 Cabin is the best JavaScript and Node.js logging service and logging npm package
Stars: ✭ 622 (+436.21%)
Mutual labels:  express, logging, logs
Fliplog
fluent logging with verbose insight, colors, tables, emoji, filtering, spinners, progress bars, timestamps, capturing, stack traces, tracking, presets, & more...
Stars: ✭ 41 (-64.66%)
Mutual labels:  cli, logging, color
Console Logging
Better, prettier commandline logging for Python--with colors! 👻
Stars: ✭ 111 (-4.31%)
Mutual labels:  logging, color, colors
Systemdlogger
Exports systemd logs to an external service, eg cloudwatch, elasticsearch
Stars: ✭ 91 (-21.55%)
Mutual labels:  logging, logs
Jutil
Command-line utilities for manipulating JSON
Stars: ✭ 91 (-21.55%)
Mutual labels:  cli, json
Nord Hyper
An arctic, north-bluish clean and elegant Hyper theme plugin.
Stars: ✭ 96 (-17.24%)
Mutual labels:  color, colors
Xsrv
[mirror] Install and manage self-hosted services/applications, on your own server(s) - ansible collection and utilities
Stars: ✭ 89 (-23.28%)
Mutual labels:  server, logging
Catj
Displays JSON files in a flat format.
Stars: ✭ 1,301 (+1021.55%)
Mutual labels:  cli, json
Swagger Merger
🔗 Merge multiple swagger files into a swagger file, support JSON/YAML.
Stars: ✭ 94 (-18.97%)
Mutual labels:  cli, json
Serve
serve starts a simple temporary static file server in your current directory and prints your IP address to share with colleagues
Stars: ✭ 90 (-22.41%)
Mutual labels:  cli, server
Swagger Express Ts
Generate and serve swagger.json
Stars: ✭ 102 (-12.07%)
Mutual labels:  json, express
Nord Termite
An arctic, north-bluish clean and elegant Termite color theme.
Stars: ✭ 104 (-10.34%)
Mutual labels:  cli, colors
React Native Logs
Performance-aware simple logger for React-Native with namespaces, custom levels and custom transports (colored console, file writing, etc.)
Stars: ✭ 84 (-27.59%)
Mutual labels:  logging, logs
Values.js
🍇 Get the tints and shades of a color
Stars: ✭ 97 (-16.38%)
Mutual labels:  color, colors

Truly highly composable logging utility written in TypeScript

Header

Build Status Coverage Status NPM Downloads

Description

Zoya is a highly composable logging library used for both client and server applications.

Visit the contributing guidelines to learn more on how to translate this document into more languages.

Come over to Discord or Twitter to share your thoughts on the project.

This is a complete rewrite of Signale, written by Klaus Siani, and it's NOT intended to be a drop-in replacement.

Highlights

  • Easy to setup and compose as you like
  • Easy to control how things look
  • Easy to extend
  • Clean and beautiful output, configure as you wish
  • Supports JSON outputs
  • Extensible fields with several fields built in
    • Labels, Badge (emoji), Scopes, Level, Separators, Message, Context
  • Multiple configurable writable streams with stream level filtering
  • Simple and minimal syntax
  • Written in TypeScript

Contents

Install

Yarn

yarn add zoya

NPM

npm install zoya

Usage

Overview

Zoya tries to make it simple to configure and compose your loggers, so you can easily control how the output will look like. This is possible due to the field chain passed to the logger in its creation.

To use the default exported logger you just import and use it.

import zoya from "zoya";

zoya.info("Hello world!");

To see all the available examples check the examples folder

Default logger

The default export of zoya is an instance of a logger (called the default logger). This instance is preconfigured to write to process.stdout with all logging levels enabled (so you can use debug and trace for example).

These are all the available loggers in the default logger.

import log from "zoya";

log.trace("trace messages...");
log.debug("debug messages...");
log.info("info messages...");
log.success("success messages...");
log.warn("warn messages...");
log.error("error messages...");
log.failed("failed messages...");
log.fatal("fatal messages...");

The fields configured in the default logger are:

[scope][separator][badge][label][level][message][context]

More on fields later.

On new instances

To create a new Zoya instance, use zoya function passing the proper configs you want. Note that all first level values uses the default values from the default logger, so you don't need to specify all of them if you want for example to just enable json logging.

Note that if you pass value to an object, for example types, all the child values are overwritten.

import { zoya, Level } from "zoya";

// Just enables json
const jsonLogger = zoya({ json: true });

// Only outputs to stderr
const stderrLogger = zoya({
  streams: [
    {
      level: Level.error,
      stream: process.stderr
    }
  ]
});

Enhancing loggers

Zoya allows you to enhance existing loggers in order to add new logging types. Enhancing logger will create a new logger instance and will keep the old logger intact.

import { bold, underline } from "chalk";
import log, { Level } from "zoya";

const xmasLogger = log.enhance({
  santa: {
    level: Level.info,
    options: {
      badge: "santa"
      label: {
        name: "santa",
        transformer: label => bold(underline(label))
      }
      scope: ["xmas"]
    }
  }
});

xmasLogger.santa("Hohoho!");

The above logger will output something like this

[xmas] » 🎅  santa Hohoho!

Configuration

Fields

Zoya has the concept of fields. All log messages are built by a chain of fields that are configured when creating a new logger through zoya function. Fields are context sensitive, this means that you can output different things in a field depending on what the message contains.

Configuring fields

For example, if you just want to show the message and its context, you can configure zoya like this:

import { context, message, zoya } from "zoya";

const custom = zoya({
  fields: [message(), context()]
});

custom.info("Hello world", { ip: "127.0.0.1" });

This will output something like this in text mode:

Hello world {
  "ip": "127.0.0.1"
}

And this in JSON mode:

{"message":"Hello world","context":{"ip":"127.0.0.1"}}

Zoya fields

Zoya contains several fields that can be imported from zoya package.

Badge

Used to display emojis in the log text

Context

Displays the message context

Label

Displays a customizable label for each message type

Level

Adds the message level only on json outputs

Message

Displays the message itself

Scope

Display the message scope(s)

Separator

Displays a customizable separator only in text mode


Custom fields

You can easily write custom fields.

TODO: write example custom fields. For now you can take the bundled ones as an example from here.

Development

For more info on how to contribute to the project, please read the contributing guidelines.

  • Fork the repository and clone it to your machine
  • Navigate to your local fork: cd zoya
  • Install the project dependencies: npm install or yarn install
  • Lint code for errors: npm test or yarn test

Related

  • Signale - Highly configurable logging utility

Team

FAQ

Why "Zoya"?

Because I like Trine :)

Acknowledgements

Thanks

Huge thanks to brain (brain#4221), Micah (Micha#6878) and undefined.toString() (elderapo#8225) for the helpful insights over TypeScript discord channel

License

MIT

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