@nexus/logger
Advanced tools
Comparing version 0.2.0-next.5 to 0.2.0-next.6
@@ -6,5 +6,5 @@ import { Num } from './level'; | ||
level: Num; | ||
event: string; | ||
path?: string[]; | ||
event: string; | ||
context: Context; | ||
context?: Context; | ||
time?: number; | ||
@@ -28,3 +28,3 @@ pid?: number; | ||
*/ | ||
export declare function create(rootState: RootLogger.State, path: null | string[], parentContext: Context): { | ||
export declare function create(rootState: RootLogger.State, path: null | string[], parentContext?: Context): { | ||
logger: Logger; | ||
@@ -31,0 +31,0 @@ link: Link; |
@@ -15,3 +15,3 @@ import * as Lo from 'lodash'; | ||
// Copy as addToContext will mutate it | ||
pinnedAndParentContext: Lo.cloneDeep(parentContext), | ||
pinnedAndParentContext: parentContext ? Lo.cloneDeep(parentContext) : undefined, | ||
children: [], | ||
@@ -29,3 +29,2 @@ }; | ||
const logRec = { | ||
context: {}, | ||
event, | ||
@@ -38,5 +37,11 @@ level, | ||
// Avoid mutating the passed local context | ||
logRec.context = localContext | ||
? Lo.merge({}, state.pinnedAndParentContext, localContext) | ||
: state.pinnedAndParentContext; | ||
if (localContext && state.pinnedAndParentContext) { | ||
logRec.context = Lo.merge({}, state.pinnedAndParentContext, localContext); | ||
} | ||
else if (localContext) { | ||
logRec.context = localContext; | ||
} | ||
else if (state.pinnedAndParentContext) { | ||
logRec.context = state.pinnedAndParentContext; | ||
} | ||
if ((_a = rootState.settings) === null || _a === void 0 ? void 0 : _a.data.hostname) { | ||
@@ -43,0 +48,0 @@ logRec.hostname = OS.hostname(); |
@@ -173,3 +173,3 @@ import stripAnsi from 'strip-ansi'; | ||
let contextColumnsConsumed = 0; | ||
const contextEntries = Object.entries(logRecord.context); | ||
const contextEntries = logRecord.context ? Object.entries(logRecord.context) : []; | ||
let widestKey = 0; | ||
@@ -176,0 +176,0 @@ let first = true; |
@@ -14,3 +14,3 @@ import * as Logger from './logger'; | ||
Object.assign(settingsManager, settings); | ||
const loggerLink = Logger.create({ settings: settingsManager }, null, {}); | ||
const loggerLink = Logger.create({ settings: settingsManager }, null, undefined); | ||
const logger = loggerLink.logger; | ||
@@ -17,0 +17,0 @@ logger.settings = settingsManager; |
@@ -6,5 +6,5 @@ import { Num } from './level'; | ||
level: Num; | ||
event: string; | ||
path?: string[]; | ||
event: string; | ||
context: Context; | ||
context?: Context; | ||
time?: number; | ||
@@ -28,3 +28,3 @@ pid?: number; | ||
*/ | ||
export declare function create(rootState: RootLogger.State, path: null | string[], parentContext: Context): { | ||
export declare function create(rootState: RootLogger.State, path: null | string[], parentContext?: Context): { | ||
logger: Logger; | ||
@@ -31,0 +31,0 @@ link: Link; |
@@ -19,3 +19,3 @@ "use strict"; | ||
// Copy as addToContext will mutate it | ||
pinnedAndParentContext: Lo.cloneDeep(parentContext), | ||
pinnedAndParentContext: parentContext ? Lo.cloneDeep(parentContext) : undefined, | ||
children: [], | ||
@@ -33,3 +33,2 @@ }; | ||
const logRec = { | ||
context: {}, | ||
event, | ||
@@ -42,5 +41,11 @@ level, | ||
// Avoid mutating the passed local context | ||
logRec.context = localContext | ||
? Lo.merge({}, state.pinnedAndParentContext, localContext) | ||
: state.pinnedAndParentContext; | ||
if (localContext && state.pinnedAndParentContext) { | ||
logRec.context = Lo.merge({}, state.pinnedAndParentContext, localContext); | ||
} | ||
else if (localContext) { | ||
logRec.context = localContext; | ||
} | ||
else if (state.pinnedAndParentContext) { | ||
logRec.context = state.pinnedAndParentContext; | ||
} | ||
if ((_a = rootState.settings) === null || _a === void 0 ? void 0 : _a.data.hostname) { | ||
@@ -47,0 +52,0 @@ logRec.hostname = OS.hostname(); |
@@ -177,3 +177,3 @@ "use strict"; | ||
let contextColumnsConsumed = 0; | ||
const contextEntries = Object.entries(logRecord.context); | ||
const contextEntries = logRecord.context ? Object.entries(logRecord.context) : []; | ||
let widestKey = 0; | ||
@@ -180,0 +180,0 @@ let first = true; |
@@ -18,3 +18,3 @@ "use strict"; | ||
Object.assign(settingsManager, settings); | ||
const loggerLink = Logger.create({ settings: settingsManager }, null, {}); | ||
const loggerLink = Logger.create({ settings: settingsManager }, null, undefined); | ||
const logger = loggerLink.logger; | ||
@@ -21,0 +21,0 @@ logger.settings = settingsManager; |
{ | ||
"name": "@nexus/logger", | ||
"version": "0.2.0-next.5", | ||
"version": "0.2.0-next.6", | ||
"main": "dist/index.js", | ||
@@ -36,3 +36,3 @@ "repository": "git@github.com:graphql-nexus/logger.git", | ||
"typescript": "3.9.2", | ||
"typescript-snapshots-plugin": "^1.7.0" | ||
"typescript-snapshots-plugin": "1.7.0" | ||
}, | ||
@@ -39,0 +39,0 @@ "jest": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
212386
3416