Fix backend logger bindings

This commit is contained in:
Silvano Cerza 2022-03-14 11:01:47 +01:00 committed by Alberto Iannaccone
parent ce2f1c227a
commit b97af32bb8
4 changed files with 26 additions and 9 deletions

View File

@ -84,8 +84,9 @@ import { PlotterBackendContribution } from './plotter/plotter-backend-contributi
import { ArduinoLocalizationContribution } from './arduino-localization-contribution';
import { LocalizationContribution } from '@theia/core/lib/node/i18n/localization-contribution';
import { MonitorManagerProxyImpl } from './monitor-manager-proxy-impl';
import { MonitorManager } from './monitor-manager';
import { MonitorManager, MonitorManagerName } from './monitor-manager';
import { MonitorManagerProxy, MonitorManagerProxyClient, MonitorManagerProxyPath } from '../common/protocol/monitor-service';
import { MonitorServiceName } from './monitor-service';
export default new ContainerModule((bind, unbind, isBound, rebind) => {
bind(BackendApplication).toSelf().inSingletonScope();
@ -302,6 +303,23 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
.inSingletonScope()
.whenTargetNamed('config');
// Logger for the monitor manager and its services
bind(ILogger)
.toDynamicValue((ctx) => {
const parentLogger = ctx.container.get<ILogger>(ILogger);
return parentLogger.child(MonitorManagerName);
})
.inSingletonScope()
.whenTargetNamed(MonitorManagerName);
bind(ILogger)
.toDynamicValue((ctx) => {
const parentLogger = ctx.container.get<ILogger>(ILogger);
return parentLogger.child(MonitorServiceName);
})
.inSingletonScope()
.whenTargetNamed(MonitorServiceName);
bind(DefaultGitInit).toSelf();
rebind(GitInit).toService(DefaultGitInit);

View File

@ -1,5 +1,4 @@
import { ILogger } from "@theia/core";
import { inject, injectable, named } from "@theia/core/shared/inversify";
import { inject, injectable } from "@theia/core/shared/inversify";
import { MonitorManagerProxy, MonitorManagerProxyClient, MonitorSettings, Status } from "../common/protocol";
import { Board, Port } from "../common/protocol";
import { MonitorManager } from "./monitor-manager";
@ -9,10 +8,6 @@ export class MonitorManagerProxyImpl implements MonitorManagerProxy {
protected client: MonitorManagerProxyClient;
constructor(
@inject(ILogger)
@named("monitor-manager-proxy")
protected readonly logger: ILogger,
@inject(MonitorManager)
protected readonly manager: MonitorManager,
) {

View File

@ -6,6 +6,8 @@ import { MonitorService } from "./monitor-service";
type MonitorID = string;
export const MonitorManagerName = 'monitor-manager';
@injectable()
export class MonitorManager extends CoreClientAware {
// Map of monitor services that manage the running pluggable monitors.
@ -16,7 +18,7 @@ export class MonitorManager extends CoreClientAware {
constructor(
@inject(ILogger)
@named('monitor-manager')
@named(MonitorManagerName)
protected readonly logger: ILogger,
) {
super();

View File

@ -8,6 +8,8 @@ import { WebSocketProvider } from "./web-socket/web-socket-provider";
import { Port as gRPCPort } from 'arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/port_pb'
import WebSocketProviderImpl from "./web-socket/web-socket-provider-impl";
export const MonitorServiceName = 'monitor-service';
export class MonitorService extends CoreClientAware implements Disposable {
// Bidirectional gRPC stream used to receive and send data from the running
// pluggable monitor managed by the Arduino CLI.
@ -39,7 +41,7 @@ export class MonitorService extends CoreClientAware implements Disposable {
constructor(
@inject(ILogger)
@named("monitor-service")
@named(MonitorServiceName)
protected readonly logger: ILogger,
private readonly board: Board,