Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
src
tests
.babelrc
.coveralls.yml
.eslintrc
.gitignore
CONTRIBUTING.md
README.md
cowlog-1.5.19.tgz
package.json

README.md

QA monorepo

JavaScript Style Guide CircleCI Test Coverage Maintainability Greenkeeper badge Known Vulnerabilities FOSSA Status

HitCount lerna

Cowlog is not for production code, as it might cause performance issues. However, the tool provides detailed information about where from you called it from, so you can locate and remove after debugging. It gives you the stack trace. All the log messages per process to a separate file and many more things.

Chat

Gitter

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/cowlog/packages/cowlog/node_modules/bottlejs/dist/bottle.js:205:89   |
| stack trace:/tmp/cowlog/hashes/1a/aca79320ae42540da2a83d1d1c7b6d_stack-trace.log                   |
| session log:/tmp/cowlog/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.

You can’t perform that action at this time.