- apollo-server Version: apollo-server-express@3.6.1
- Operating System (or Browser): windows 10, firefox latest
- Node Version: v16.13.1
- apollo-log Version: 1.1.0
How Do We Reproduce?
I suspect this is OS specific. To repro just use apollo-log as normal on a windows 10 machine. I am using conemu as my terminal but the same happens on windows default cmd
Expected Behavior
The logs are displayed with linebreaks etc so that they can be easily read.
apollo 44d6e2 {
event: 'request',
operationName: 'AddUser',
query: 'mutation AddUser($addUserInput: AddUserInput!) {\n' +
' addUser(addUserInput: $addUserInput) {\n' +
' id\n' +
' device_id\n' +
' favourites\n' +
' __typename\n' +
' }\n' +
'}',
variables: [ 'addUserInput' ],
context: {
logger: Logger {
name: 'apollo-server',
levels: [Object],
methodFactory: [Function: defaultMethodFactory],
getLevel: [Function (anonymous)],
setLevel: [Function (anonymous)],
setDefaultLevel: [Function (anonymous)],
resetLevel: [Function (anonymous)],
enableAll: [Function (anonymous)],
disableAll: [Function (anonymous)],
trace: [Function: noop],
debug: [Function: noop],
info: [Function: bound info],
warn: [Function: bound warn],
error: [Function: bound error],
log: [Function: noop]
},
schema: GraphQLSchema {
__validationErrors: [],
description: undefined,
Actual Behavior
Server is running on http://localhost:4000/graphql
apollo 21d17c {"event":"request","query":" query IntrospectionQuery { __schema { queryType { name } mutationType { name } subscriptionType { name } types { ...FullType } directives { name description locations args { ...InputValue } } } } fragment FullType on __Type { kind name description fields(includeDeprecated: true) { name description args { ...InputValue } type { ...TypeRef } isDeprecated deprecationReason } inputFields { ...InputValue
} interfaces { ...TypeRef } enumValues(includeDeprecated: true) { name description isDeprecated deprecationReason } possibleTypes { ...TypeRef } } fragment InputValue on __InputValue { name description type { ...TypeRef } defaultValue } fragment TypeRef on __Type { kind name ofType { kind name ofType { kind
name ofType { kind name ofType { kind name ofType { kind name ofType { kind
name ofType {
Observations
So the problem arises from the call to stringify() here:
|
log[(data as any).errors ? 'error' : 'info'](chalk`{dim ${id}}`, stringify(mutated)); |
when I removed stringify() and just returned the mutated variable the formatting was correct (as shown in expected behaviour above).
log[(data as any).errors ? 'error' : 'info'](chalk`{dim ${id}}`, mutated);
also I removed the line deleting newline chars in the query here
https://github.com/edzillion/apollo-log/blob/0b33bcd29f17ca8d321586b4770fe1c779ff96cb/src/index.ts#L69
How Do We Reproduce?
I suspect this is OS specific. To repro just use apollo-log as normal on a windows 10 machine. I am using conemu as my terminal but the same happens on windows default cmd
Expected Behavior
The logs are displayed with linebreaks etc so that they can be easily read.
Actual Behavior
Observations
So the problem arises from the call to
stringify()here:apollo-log/src/index.ts
Line 55 in 0b33bcd
when I removed
stringify()and just returned themutatedvariable the formatting was correct (as shown in expected behaviour above).log[(data as any).errors ? 'error' : 'info'](chalk`{dim ${id}}`, mutated);also I removed the line deleting newline chars in the query here
https://github.com/edzillion/apollo-log/blob/0b33bcd29f17ca8d321586b4770fe1c779ff96cb/src/index.ts#L69