sospedra / logatim Goto Github PK
View Code? Open in Web Editor NEWLogatim is an isomorphic logger which implements log levels and ANSI styles.
Home Page: http://sospedra.github.io/logatim/
License: ISC License
Logatim is an isomorphic logger which implements log levels and ANSI styles.
Home Page: http://sospedra.github.io/logatim/
License: ISC License
In the browser console, for the page logatim, if I do ...
logatim.info("String log");
... then I get ...
String log
If I do ...
console.log("String log");
... then I also get ...
String log
However, if I do ...
logatim.info(this);
... I only get ...
[object Window]
... whereas, if I do ...
console.log(this);
... then I will get ...
> Window {external: Object, chrome: Object, document: document, GoogleAnalyticsObject: "ga", React: Object…}
This allows me to browse the object directly, drilling down to check if everything is correct.
It would be great if you could retain that capability.
Stream anywhere.
This feature needs a hard rethinking on the config setting up.
Hi. I have a nodeJs universal application bundled with webpack. I tried importing/requiring your library and using it but I see nothing on the console. Furthermore, if I try this: console.log(logatim);
I get undefined
on the console.
.raw()
It returns the current message as a string including the ANSI characters or HTML tags.
Useful for testing and the end-user may is interesting in not print the styles for some reason.
Allow a middle step before output the message so the users can add their own formats.
Instead of:
logatim.info('Valar morghulis')
Do, for example:
logatim.info(() => `[${new Date}] Valar morghulis`)
logatim.bgRed('Error').info(`: ${message}`);
I basically want the part after the colon to not have any styles at all, revert back to default.
Is there a method to reset styles? I couldn't find any real API docs, just a pretty page with not that much of any useful info in it.
The idea behind this library is great, I would really love to use it, I'm just trying to understand how.
Thank you!
So we fit into the micro libs definition
Remember to add this stunning feature to the README.md as a feature. Something like:
Don't worry for globals. You can require logatim anywhere and it will remember what log level you're using.
I was printing an error object when I've noticed that all the information is not printed with logatim
The error printed by Logatim logatim.red.error(error)
:
SequelizeUniqueConstraintError: Validation error
The error printed by console.log( )
{ [SequelizeUniqueConstraintError: Validation error]
name: 'SequelizeUniqueConstraintError',
message: 'Validation error',
errors:
[ { message: 'PRIMARY must be unique',
type: 'unique violation',
path: 'PRIMARY',
value: '[email protected]' } ],
fields: { PRIMARY: '[email protected]' } }
But nevertheless if I print the object in this way with Logatim logatim.red.error(JSON.stringify(error))
{"name":"SequelizeUniqueConstraintError","message":"Validation error","errors":[{"message":"PRIMARY must be unique","type":"unique violation","path":"PRIMARY","value":"[email protected]"}],"fields":{"PRIMARY":"[email protected]"}}
So we can abstract the configuration from the implementation.
The config would be able to modify:
{
level: {String | Number},
channels: [{
wagon: {Function}, // plug-in
options: {Object},
levels: {String []},
test: {Regexp},
exclude: {Regexp},
replace: {Boolean}
}],
storageKey: {String}, // name used to store the logatim level
env: {'node' | 'browser'},
logMethods: {String []},
verbose: {Boolean},
infect: {Boolean}
}
Thanks for the lib, looks sweet. Having an issue getting it working though. I made a reduced test case, file tree looks like this:
- package.json
- node_modules/
– logatim/
- index.js
index.js
looks like this:
const logatim = require('logatim')
console.log(logatim) // undefined
That log returns undefined every time. I'm on Node v7.4.0
but this doesn't work in v6.2.1
either.
100% human-like
logatim.red('R').green('G').info()
We need a combination of ANSI and HTML tags so we have to implement our own.
Include this new style table in the constants.js
.
For clientside (GH Pages, or JSBin) and serverside (Runnable?)
May be separate examples directory? Would be helpful to took at lib before downloading it. Thanks!
I tried to use logatim (nodejs v5.5) but it gives an error:
$ npm install logatim
$ node
> const logatim = require('logatim');
undefined
> logatim.warn('oops')
TypeError: e.join is not a function
at a (/home/jos/tmp/node_modules/logatim/dist/logatim.umd.min.js:1:3955)
at i (/home/jos/tmp/node_modules/logatim/dist/logatim.umd.min.js:1:3818)
at s (/home/jos/tmp/node_modules/logatim/dist/logatim.umd.min.js:1:3729)
at repl:1:9
at REPLServer.defaultEval (repl.js:252:27)
at bound (domain.js:287:14)
at REPLServer.runBound [as eval] (domain.js:300:12)
at REPLServer.<anonymous> (repl.js:417:12)
at emitOne (events.js:95:20)
at REPLServer.emit (events.js:182:7)
>
Am I overlooking something obvious?
Something like:
logatim.setLevel('info', true)
// will save it for the future also
logatim.setLevel('info')
// only for this current logatim instance
Find inspiration in latenflip/bows and dcodeIO/colour.js
Reproduce it as:
logatim.red.error('red').blue('blue')
// red (red color)logatim.green.error('green')
// blue (blue color) green (green color)It's keeping the blue
message for the next tick. Should be overriden.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.