collective-soundworks / soundworks

Creative coding framework for distributed applications based on Web technologies.
http://soundworks.dev
BSD 3-Clause "New" or "Revised" License
114 stars 7 forks source link

custom logger to file? #3

Closed MAOShea closed 8 years ago

MAOShea commented 8 years ago

Hi guys, I don't know if this is an issue at all or just something that could be covered in the documentation at some point. Suffice it to say that my attempts to get it to work failed.

In my server's index.js I have this (see the logger object) :

server.init(
    { appName: 'The Dogging Remedy' },   
    { osc: {
        receiveAddress: '127.0.0.1',
        receivePort: 57121,
        sendAddress: '192.168.10.151',
        sendPort: 57124,
        }
    },
    { logger: {
        name: 'paisleyworks',
        level: 'info',
        streams: [
/*      {
          level: 'info',
          stream: process.stdout,
        }, */{
          level: 'info',
          path: './paisleyworks.log',
        }
        ]
        }
    }
    );

Later on, in one of my Activity classes:

import debug from 'debug';
const log = debug('paisleyworks:PerfLoNormalHi');
...
log("received user event " + usereventcounter + ", option:" + voteParams.option);

I set my DEBUG environment variable to enable paisleyworks:PerfLoNormalHi.

When I run SoundWorks, I see:

  {"name":"paisleyworks","hostname":"cheddar","pid":8328,"level":30,"socket":{"id":"/conductor#Y9TXgQux8TStFkwvAAAA"},"clientType":"conductor","msg":"disconnect","time":"2016-06-12T16:07:24.908Z","v":0} 

What am I doing wrong?

Thanks!

Michael

b-ma commented 8 years ago

Hi Michael,

It looks like you are confusing two things here (as well as pointing a problem in the documentation):

I actually don't know if debug is able to write logs inside a file but it's anyway something you should look for in the documentation of this package.

Benjamin

MAOShea commented 8 years ago

Benjamin,

thanks for the prompt response.

As you will have maybe already have detected, I'm still very much a n00b in Node.js.

To complement your analysis of my failed attempt at logging, could you kindly suggest what would be the correct strategy for implementing the ability to log to a file?

If there is anything in SoundWorks that I should be building upon or should I be trying to implement my own solution (possibly with the help of other packages available in the npm ecosystem)?

Regards et merci beaucoup!

Michael

b-ma commented 8 years ago

Hey,

No, there is nothing in soundworks to help you to do that, as I said the logger is not exposed for now and I'm really not sure it can be considered as something stable enough to be exposed.

To add logging in your own application, I think these 2 solutions are generally considered as good choices:

Bests, Benjamin

MAOShea commented 8 years ago

Thank you !

Regards,

Michael