mperdeck / jsnlog.js

Tiny JavaScript logging library, simple and well documented. Lots of options to filter logging data.
js.jsnlog.com
Other
130 stars 43 forks source link

Example custom appender #60

Closed ap1969 closed 6 years ago

ap1969 commented 6 years ago

Hi, First of all, I love JSNlog. I've been battling with a number of logging solutions for a JS client application, and none worked well, so thanks for creating this.

However, I'm stuck on something. I'm trying to write a custom appender which is basically a modification to the console appender. I keep hitting issues with the typescript definitions, probably because I'm pretty new to typescript.

Do you have an example appender template which we could use to create our own appenders - something that sits outside the JSNLog package, but references it correctly?

Regards, Andy

mperdeck commented 6 years ago

I don't have such an example. I never expected anybody to want to write a client side custom appender that lives outside jsnlog.ts.

One approach would be to write your appender in JavaScript and not worry about type definitions. For inspiration, the JavaScript version of jsnlog.ts is in jsnlog.js.

In case you're familiar with Node.Js, you can use Winston transports as JSNLog appenders. These live server side in a Node app. See: http://nodejs.jsnlog.com/Documentation/HowTo/LogToDb

ap1969 commented 6 years ago

Thanks. I had a brainwave - remove the console appender and simply write to console. Stunning idea, eh? :-)

Appreciate the good work - the module has come in really useful.

mperdeck commented 6 years ago

Problem solved!

Do you use JSNLog for a company? I am keen to have more company logos on the jsnlog.com home page: http://jsnlog.com/