My first question is. Is it possible to get the filename and line
number of the logging call from within the log.debug call for
instance?
Kind regards
---
Thomas FRITZ
web http://fritzthomas.com
twitter http://twitter.com/thomasf
--Job Board: http://jobs.nodejs.org/Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-GuidelinesYou received this message because you are subscribed to the GoogleGroups "nodejs" group.To post to this group, send email to nod...@googlegroups.comTo unsubscribe from this group, send email toFor more options, visit this group at
In case of express or socket.io or other libraries, if they would just
use this core logging then, it would be easy for you to configure
logging format and "plug" a userland logging framework to it which
writes all logs to a file for instance.
Without the need to reafactor anything.
---
Thomas FRITZ
web http://fritzthomas.com
twitter http://twitter.com/thomasf
2012/1/20 Eldar Djafarov <djk...@gmail.com>:
> Well. There are modules for this. I do not think this needs to be a part of
> nodejs core.
>
But in my opinion something like that has to be in the core. Because,
even when devnull is great and i would definately use it, other will
not. So if node.js would have such a generic core logging framework, i
think other userland logging frameworks like devnull with multiple
transports will then be built on top of that core, which will then
allow the end application to define and configure its logging
behaviour like he wants it to be.
In fact the API of devnull is mostly exactly like thought of. But for
the generic core logging i would not support multiple transports or
multiple configuration envs as this i would see in userland modules
built on top of that.
I think that this is really important for better debugging and error
research. Especially when node apps beeing more and more in production
log monitoring and alerting gets more and more important. Without a
unified log format this is not that easy as it sounds as one would
maybe think.
---
Thomas FRITZ
web http://fritzthomas.com
twitter http://twitter.com/thomasf
2012/1/20 Arnout Kazemier <in...@3rd-eden.com>:
This is useless, you're just defining yet another logging framework.
All
the options you set (useColors, *format) should not be there. To be
used
by any module you should have something like:
var log = require("logger")("my_module_id"); // or app_id or whatever
log.info("whatever");
// and perhaps..
log.info("whatever", aditionalStuffObject);
Date should be added automatically, format and colors should be global.
var log = require("logger");
log.setDateFormat("d-m-Y ...").useColors(true);
---
Diogo R.
So for instance if express would use 'setDataFormat('Y-m-y
H:i:s').useColors(true)' and my app depends on express i want to have
the possibility to override all existing log settings. Otherwise it
makes no sense to me.
With "my_module_id" or "app_id" you mean a free identifier used in the
log output, right?
so the above log messages would output something like this, right?
[20-01-2012 13:03] [INFO] [my_module_id] [/path/to/file.js:12] "whatever"
I have not found a way to get the line number and the file where the
logging happened. Is there a clean way to get this information?
Another question is how to configure or handle log levels which should
be logged or not logged?
---
Thomas FRITZ
web http://fritzthomas.com
twitter http://twitter.com/thomasf
2012/1/20 Diogo Resende <dres...@thinkdigital.pt>:
phidelta <philipp...@gmail.com> wrote:
So with that reality in mind we have to face reality that this will
never happen, when node does not provide a simple generic
infrastructure for this. Maybe there is no need for a extra "logging"
core module. Perhaps just a documented
debug,log,notice,info,warn,error event is enough. So everyone could
just use the global console object as everyone does already and this
will emit a event on console.
For instance:
console.on('log', function(file, line, message) {
});
console.on('error', function(file, line, message) {
});
and library modules like the one mentioned above would just use
somethin like, i do not know, maybe:
console.emit('log', "this is the log message")
// or
console.emit("error", "this is an error");
But i fully agree that this has nothing to do in the core. It is the
responsibilty of the final app using this modules to decide what to
log and what not. But we are not in this situation, so apparently
something has to be done here.
---
Thomas FRITZ
web http://fritzthomas.com
twitter http://twitter.com/thomasf
2012/1/20 phidelta <philipp...@gmail.com>:
What you consider a module I can consider a dependency and find myself
building an app *with modules*. In an extreme view, any file is a
module.
> When I evaluate whether or not to use a module, any module that logs
> stuff or writes to the console (unless of course that is its stated
> purpose) is automatically disqualified. Even a framework like Express
> should never log anything. What it should do is have the app emit an
> event. If I as the developer then decide I want that event in a log,
> then that is my decision.
>
> So logging is not something that should be anywhere, much less in
> core.
What I exposed can and is probably better on the module land, not core.
The only thing I don't know how to, is get the file/line of the caller.
---
Diogo R.
konsole's API is identical to the internal console API. So usage of
konsole is exactly like console. The difference is that konsole will
not write to stdout or stderr. Instead it will emit a 'data' event and
one event named after the log level.
For example:
konsole.info("foo");
will emit a 'data' event and a 'info' event.
On the GitHub Page there is some more info how to use it, or how it is
intended to use.
Kind regards
---
Thomas FRITZ
web http://fritzthomas.com
twitter http://twitter.com/thomasf
2012/1/21 Dobes <dob...@gmail.com>:
Thanks. I also was looking for something like that. I actually
proposed that there needs something to be done in the core, so that
developers of modules are using logging the right way and not in very
different ways.
Could you open an issue?
You are right. In production you normally do not want to do that kind
of logging. I think i will have to reorder the callback arguments
then.
I will try add a configuration for this.
>
> Jeff
I fixed your issue.
It is now possible to configure if a stack should be generated.
In the new version the usage changed a bit, now i think i am happy
with the result.
* konsole overrides the default console functions. So in a module
where you have used console.* functions you just have to add a
require("konsole")(); at least to override consoles functions.
* But you could also return a konsole object without overriding - just
call var konsole = require("konsole")("any label"); As before konsoles
API is identical to consoles one. So you can easily change it.
* You will also get the pid from where the log came from and the
process type (worker or master) - useful if you have different workers
of the same file running
* you also get a time diff in milliseconds since the last log with the
same label (you can turn this off the same way you can turn tracing
off)
* It is also now mandatory to add at least one listener otherwise,
nothing will ever be written to stdout.
I have added one more example, the cluster example from the node.js
docs and updated the example before.
Take a look at the readme to see what it can do for you:
https://github.com/thomasfr/node-konsole
I am thinking of adding some ENV Variable checking directly in
konsole. There is an issue opened, please comment if you want that and
how you want that feature to be.
Another open issue is, but i am not sure yet, if i should ANSI color
utility functions, so one could easily colorize its ouput in his
callback. What do you think?
Kind regards
---
Thomas FRITZ
web http://fritzthomas.com
twitter http://twitter.com/thomasf
2012/1/27 Thomas Fritz <frit...@gmail.com>: