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

Add Logger interface #94

Merged
merged 1 commit into from Jul 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 32 additions & 0 deletions packages/opentelemetry-core/src/common/NoopLogger.ts
@@ -0,0 +1,32 @@
/**
* Copyright 2019, OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { Logger } from '@opentelemetry/types';

/** No-op implementation of Logger */
export class NoopLogger implements Logger {
// By default does nothing
debug(message: string, ...args: unknown[]) {}

// By default does nothing
error(message: string, ...args: unknown[]) {}

// By default does nothing
warn(message: string, ...args: unknown[]) {}

// By default does nothing
info(message: string, ...args: unknown[]) {}
}
25 changes: 25 additions & 0 deletions packages/opentelemetry-types/src/common/Logger.ts
@@ -0,0 +1,25 @@
/**
* Copyright 2019, OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export type LogFunction = (message: string, ...args: unknown[]) => void;

/** Defines a logger interface. */
export interface Logger {
error: LogFunction;
warn: LogFunction;
info: LogFunction;
debug: LogFunction;
}
1 change: 1 addition & 0 deletions packages/opentelemetry-types/src/index.ts
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

export * from './common/Logger';
export * from './context/propagation/Propagator';
export * from './distributed_context/DistributedContext';
export * from './distributed_context/EntryValue';
Expand Down