Skip to content

Commit

Permalink
Add Logger interface (open-telemetry#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurkale22 authored Jul 11, 2019
1 parent 06ac7aa commit 14310c3
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/opentelemetry-core/src/common/NoopLogger.ts
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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

0 comments on commit 14310c3

Please sign in to comment.