Giter Site home page Giter Site logo

Comments (5)

jonnyreeves avatar jonnyreeves commented on July 22, 2024

from js-logger.

biergit avatar biergit commented on July 22, 2024

Sorry, I am no JS expert. This is what I did:

formatter: function (messages, context) {
    const first = messages[0]
    if (messages[0]) {
      messages[0] = new Date().toUTCString() + ' ' + first
    }
  }

It also feels surprising that messages here is not an array but an arguments.

from js-logger.

xHyroM avatar xHyroM commented on July 22, 2024

Thanks for raising this issue. Do you have a suggested fix? Jonny

On Thu, 10 Jun 2021, 08:46 biergit, @.***> wrote: formatter: function (messages, context) { // prefix each log message with a timestamp. messages.unshift(new Date().toUTCString()); }, }); will break: logger.log('Hello %s', 'Jonny') — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#106>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABQ36LX7IZ2QM66YJ7GXHTTSBUWRANCNFSM46NRGWGA .

Why?

The console.log function parses these "variables" like %s only in the first argument, and you put what you want in the formatters in the first argument, and that's not good. The solution is that you add it to the null element at the beginning in your own formatting handler.

from js-logger.

jonnyreeves avatar jonnyreeves commented on July 22, 2024

from js-logger.

xHyroM avatar xHyroM commented on July 22, 2024

Pull requests welcome! ♥️

On Sat, 18 Dec 2021, 13:06 Hyro, @.> wrote: Thanks for raising this issue. Do you have a suggested fix? Jonny … <#m_8893153787719601507_> On Thu, 10 Jun 2021, 08:46 biergit, @.> wrote: formatter: function (messages, context) { // prefix each log message with a timestamp. messages.unshift(new Date().toUTCString()); }, }); will break: logger.log('Hello %s', 'Jonny') — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub < #106 <#106>>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABQ36LX7IZ2QM66YJ7GXHTTSBUWRANCNFSM46NRGWGA . Why? The console.log function parses these "variables" like %s only in the first argument, and you put what you want in the formatters in the first argument, and that's not good. The solution is that you add it to the null element at the beginning in your own formatting handler. — Reply to this email directly, view it on GitHub <#106 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABQ36KY2AC2YYBURZUVLR3URSBNXANCNFSM46NRGWGA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you commented.Message ID: @.***>

It will be major change probably

from js-logger.

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.