Skip to content

Commit

Permalink
Remove loglevel-debug and DEBUG=apollo-gateway:* support. (#3896)
Browse files Browse the repository at this point in the history
While this package provided some simple functionality at one point or
another, it was neither actively maintained, properly typed, and as of #
fully-featured as of
#3894, no longer really
necessary.  Also, since it re-uses the same logger based on repeat requests
to `getLogger("name")` in a global context, it was responsible for
recursively wrapping our log function in tests with the same `methodFactory`
and causing our log messages to get longer and longer for each test which
used `ApolloGateway`.  This only affected tests, but was hard to track down
the cause!

The new `logger` functionality in the above PR should provide much more
flexibility here and `debug: true` on the `ApolloGateway` constructor can
replicate the same behavior.

Anyone who misses this behavior can utilize the new pluggable
logger to provide [`loglevel-debug`] themselves!
  • Loading branch information
abernix authored Mar 18, 2020
1 parent c56129d commit 0ca43f8
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 20 deletions.
9 changes: 0 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/apollo-gateway/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Warn of a possible misconfiguration when local service configuration is provided (via `serviceList` or `localServiceList`) and a remote Apollo Graph Manager configuration is subsequently found as well. [PR #3868](https://github.com/apollographql/apollo-server/pull/3868)
- During composition, the unavailability of a downstream service in unmanaged federation mode will no longer result in a partially composed schema which merely lacks the types provided by the downed service. This prevents unexpected validation errors for clients querying a graph which lacks types which were merely unavailable during the initial composition but were intended to be part of the graph. [PR #3867](https://github.com/apollographql/apollo-server/pull/3867)
- Support providing a custom logger implementation (e.g. [`winston`](https://npm.im/winston), [`bunyan`](https://npm.im/bunyan), etc.) to capture gateway-sourced console output. This allows the use of existing, production logging facilities or the possibiltiy to use advanced structure in logging, such as console output which is encapsulated in JSON. The same PR that introduces this support also introduces a `logger` property to the `GraphQLRequestContext` that is exposed to `GraphQLDataSource`s and Apollo Server plugins, making it possible to attach additional properties (as supported by the logger implementation) to specific requests, if desired, by leveraging custom implementations in those components respectively. When not provided, these will still output to `console`. [PR #3894](https://github.com/apollographql/apollo-server/pull/3894)
- Drop use of `loglevel-debug`. This removes the very long date and time prefix in front of each log line and also the support for the `DEBUG=apollo-gateway:` environment variable. Both of these were uncommonly necessary or seldom used (with the environment variable also being undocumented). The existing behavior can be preserved by providing a `logger` that uses `loglevel-debug`, if desired, and more details can be found in the PR. [PR #3896](https://github.com/apollographql/apollo-server/pull/3896)

## 0.13.2

Expand Down
1 change: 0 additions & 1 deletion packages/apollo-gateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"apollo-server-types": "file:../apollo-server-types",
"graphql-extensions": "file:../graphql-extensions",
"loglevel": "^1.6.1",
"loglevel-debug": "^0.0.1",
"make-fetch-happen": "^7.1.1",
"pretty-format": "^24.7.0"
},
Expand Down
10 changes: 4 additions & 6 deletions packages/apollo-gateway/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
import { GraphQLSchemaValidationError } from 'apollo-graphql';
import { composeAndValidate, ServiceDefinition } from '@apollo/federation';
import loglevel from 'loglevel';
import loglevelDebug from 'loglevel-debug';

import { buildQueryPlan, buildOperationContext } from './buildQueryPlan';
import {
Expand Down Expand Up @@ -220,14 +219,13 @@ export class ApolloGateway implements GraphQLService {
this.logger = this.config.logger;
} else {
// If the user didn't provide their own logger, we'll initialize one.
const loglevelLogger = loglevel.getLogger(`apollo-gateway:`);

// Support DEBUG environment variable, à la https://npm.im/debug/.
loglevelDebug(loglevelLogger);
const loglevelLogger = loglevel.getLogger(`apollo-gateway`);

// And also support the `debug` option, if it's truthy.
if (this.config.debug === true) {
loglevelLogger.enableAll();
loglevelLogger.setLevel(loglevelLogger.levels.DEBUG);
} else {
loglevelLogger.setLevel(loglevelLogger.levels.WARN);
}

this.logger = loglevelLogger;
Expand Down
4 changes: 0 additions & 4 deletions types/loglevel-debug/index.d.ts

This file was deleted.

0 comments on commit 0ca43f8

Please sign in to comment.