Comments (7)
I see what you mean, but I'd disagree.
Simple usecase for example is logging method calls. I use a decorator to make this easy to add to interesting methods.
It prints: Calling ${methodName} with args:
and then the args as objects. It's very useful to print them as objects since this is the browser and the browser console has some really powerful built-in logging formatters (especially for things like DOM nodes).
So I appreciate the current capability of allowing you to mix "text logs" and "object logs"
from diary.
Howdy @abeforgit β thank you for this. Yeah its definitely I was in mind of when designing the api. I didnt want an exact 1-to-1 relationship with console.log. It was more for the storytelling aspects.
But yeah maybe there is scope or use for just straight objects, or any data type other than string in that message argument. I can see value in something like a api or fetcher layer, where you may want it to simply log payloads coming back β the scope of the method would be that small that the diary name itself is descriptive enough. so diary('things').log({ payload: 'things' })
seems good enough for there.
So ya, let me have a ponder, see if anyone else chimes in with some ideas. If not ya will look at adding. πΊπ»
from diary.
Sounds like there are
- story telling use case, which (probably) give
diary
a name - structure logs use case, which is more applicable for, well, "logs"
Wondering - it is about expanding existing API, letting to do more(or less) stuff, or adding extra API/functionality a little aside, as it is actually a different use case
from diary.
Yeah I find that with a good diary name the message can become a bit redundant. It's also a slight deviation from the original console
api which might trip up users (only once, really, but still)
Ultimately it's about control I think. Do you want to "force" users to use best practices? or do you allow them to use it however they want?
One thing I could see happening is people avoiding the issue by using console
directly when the lib doesn't behave how they expect. Or passing ""
as the message, which would be a bit silly.
@theKashey I don't think adding extra API for logging objects directly is the way to go. It's basically already supported anyway, all you have to do is provide a message (or ""
if you really have nothing to say). I think extra methods would only increase confusion without adding value.
from diary.
Usually, it's or "textural logs" or "json logs". Never both at the same time.
from diary.
But the request is about logging something without any message provided. Sounds like it can be solved with a little different π€·ββοΈ wording:
- strict mode, enforcing you to follow some "model"
- flexible mode, where you can do whatever you want πππ the one you are looking for
from diary.
Hi @abeforgit sorry for the delay here π
We no longer restrict what you want to log, be it info('bob')
, info()
, or info({ foo: 'bar' })
. We will respect this.
message[0]
will still format, if it's a string.
from diary.
Related Issues (14)
- TypeScript: Cannot find module 'diary' or its corresponding type declarations HOT 7
- feature request: diaries that inherit from other scopes HOT 3
- [Bug] Handle cases where localStorage is not available. HOT 3
- Support `deno`
- Separate setup from logging in benchmarks HOT 4
- `LogFnAsError` type missing from `src/index.d.ts` HOT 3
- Trying to access process.env HOT 2
- Add check to filter log level HOT 2
- Add in a json logger as an extra
- Build babel plugin to enhance context HOT 3
- Consider anylogger support? HOT 4
- [RFC] Always "log" just don't output HOT 1
- TypeScript: Cannot find module 'diary' or its corresponding type declarations HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from diary.