Coder Social home page Coder Social logo

olehan / kek Goto Github PK

View Code? Open in Web Editor NEW
17.0 17.0 2.0 90 KB

๐ŸŒš Zero allocated, structured, leveled and very pretty Golang logger

License: MIT License

Go 96.48% Makefile 1.18% Shell 2.33%
fast go golang leveled logger pretty-print structured-logger zero-alloc zero-allocation

kek's Introduction

kek's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

kek's Issues

Add structured compose printer

Motivation

Structured Key-Value printer is twice slower than the Template or Base printers, so I have an idea that will fix the problem and get a better logging experience.

Description

Expected function type:

type PrinterComposer interface {
    Interface(key string, value interface{}) PrinterComposer
    String(key string, value string) PrinterComposer
    Int(key string, value int64) PrinterComposer
    Bool(key string, value bool) PrinterComposer
    // And so on...

    // A function that is going to Write to the Writer from a linked buffer.
    Flush() PrinterComposer
}

type PrintSC = func(message string) PrinterComposer

Expected usage:

logger.PrintSC("user info:").
    String("name", "My").
    Int("age", int64(32)).
    Bool("male", true).
    Flush()

The idea is to get type-safe and fast structured logging.

FormatterUtils.StringifyByTemplate can't format "{}{}{}"

Describe the bug
FormatterUtils.StringifyByTemplate function can not format when the template string contains two (or more) value points at a row. Instead of the following format, the output will miss every second value point, so the format "{}{}{}{}" will be formatted as "value{}value{}".

To Reproduce
Steps to reproduce the behavior:

  1. Execute StringifyByTemplate in any of tests with the template string "{}{}{}{}"
  2. Insert values so you could say see the differences between them.

Expected behavior
Values should be written into a buffer as expected by the template string.
For example []interface{}{"v", 1, true, 1.1} should format to "v1true1.1" if the template string is "{}{}{}{}"

Create a proper benchmark tests

Not really sure when I can do it, but I plan to rent a dedicated server and create some gud benchmarks, so you could see the clear performance of the lib.

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.