Giter Club home page Giter Club logo

Comments (5)

ptaoussanis avatar ptaoussanis commented on May 11, 2024

Hi Julius,

I am not sure if it is appropriate to put question here, please close it if it not.

Sure, this is the right place to ask :-)

I make a poor workaround by copying def-loggers and so on into the logging.clj file in my personal project.

Can you explain what you want to do here exactly? Do you want to change something in def-logger or ordered-levels?

If you just want the logging macros (info, infof, error, errorf, etc.) to be available to your namespace, I would usually recommend doing that with something like:

(ns my-app (:require [taoensso.timbre :as timbre
                      :refer (trace debug info warn error fatal spy with-log-level)]))

But maybe I misunderstand you?

from timbre.

weejulius avatar weejulius commented on May 11, 2024

:), I just want the source codes refer to those macros under my namespace (:require [logging :as log]) like t_logging.clj instead of
[taoensso.timbre :as timbre
:refer (trace debug info warn error fatal spy with-log-level)]

from timbre.

ptaoussanis avatar ptaoussanis commented on May 11, 2024

Okay, I think I understand. I think using def-loggers in your own ns is maybe a bad idea. It would be better to use :require and :refer.

If :refer (trace debug info warn error fatal spy with-log-level) is too long, you can write a fn like this:

(defn require-timbre []
  (require '[taoensso.timbre :as timbre :refer (trace debug info warn error fatal spy with-log-level)])

Then you can call (require-timbre) under your ns form. I will think about adding this to Timbre officially.

Another idea: you can require log or logf which lets you choose a logging level yourself, like (log :info "Log this").

Does that help?

from timbre.

ptaoussanis avatar ptaoussanis commented on May 11, 2024

Okay, I have added refer-timbre to v2.4.0.

from timbre.

weejulius avatar weejulius commented on May 11, 2024

It does help, Thanks a lot. Actually what I did is not about to save the time to press the long require statement, I want to abstract the logging interface, so that the code will not be changed a lot after switching the logging implementation.

from timbre.

Related Issues (20)

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.