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

feat: trace level logging #437

Merged
merged 1 commit into from
Jul 11, 2018
Merged

feat: trace level logging #437

merged 1 commit into from
Jul 11, 2018

Conversation

njlie
Copy link
Contributor

@njlie njlie commented Jun 22, 2018

No description provided.

@njlie njlie requested a review from sharafian July 10, 2018 18:34

import through2 = require('through2')
const logStream = through2()
logStream.pipe(process.stdout)

// TODO: Not clear why I needed this, but got a
// TypeScript error without it.
export interface ConnectorLogger extends riverpig.Logger { }
export class ConnectorLogger {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could extend riverpig.Logger and add only the trace function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The riverpig.Logger that is exported is a type alias, rather than a class. It doesn't appear to export its own Logger class. I think extending this will still require me to define a class that fits the extended type definition

}

trace (...msg): void {
this.tracer(msg)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be this.tracer(...msg)?

this.river.debug(msg, ...elements)
}

trace (msg: any, ...elements: any[]): void {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why require two arguments instead of doing just (...msg: any[])?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typescript is enforcing that the function calls here match the function signatures for their interfaces. Both debug and riverpig implement their logging functions like this, so they expect at least one argument and using just the rest parameter will cause it to complain that it got at least 0 args on compile.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a comment about this for others who might have the same question?

@njlie njlie merged commit 5292ad4 into interledgerjs:master Jul 11, 2018
@@ -1,15 +1,44 @@
import * as riverpig from 'riverpig'
import { LoggerConfig } from 'riverpig'
import { Logger } from 'riverpig'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this be one statement, import { LoggerConfig, Logger } from 'riverpig' or am I missing something here?

this.river.debug(msg, ...elements)
}

trace (msg: any, ...elements: any[]): void {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a comment about this for others who might have the same question?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants