Skip to content

πŸ‹ LemonLog - Simplify Your Node.js Logging πŸš€

Notifications You must be signed in to change notification settings

clasen/LemonLog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ‹ LemonLog - Simplify Your Node.js Logging

Welcome to LemonLog! The zesty, easy-to-use logging solution for your Node.js applications. Whether you're debugging your latest feature or keeping an eye on production issues, LemonLog is here to brighten your day (and your console) with colorful, structured logs. 🌈

🌟 Features

  • Simple Setup: Get up and running in no time. LemonLog is all about simplicity.
  • Colorful Logs: Make your logs more readable with automatic color coding. Info, debug, warn, and error logs each have their own vibrant hue.
  • Console Bindings: LemonLog ties neatly into the console, ensuring that your logs are both beautiful and functional.
  • Custom Callbacks: Handle errors and debug information your way with custom callbacks.
  • Flexible: Whether you're writing a quick script or a complex application, LemonLog adapts to your needs.
  • Full Depth Inspect: Allows you to inspect deeply nested objects with ease. You can quickly and clearly see the structure of your data.

πŸš€ Getting Started

  1. Install LemonLog

    npm install lemonlog
  2. Usage

    First, require and create a new instance of LemonLog in your project:

    const log = require('lemonlog')('MyApp');

    or

    import LemonLog from 'lemonlog';
    const log = new LemonLog('MyApp');

    Then, log away:

    log.info('This is an info message!');
    log.debug('Here’s something you might find interesting...', { emoji: "🎁" });
    log.inspect('Inspecting a deeply nested object', { a: { b: { c: { d: 1 } } } });
    log.warn('Warning! Warning! 🚨');
    log.error('Oops! Something went wrong. πŸ”₯');

    Use DEBUG to filter logs:

    $ DEBUG=* node demo/demo.js
    myApp:info ------ This is an info message { a: 1 } +0ms
    myApp:debug ----- This is a debug message +0ms
    myApp:inspect --- [
    myApp:inspect ---   'This is a full json depth inspect message',
    myApp:inspect ---   {
    myApp:inspect ---     a: { b: { c: { d: 1 } } }
    myApp:inspect ---   }
    myApp:inspect --- ] +0ms
    myApp:warn ------ This is a warning +0ms
    myApp:error ----- This is an error +0ms
    myApp:debug ----- [ 'Custom success message' ]
    myApp:debug ----- { return: 'ok' } +0ms
    myApp:error ----- { return: 'error' }
    myApp:error ----- [ 'Custom error message' ]
    myApp:error ----- null +0ms
    myApp:debug ----- Success: { return: 'ok' } +1ms
    myApp:error ----- { return: 'error' }
    myApp:error ----- null +1ms
    
    $ DEBUG=myApp:error* node demo/demo.js
    myApp:error ----- This is an error +0ms
    myApp:error ----- { return: 'error' }
    myApp:error ----- [ 'Custom error message' ]
    myApp:error ----- null +0ms
    myApp:error ----- { return: 'error' }
    myApp:error ----- null +1ms
  3. Customize Your Callbacks

    Handle logs with your own custom logic:

    async function someAsyncFunction(fail, cbk) {
    
       if (fail) {
          cbk({ return: "error" }, null);
       } else {
          cbk(null, { return: "ok" });
       }
    }
    
    // Custom callback example
    someAsyncFunction(false, log.callback("Custom success message"));
    
    someAsyncFunction(true, log.callback("Custom error message"));
    
    
    // Exec example
    someAsyncFunction(false, log.exec(result => {
       log.debug('Success:', result);
    }));
    
    someAsyncFunction(true, log.exec(result => {
       log.debug('Error:', result);
    }));

πŸ‹ Why LemonLog?

We believe that logging shouldn't just be about capturing information. It should be a delightful part of your development process. With LemonLog, we aim to bring a little joy and color to your console, making it easier and more fun to sift through your logs.

🀝 Contributing

Got ideas on how to make LemonLog even better? We'd love to hear from you! Check out our contribution guidelines to get started.

Keep It Zesty!

Thank you for choosing LemonLog for your logging needs. We hope it adds a splash of color to your projects and makes logging something to look forward to.

Happy coding!

πŸ“„ License

The MIT License (MIT)

Copyright (c) Martin Clasen

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

πŸ‹ LemonLog - Simplify Your Node.js Logging πŸš€

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published