npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cowlog

v1.7.28

Published

Development time logging for NodeJs

Downloads

446

Readme

QA dsl-toolkit

CI Maintainability Test Coverage FOSSA Statuslerna

Cowlog

Cowlog is the product of the vidaxl.com engineering efforts. Helps you to debug your backend javascript code with less cognitive effort. It is a library that helps you identify your debug message quickly on the console output. Having it's own domain-specific language regarding the logging procedures, it's behaviour can be altered through the use of them. The project supports at the moment only the NodeJs environment.

We want cowlog to be usable in any circumstances without problems therefore we have close 100% code coverage, but at least 90%.

Motivation

  • Server-side applications tend to pollute the console still sometimes you want to use console.log, and not solely use the amazing debug mode --inspect of the NodeJs.

  • CowLog can help you refactor your code faster. Our aim is that the code would run on most node.js environment now we support node >= 7.6.4.

np## Installation

npm install cowlog --save-dev

Usage

require('cowlog)()

This will reigister the global variable l this is a function that you an chain to i's DSL functions so the mostbasic usage is

l('your', 'stuffs')()

Chances are high, "that's the way you like it..."

You will see all information with cowlog, no need to have specially trained eye for development log messages, or particular identifiable strings, before and after you want to look at.

  • session log: Every you call cowlog, the results appear in a separate file.

  • called from: It is the exact place where you placed cowlog, so you can remove it with ease, after you have inspected the variables in the runtime.

The "stack trace" will help you, it sticks with cowlog.

Basic logging (read further there are much more coolness)

The output looks like this:

 ____________________________________________________________________________________________________
/                                                                                                    \
| 0 Beginnig -------                                                                                 |
| "abcz"                                                                                             |
| 0 End -------                                                                                      |
|                                                                                                    |
| 1 Beginnig -------                                                                                 |
| {                                                                                                  |
|   a: "A",                                                                                          |
|   "embeded.level1.level2.c": null,                                                                 |
|   "embeded.level1.level2.c2": "cc",                                                                |
|   "embeded.level1.level2.array.0.a": "a",                                                          |
|   "embeded.level1.level2.array.0.b": "b",                                                          |
|   "embeded.level1.level2.array.1": 1,                                                              |
|   "embeded.level1.level2.array.2": 1,                                                              |
|   "embeded.level1.level2.array.3": 3,                                                              |
|   "embeded.level1.level2.array.4": 7,                                                              |
|   "embeded.level1.level2.testObject2.c": 1,                                                        |
|   "embeded.level1.level2.testObject2.fn": function (a, b) {                                        |
|   return a + b                                                                                     |
| },                                                                                                 |
|   "embeded.level1.b": "1.5"                                                                        |
| }                                                                                                  |
| 1 End -------                                                                                      |
|                                                                                                    |
| 2 Beginnig -------                                                                                 |
| "This is a very long text. Indeed, it has to be long enough to be able to                          |
| present how awesomely it breaks the strings so that you will have a conven                         |
| ient reading experience through your logs."                                                        |
| 2 End -------                                                                                      |
|                                                                                                    |
| _-_-_-_-_-_-_-_-_-_-_-_                                                                            |
|                                                                                                    |
| called from:/home/it/dev/misc/dsl-toolkit/packages/dsl-toolkit/node_modules/bottlejs/dist/bottle.js:205:89   |
| stack trace:/tmp/dsl-toolkit/hashes/1a/aca79320ae42540da2a83d1d1c7b6d_stack-trace.log                   |
| session log:/tmp/dsl-toolkit/hashes/b6/cda5f0931f0f85054b0f59b0d5e749_session.log                       |
\ logged at:2018-06-20T20:54:17.782Z                                                                 /
 ----------------------------------------------------------------------------------------------------
    \
     \
                                   .::!!!!!!!:.
  .!!!!!:.                        .:!!!!!!!!!!!!
  ~~~~!!!!!!.                 .:!!!!!!!!!UWWW$$$
      :$$NWX!!:           .:!!!!!!XUWW$$$$$$$$$P
      $$$$$##WX!:      .<!!!!UW$$$$"  $$$$$$$$#
      $$$$$  $$$UX   :!!UW$$$$$$$$$   4$$$$$*
      ^$$$B  $$$$\     $$$$$$$$$$$$   d$$R"
        "*$bd$$$$      '*$$$$$$$$$$$o+#"
             """"          """""""

If you don't have a global variable registered to l (cowlog.log) than cowlog will register them, so you can reach it from anywhere. I know it is against all good practice, but don't forget to remove it after you finished your development session.

Cowlog has its own DSL

l('your stuffs').die()

Joe is dead here.

l('your stuffs').once()

Just once please! lodash#once

l('your stuffs').throttle(2000)()

Just like in the lodash#throttle documentation

l('your stuffs').debounce(2000)()

Just like in the lodashe#debounce documentation

l('your stuffs').lasts()

Collects these logs and displays if the application exits.

l('your stuffs').last()

Pretty much like the previous, it makes sure only this last call will be shown at the end.

l('your stuffs').mute()

Mutes the output. This can be convinient in some cases.

l({a:'1,b:1}).keys()

Will print only the keys for object type aruments. here ["a", "b"]

var test = l('a', 1).return()

Here the test variable's value will e 1 so it returns the last variale's value.

l('a', 1).lol()

The rainbowmabic of lolcat is activated

DSL chaining

For instance typing

l('your stuffs').once.throttle(2000)()

is legit. Once it prints the output other than this it throttles it as well.

const test = l('a', 1).return.mute()

Will do the same taht the upper one, but no output, can be useful for debugging.

Remarks

In the future, we will add a production feature to the software, but that needs some pressure from the community, and meanwhile, we have more meaningful things to implement.

This document is part of the Cowlog project.