Skip to content

Commit 5975a37

Browse files
committed
feat: v0.3.7
1 parent f2a378a commit 5975a37

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nerdctl",
3-
"version": "0.3.6",
3+
"version": "0.3.7",
44
"main": "dist/index.js",
55
"types": "dist/index.d.ts",
66
"description": "Node wrapper for nerdctl",

src/utils/logging.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020

2121
import { Console } from "console";
22+
import { EventEmitter } from "events";
2223
import fs from "fs";
2324
import path from "path";
2425
import stream from "stream";
@@ -33,8 +34,9 @@ export function setLogLevel(level: logLevel): void {
3334
LOG_LEVEL = level;
3435
}
3536

36-
export class Log {
37+
export class Log extends EventEmitter {
3738
constructor(topic: string, directory: string) {
39+
super();
3840
this.path = path.join(directory, `${topic}.log`);
3941

4042
fs.mkdirSync(directory, { recursive: true });
@@ -107,6 +109,7 @@ export class Log {
107109
message: any,
108110
optionalParameters: any[]
109111
) {
112+
this.emit("log", message, method);
110113
this.console[method](`%s: ${message}`, new Date(), ...optionalParameters);
111114
}
112115

src/vms/base.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import * as events from "@/constants/events";
2+
13
import { ImageResult, RemoveImageCommandFlags } from "@/types/images";
24
import {
35
RemoveCommandFlags,
@@ -23,6 +25,9 @@ export default abstract class BaseBackend extends EventEmitter {
2325
super();
2426
this.path = path;
2527
this.log = new Log(APP_NAME, join(this.resourcePath, "logs"));
28+
this.log.on("log", (message: string, type: string) => {
29+
this.emit(events.VM_INIT_OUTPUT, message, type);
30+
});
2631
}
2732

2833
protected get resourcePath() {

0 commit comments

Comments
 (0)