Giter VIP home page Giter VIP logo

chainsaw's Introduction

Chainsaw

A versatile tool for logging in manageable pieces.

Chainsaw is a Clojure library for logging datastructures with taoensso/timbre. It also comes with an Elastiscsearch appender to improve the usability of your data driven logging.

Harvester cutter
Figure 1. Instrumented chainsaw making logs useful (Source)

Inspiration

This library was inspired by the Juxt blogpost Logging: change your mind from 2016. It outlines the reasons for data driven logging, and how one could go about adopting it. Chainsaw was conceived as a implementation for this concept.

Examples

Add the library
[com.alliander.chainsaw/core "0.1.0"]
Require libraries
(require '[com.alliander.chainsaw.core :as logd]
         '[taoensso.timbre :as log])
Simple data-driven logging
(logd/errord ::http-request.failed {:request request :response response})
Incrementally appending logging context
(let [user-id (:user-id request)]

  ;; log the user-id from now on, conventional timbre style
  (log/with-context {:user-id user-id}

    (logd/infod ::service.called)

    (if-let [service-level (service-level user-id)]

      ;; add the service level to the logging context
      (logd/with-merged-context {:service-level service-level}
        (logd/info ::service-level.found)
        (service service-level))

      ;; per-logging statement context
      (do (logd/error ::service-level.not-found {:request request})
          (reject))))))
Dealing with exceptions
;; exceptions should be passed as the first argument
(logd/error e ::exception)

License

Copyright 2017 Alliander NV.

Licensed under the Apache Public License 2.0.

chainsaw's People

Contributors

nicorikken avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

aroemers

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.