Skip to content
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

Creating multiple log files #504

Closed
mrbhjv opened this issue Jul 9, 2016 · 7 comments
Closed

Creating multiple log files #504

mrbhjv opened this issue Jul 9, 2016 · 7 comments
Assignees
Labels
non issue Issue is not a problem or requires changes

Comments

@mrbhjv
Copy link

mrbhjv commented Jul 9, 2016

Hello, I'm developing an app where I want to be able to generate multiple log files, one for errors, one for requests and one for ops. Using good 6.x.x I was able to do so. Now I'm not being capable of. It just takes the first one in the list.

I've tried creating one option with the reporters object with three files and it only takes the first one. I've also tried splitting them into multiple options but it's the same. Maybe I'm doing something wrong.

Thanks!

@arb
Copy link
Contributor

arb commented Jul 10, 2016

I need to see your configuration to help. My guess is that you're using the same reporter name for all the file logging reporters.

@arb arb self-assigned this Jul 10, 2016
@arb arb added the question label Jul 10, 2016
@mrbhjv
Copy link
Author

mrbhjv commented Jul 10, 2016

Sorry for the lack of format. I did to train myself to post things in here.

I'm using the same reporter name for everyone but when changing it doesn't produce any difference. For this example of code, only the last log file gets created. I tried to go through the code and doc, but there's not much I can follow. Besides I am relatively new to JS itself, I am just trying to use the best resources I can run into. Sorry if my issue is kinda dumb :)

const options = {
    ops:{
        interval: 5000
    },
    reporters: {
        file: [{
            module: 'good-squeeze',
            name: 'Squeeze',
            args: [{ops: '*'}]
        },{
            module: 'good-squeeze',
            name: 'SafeJson'
        },{
            module: 'good-file',
            args: ['./logs/hapi-process.log']
        }],
        file: [{
            module: 'good-squeeze',
            name: 'Squeeze',
            args: [{response: '*'}]
        },{
            module: 'good-squeeze',
            name: 'SafeJson'
        },{
            module: 'rotating-file-stream',
            args: ['hapi-requests.log',
            {
                size: '10000B',
                path: './logs'
            }]
        }],
        file: [{
            module: 'good-squeeze',
            name: 'Squeeze',
            args: [{error: '*'}]
        },{
            module: 'good-squeeze',
            name: 'SafeJson'
        },{
            module: 'rotating-file-stream',
            args: ['hapi-error.log',
            {
                size: '1000B',
                path: './logs'
            }]
        }]
    }
}

server.register({
    register: require('good'),
    options: options
}, function(err) {

    //something
});

@mtharrison
Copy link

mtharrison commented Jul 10, 2016

You can not have multiple properties with the same name in JavaScript (nothing specific to Good here). To start with, you probably need to name them differently.

screen shot 2016-07-10 at 23 22 04

@arb arb assigned mtharrison and unassigned arb Jul 10, 2016
@arb arb added non issue Issue is not a problem or requires changes and removed question labels Jul 10, 2016
@cshanejennings
Copy link
Contributor

cshanejennings commented Aug 11, 2016

This threw me as well and I think it's a potential interpretation quirk in the documentation.

I assumed that the keys in reporters hash were reserved names based on the type of reporting. It wasn't until I saw this thread that I realized the keys were arbitrarily named (at least I'm assuming they are). I think something that could help would be to provide an example of two files being logged out where the keys are labeled something obviously unreserved like "mylogfile1" and "mylogfile2".

OR... to explain the purpose of the keys in the hash and provide some comments on what each section is actually doing. Anyhow, hope that's helpful!

EDIT: after noticing the API documentation link I see this is clearly explained. doh! I think just a simple "View the api documentation for more information on reporters" next to the examples could help reduce confusion for those of us moving fast and skimming? I'm following along with a tutorial that's out of date and already a lot farther down the rabbit hole than I anticipated, hence the lack of attention to detail.

@arb
Copy link
Contributor

arb commented Aug 11, 2016

PR documentations are always welcome.

@cshanejennings
Copy link
Contributor

done, let me know if that works for you or if you'd like me to tweak it. Thanks!

@arb arb closed this as completed in 673af3e Aug 12, 2016
@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
non issue Issue is not a problem or requires changes
Projects
None yet
Development

No branches or pull requests

4 participants