Skip to content

Commit

Permalink
feat: improved logging
Browse files Browse the repository at this point in the history
  • Loading branch information
grutt committed Feb 3, 2024
1 parent 4640e62 commit ca7c355
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions typescript-sdk/src/clients/dispatcher/dispatcher-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from '@hatchet/protoc/dispatcher';
import { ClientConfig } from '@clients/hatchet-client/client-config';
import HatchetError from '@util/errors/hatchet-error';
import { Logger } from '@hatchet/util/logger';
import { ActionListener } from './action-listener';

interface GetActionListenerOptions {
Expand All @@ -19,9 +20,12 @@ export class DispatcherClient {
config: ClientConfig;
client: PbDispatcherClient;

logger: Logger;

constructor(config: ClientConfig, channel: Channel, factory: ClientFactory) {
this.config = config;
this.client = factory.create(DispatcherDefinition, channel);
this.logger = new Logger(`Dispatcher`, config.log_level);
}

async getActionListener(options: GetActionListenerOptions) {
Expand Down
8 changes: 7 additions & 1 deletion typescript-sdk/src/clients/event/event-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ import {
} from '@hatchet/protoc/events/events';
import HatchetError from '@util/errors/hatchet-error';
import { ClientConfig } from '@clients/hatchet-client/client-config';
import { Logger } from '@hatchet/util/logger';

export class EventClient {
config: ClientConfig;
client: EventsServiceClient;

logger: Logger;

constructor(config: ClientConfig, channel: Channel, factory: ClientFactory) {
this.config = config;
this.client = factory.create(EventsServiceDefinition, channel);
this.logger = new Logger(`Dispatcher`, config.log_level);
}

push<T>(type: string, input: T) {
Expand All @@ -24,7 +28,9 @@ export class EventClient {
};

try {
return this.client.push(req);
const e = this.client.push(req);
this.logger.info(`Event pushed: ${type}`);
return e;
} catch (e: any) {
throw new HatchetError(e.message);
}
Expand Down

0 comments on commit ca7c355

Please sign in to comment.