Giter Site home page Giter Site logo

shobiz's Introduction

shobiz

nimble install shobiz

Github Actions

API reference

Simple structured console messages for Nim applications.

About

shobiz is a simple library for outputting structured console messages in Nim applications. Configuration is done with global variables (there is no need to pass around a logger object), and the API consists of only a few methods.

import shobiz
import json

SHO_PRETTY = true # These should be set with the
SHO_DEBUG = true  # command line arg parser of your choice.

"Hello, Message!".shoMsg()
"Hello, Debug!".shoDbg(%*{"interesting": 1234}) # This is only shown if SHO_DEBUG is true.

try:
  raise newException(KeyError, "Hello, Error!")
except Exception as err:
  err.shoExc()
{
    "timestamp": "2024-05-27T21:57:43.862-07:00",
    "level": "Message",
    "message": "Hello, World!"
}
{
    "timestamp": "2024-05-27T21:57:43.862-07:00",
    "level": "Debug",
    "message": "Hello, Debug!",
    "data": {
        "interesting": 1234
    }
}
{
    "timestamp": "2024-05-27T21:57:43.862-07:00",
    "level": "Error",
    "type": "KeyError",
    "message": "Hello, Error!"
}

Pretty Flag

The SHO_PRETTY flag is used to determine if the output should be pretty-printed or not. If set to true, the output will be formatted with newlines and indentation, and is intended for human consumption. If set to false(the default), the output will be a single line of minified JSON, which is great for piping to other programs (like jq) or writing to a log file (like | tee -a log.jsonl).

Debug Flag

The SHO_DEBUG flag is used to determine if debug messages should be shown or not. If set to true, debug messages will be shown. If set to false(the default), debug messages will be suppressed.

shobiz's People

Contributors

logavanc avatar

Stargazers

 avatar Constantine Molchanov avatar

Watchers

 avatar

shobiz's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.