-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No logging message appear (ulog doesn't look to be loaded) #66
Comments
Hi @toddb have a look at this section of the documentation: Add to entry pointIn the entry point of your application import ulog: index.js import "ulog" https://github.com/Download/ulog#add-to-entry-point You should import I am open to ideas to improve the documentation on this. I kinda have a blind spot here since I know exactly how it works so I am not sure what I should change to make it more clear. EDIT:
Mmm yes.... I am not sure about this part. I am a typescript novice. Does whether or not you use typings have any influence on tree-shaking? I can imagine that the statement |
All your examples are without build chain tools. You just need to be aware of this. IMHO, you are a library builder of a library that is central (to real/professional software) that these days is just about never included as you document. We also use tool chains—thus an import is not enough. Just make a note of this is a bare minimum. Note: this occurs because you auto register ulog. One way around this is to document manual registration which means that tool chains include the library. I personally did it by using it in a log message. This is a tiny point. But it questions if the tool builder fully understands the customer and the customers' scenarios :-) |
I am using Webpack myself in the build of ulog.
Which is what the docs about adding to the entry point is supposed to be, If it's not good, please elaborate on how to improve it.
So show me your scenario. How can I understand your Typescript scenario if I'm not a regular typescript user and you don't show it? |
You could say:
and then write Also say: @Download perhaps the README focuses a bit too much on discussing how you took so many awesome features from other packages, like when you quote the code from other loggers ( My two cents. |
I still fail to see which 'complex setups' have an issue.
Yes, this may be true. On the other hand I have been swamped with work the last few months so I'm not working on ulog at the moment but one day I will come back to this. In the mean time if you want you could make a PR for the docs and or share a repo for me to look at. I am uncomfortable writring tips related to Typescript in the README myself because I am too unfamiliar with it. |
Got an issue, probably related to that ticket ? Not working (no log in the console) :
This works:
Same thing everywhere (i.e import ulog in index.js and import anylogger in another file) |
@eviltik |
@Download no, i've npm install, then i'm using webpack with imports. no lazy load. |
Is there something you can share, like a Github project, that I can test out? |
yep, let me create a simple case |
here it is : https://github.com/eviltik/ulog-test |
main code (src/frontend/index.js)
"immediate" not written into the console as it should Thank you |
@eviltik here's my code inside a Vue application registration. These logs do get written to the console. There are some very subtle differences and I wonder if that makes a difference (which are the subject of this message). You could try logging 'ulog' to see if you see the same behaviour. (sorry, I see your repo but struggling with time at the moment.) import anylogger from 'anylogger';
import ulog from 'ulog';
const log = anylogger('app');
log.debug(ulog.levels);
log.debug('Set log level \'%s\'', process.env.NODE_ENV); |
Sorry I have been very busy. I will check out your code base later. We will get this fixed. @toddb I am open to suggestions for changes / improvements, but please make them actionable. And in the past, some have said things like 'just rewrite this in typescript', which I don't think is a reasonable change to suggest. I do like Typescript and foresee a version 3 written in Typescript in the future, but I intend to finish v2 first, which means solving all the little issues and making sure this is a robust logging library that people can rely on to work. Given how long it took to get here, that may take a lot of time still. The current design is working pretty well imho and at this stage I intend to keep it like this and just iron out the issues first so we all have a stable 2.0 to work with. My design for this library is trying to meet some very ambitious requirements, many of which are actually contradictory:
My top priority is this great feature set at a microscopically small size. And if I have to write the code in Chinese or binary to get it, I will write the code in Chinese or binary. Writing readable code is great, but having a tiny and rich logging library is more important to me. Sometimes the design may seem contrived (and I'm sure it can be improved), but if these improvements make the library bigger without adding features, I'm against them. Because in my experience. only a few devs actually read the code. The fast majority just uses it and they could care less on how it was written as long as it works great and doesn't bloat their bundle. And that's exactly what I intend |
@eviltik Took a quick glance at your codebase and it looks fine to me. Don't have the time to dig into it right now but I will. I promise. Just a heads-up that you cannot combine the lazy loading with the sync behavior that you seek. But afaict from the quick glance at your code, you are not trying to. I do want sync loading to work. You won't get the 2.7kB footprint (it will be closer to 6kB) but that's life. We have to make hard choices sometimes. But just to let you know, I deeply care about the sync loading scenario to work and if the fact that it's not working at the moment in your code is due to a bug in |
thank you @Download It's important to fix this bug asap, because since a few months, a user who is testing ulog with webpack for this kind of usage will drop your lib immediately. I'm at this point too right now. Waiting for your fix ! ty |
+1 |
Any work arounds? No one else facing this issue. I tried pretty much everything and I decided to remove ulog. My belief is it does not work in a rollup react library setup. Tried a lot of stuff... but I don't want to spend more time on this. |
@harinair I see a couple of practical solutions. Roll back to ulog v1 (it did everything I wanted and mostly worked). I wouldn't recommend rolling your own Console anylogger implementation because IMHO it needs some logging level configuration that start to be a lot of work (ps I did :-(). I hope there is some sense in there that is useful. |
The documentation for running anylogger assumes anylogger as bundled package where it is directly loaded in the browser and globally available. The problem looks to be that ulog is not actually bundled because the only reference to ulog as the implementation is an import. Bundlers will treeshake the package.
Expected
Add logging to a project and logging messages will be written to the console in the browser
Actual
Nothing appears inn the browser console.
Steps to reproduce
Created a brand new Vue project and add logging
Based on the sample README, only a reference to
anylogger
is required.Add ulog import, still doesn't work (under my build system-let's assume "tree shaking" broadly)
Of course, the logging library is actually required to implement the interface. Without typings, it all gets hard and picked something random to log that ensures the library is bundled.
The text was updated successfully, but these errors were encountered: