Skip to content

Commit

Permalink
style: fix style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Jul 18, 2018
1 parent 829b475 commit 7c182e3
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/bin/commands/augment.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ import {
isRoarrLine
} from './utilities';

export const command = 'augment';
export const desc = 'Augments Roarr logs with additional information.';

type LogFormatterConfigurationType = {|
+appendHostname: boolean,
+appendInstanceId: boolean,
Expand Down Expand Up @@ -46,6 +43,9 @@ const createLogFormatter = (configuration: LogFormatterConfigurationType) => {
return stream;
};

export const command = 'augment';
export const desc = 'Augments Roarr logs with additional information.';

// eslint-disable-next-line flowtype/no-weak-types
export const builder = (yargs: Object) => {
return yargs
Expand Down
24 changes: 12 additions & 12 deletions src/bin/commands/pretty-print.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@ import {
isRoarrLine
} from './utilities';

export const command = 'pretty-print';
export const desc = 'Format logs for user-inspection.';
type ArgvType = {|
+excludeOrphans: boolean,
+includeContext: boolean
|};

type LogFormatterConfigurationType = {|
+includeContext: boolean,
+excludeOrphans: boolean
|};

/* eslint-disable quote-props */
const logLevels = {
Expand All @@ -34,11 +41,6 @@ const getLogLevelName = (logLevel: number): string => {
return logLevels[logLevel] || 'INFO';
};

type LogFormatterConfigurationType = {|
+includeContext: boolean,
+excludeOrphans: boolean
|};

const createLogFormatter = (configuration: LogFormatterConfigurationType) => {
const stream = split((line) => {
if (!isRoarrLine(line)) {
Expand Down Expand Up @@ -100,6 +102,9 @@ const createLogFormatter = (configuration: LogFormatterConfigurationType) => {
return stream;
};

export const command = 'pretty-print';
export const desc = 'Format logs for user-inspection.';

// eslint-disable-next-line flowtype/no-weak-types
export const builder = (yargs: Object) => {
return yargs
Expand All @@ -116,11 +121,6 @@ export const builder = (yargs: Object) => {
});
};

type ArgvType = {|
+excludeOrphans: boolean,
+includeContext: boolean
|};

export const handler = (argv: ArgvType) => {
process.stdin
.pipe(createLogFormatter(argv))
Expand Down
4 changes: 2 additions & 2 deletions src/factories/createLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ const createLogger = (onMessage: OnMessageEventHandlerType, parentContext: Messa
if (typeof context === 'function') {
return createLogger((message) => {
if (typeof context !== 'function') {
throw new Error('Unexpected state.');
throw new TypeError('Unexpected state.');
}
onMessage(context(message))
onMessage(context(message));
}, parentContext);
}

Expand Down
9 changes: 5 additions & 4 deletions src/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ import {
import {
ROARR_LOG
} from './config';
export type {
MessageType,
TranslatorType
} from './types';

global.ROARR = createRoarrInititialGlobalState(global.ROARR || {});

Expand All @@ -26,6 +22,11 @@ if (!global.ROARR.registeredFlush) {
});
}

export type {
MessageType,
TranslatorType
} from './types';

export default createLogger((message) => {
if (!ROARR_LOG) {
return;
Expand Down
2 changes: 2 additions & 0 deletions src/types.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// @flow

/* eslint-disable import/exports-last, flowtype/require-types-at-top */

export type SerializableObjectType = {
+[key: string]: string | number | null | SerializableObjectType
};
Expand Down
5 changes: 2 additions & 3 deletions test/roarr/roarr.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,8 @@ test('translates child message', (t) => {
return {
...message,
message: message.message + 'bar'
}
})
('foo');
};
})('foo');

t.deepEqual(log.messages, [
{
Expand Down

0 comments on commit 7c182e3

Please sign in to comment.