Skip to content

Commit 340c68a

Browse files
authored
Merge pull request #6169 from elizaOS/refactor/standardize-clean-logging
refactor: Standardize Logging Across Core, CLI, and Server
2 parents c173aef + 52cf7fb commit 340c68a

File tree

155 files changed

+2264
-2974
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+2264
-2974
lines changed

bun.lock

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"lockfileVersion": 1,
3+
"configVersion": 0,
34
"workspaces": {
45
"": {
56
"name": "eliza",
@@ -28,6 +29,7 @@
2829
"@elizaos/core": "workspace:*",
2930
},
3031
"devDependencies": {
32+
"@elizaos/config": "workspace:*",
3133
"@types/bun": "^1.2.21",
3234
"@types/node": "latest",
3335
"eslint": "^9.36.0",
@@ -47,6 +49,7 @@
4749
"react-dom": "^19.1.0",
4850
},
4951
"devDependencies": {
52+
"@elizaos/config": "workspace:*",
5053
"@tauri-apps/cli": "^2.6.2",
5154
"@types/react": "^19.1.5",
5255
"@types/react-dom": "^19.1.6",
@@ -95,6 +98,7 @@
9598
"zod": "4.1.11",
9699
},
97100
"devDependencies": {
101+
"@elizaos/config": "workspace:*",
98102
"@types/bun": "^1.2.21",
99103
"@types/express": "^5.0.2",
100104
"@types/fs-extra": "^11.0.1",
@@ -172,6 +176,7 @@
172176
"devDependencies": {
173177
"@cypress/react": "^9.0.1",
174178
"@cypress/vite-dev-server": "^7.0.0",
179+
"@elizaos/config": "workspace:*",
175180
"@eslint/js": "^9.22.0",
176181
"@happy-dom/global-registrator": "^19.0.2",
177182
"@playwright/test": "^1.40.0",
@@ -232,6 +237,7 @@
232237
"adze": "^2.2.5",
233238
"crypto-browserify": "^3.12.0",
234239
"dotenv": "17.2.3",
240+
"fast-redact": "^3.5.0",
235241
"glob": "11.0.3",
236242
"handlebars": "^4.7.8",
237243
"pdfjs-dist": "^5.2.133",
@@ -240,7 +246,9 @@
240246
"zod": "4.1.11",
241247
},
242248
"devDependencies": {
249+
"@elizaos/config": "workspace:*",
243250
"@types/bun": "^1.2.21",
251+
"@types/fast-redact": "^3.0.4",
244252
"@types/node": "^24.0.3",
245253
"@types/uuid": "11.0.0",
246254
"prettier": "3.6.2",
@@ -266,6 +274,7 @@
266274
"bun": "^1.2.21",
267275
},
268276
"devDependencies": {
277+
"@elizaos/config": "workspace:*",
269278
"@types/bun": "^1.2.21",
270279
"@types/node": "^22.15.3",
271280
"prettier": "3.5.3",
@@ -284,6 +293,7 @@
284293
"uuid": "^9.0.0",
285294
},
286295
"devDependencies": {
296+
"@elizaos/config": "workspace:*",
287297
"prettier": "3.5.3",
288298
"typescript": "5.8.2",
289299
},
@@ -318,6 +328,7 @@
318328
"uuid": "^11.0.5",
319329
},
320330
"devDependencies": {
331+
"@elizaos/config": "workspace:*",
321332
"@eslint/js": "^9.28.0",
322333
"@types/node": "^24.0.3",
323334
"@types/pg": "8.15.4",
@@ -430,6 +441,7 @@
430441
},
431442
"devDependencies": {
432443
"@elizaos/client": "workspace:*",
444+
"@elizaos/config": "workspace:*",
433445
"@types/bcrypt": "^6.0.0",
434446
"@types/node": "^24.0.1",
435447
"bun-fetch-mock": "^1.0.0",
@@ -447,6 +459,7 @@
447459
"@elizaos/core": "workspace:*",
448460
},
449461
"devDependencies": {
462+
"@elizaos/config": "workspace:*",
450463
"@types/bun": "^1.2.21",
451464
"prettier": "^3.4.2",
452465
"typescript": "^5.7.3",
@@ -463,6 +476,7 @@
463476
"zod": "3.24.2",
464477
},
465478
"devDependencies": {
479+
"@elizaos/config": "workspace:*",
466480
"dotenv": "16.4.5",
467481
"prettier": "3.5.3",
468482
"typescript": "5.8.2",
@@ -1475,6 +1489,8 @@
14751489

14761490
"@types/express-serve-static-core": ["@types/[email protected]", "", { "dependencies": { "@types/node": "*", "@types/qs": "*", "@types/range-parser": "*", "@types/send": "*" } }, "sha512-jnHMsrd0Mwa9Cf4IdOzbz543y4XJepXrbia2T4b6+spXC2We3t1y6K44D3mR8XMFSXMCf3/l7rCgddfx7UNVBA=="],
14771491

1492+
"@types/fast-redact": ["@types/[email protected]", "", {}, "sha512-tgGJaXucrCH4Yx2l/AI6e/JQksZhKGIQsVwBMTh+nxUhQDv5tXScTs5DHTw+qSKDXnHL2dTAh1e2rd5pcFQyNQ=="],
1493+
14781494
"@types/fs-extra": ["@types/[email protected]", "", { "dependencies": { "@types/jsonfile": "*", "@types/node": "*" } }, "sha512-yTbItCNreRooED33qjunPthRcSjERP1r4MqCZc7wv0u2sUkzTFp45tgUfS5+r7FrZPdmCCNflLhVSP/o+SemsQ=="],
14791495

14801496
"@types/geojson": ["@types/[email protected]", "", {}, "sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg=="],
@@ -2407,6 +2423,8 @@
24072423

24082424
"fast-levenshtein": ["[email protected]", "", {}, "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw=="],
24092425

2426+
"fast-redact": ["[email protected]", "", {}, "sha512-dwsoQlS7h9hMeYUq1W++23NDcBLV4KqONnITDV9DjfS3q1SgDGVrBdvvTLUotWtPSD7asWDV9/CmsZPy8Hf70A=="],
2427+
24102428
"fast-stable-stringify": ["[email protected]", "", {}, "sha512-wpYMUmFu5f00Sm0cj2pfivpmawLZ0NKdviQ4w9zJeR8JVtOpOxHmLaJuj0vxvGqMJQWyP/COUkF75/57OKyRag=="],
24112429

24122430
"fastq": ["[email protected]", "", { "dependencies": { "reusify": "^1.0.4" } }, "sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ=="],
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import pluginConfig from '@elizaos/config/eslint/eslint.config.plugin.js';
2+
3+
export default pluginConfig;

packages/api-client/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
"dev": "bun run build.ts --watch",
1212
"test": "bun test",
1313
"test:watch": "bun test --watch",
14-
"lint": "prettier --write ./src",
14+
"lint": "eslint src/ && prettier --write ./src",
15+
"lint:check": "eslint src/",
1516
"typecheck": "tsc --noEmit"
1617
},
1718
"dependencies": {
1819
"@elizaos/core": "workspace:*"
1920
},
2021
"devDependencies": {
22+
"@elizaos/config": "workspace:*",
2123
"@types/bun": "^1.2.21",
2224
"@types/node": "latest",
2325
"eslint": "^9.36.0",

packages/app/eslint.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import pluginConfig from '@elizaos/config/eslint/eslint.config.plugin.js';
2+
3+
export default pluginConfig;

packages/app/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"typecheck": "tsc --noEmit",
1515
"format": "prettier --write ./src",
1616
"format:check": "prettier --check ./src",
17-
"lint": "prettier --write ./src"
17+
"lint": "eslint src/ && prettier --write ./src",
18+
"lint:check": "eslint src/"
1819
},
1920
"dependencies": {
2021
"@elizaos/api-client": "workspace:*",
@@ -26,6 +27,7 @@
2627
"react-dom": "^19.1.0"
2728
},
2829
"devDependencies": {
30+
"@elizaos/config": "workspace:*",
2931
"@tauri-apps/cli": "^2.6.2",
3032
"@types/react": "^19.1.5",
3133
"@types/react-dom": "^19.1.6",

packages/cli/eslint.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import pluginConfig from '@elizaos/config/eslint/eslint.config.plugin.js';
2+
3+
export default pluginConfig;

packages/cli/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
"scripts": {
4444
"start": "bun run build && bun dist/index.js start",
4545
"build": "bun run build.ts",
46-
"lint": "prettier --write ./src",
46+
"lint": "eslint src/ && prettier --write ./src",
47+
"lint:check": "eslint src/",
4748
"format": "prettier --write ./src",
4849
"format:check": "prettier --check ./src",
4950
"clean": "rm -rf dist .turbo node_modules .turbo-tsconfig.json *.tsbuildinfo",
@@ -65,6 +66,7 @@
6566
"test:scenarios": "for f in src/commands/scenario/examples/*.scenario.yaml; do echo \"=== $f ===\"; bun dist/index.js scenario run \"$f\" || echo \"FAIL $f\"; echo; done | cat"
6667
},
6768
"devDependencies": {
69+
"@elizaos/config": "workspace:*",
6870
"@types/bun": "^1.2.21",
6971
"@types/express": "^5.0.2",
7072
"@types/fs-extra": "^11.0.1",

packages/cli/src/commands/agent/actions/lifecycle.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ export async function startAgent(options: OptionValues): Promise<void> {
5454
const agent = await agentsService.createAgent(payload);
5555
return agent.name || agent.id;
5656
} catch (error) {
57-
logger.error(
58-
`Failed to create agent: ${error instanceof Error ? error.message : String(error)}`
59-
);
57+
logger.error({ src: 'cli', command: 'agent-start', error: error instanceof Error ? error.message : String(error) }, 'Failed to create agent');
6058
return null;
6159
}
6260
}
@@ -72,7 +70,7 @@ export async function startAgent(options: OptionValues): Promise<void> {
7270
payload.characterJson = JSON.parse(fileContent);
7371
characterName = await createCharacter(payload);
7472
if (!characterName) {
75-
logger.error('Failed to create character from file. Check server logs for details.');
73+
logger.error({ src: 'cli', command: 'agent-start' }, 'Failed to create character from file. Check server logs for details');
7674
}
7775
} catch (error) {
7876
console.error('Error reading or parsing local JSON file:', error);
@@ -93,9 +91,7 @@ export async function startAgent(options: OptionValues): Promise<void> {
9391
payload.characterPath = options.remoteCharacter;
9492
characterName = await createCharacter(payload);
9593
if (!characterName) {
96-
logger.error(
97-
'Failed to create character from remote URL. Check server logs for details.'
98-
);
94+
logger.error({ src: 'cli', command: 'agent-start' }, 'Failed to create character from remote URL. Check server logs for details');
9995
}
10096
}
10197

@@ -213,13 +209,13 @@ export async function stopAgent(opts: OptionValues): Promise<void> {
213209

214210
// If --all flag is provided, stop all local ElizaOS processes
215211
if (opts.all) {
216-
logger.info('Stopping all ElizaOS agents...');
212+
logger.info({ src: 'cli', command: 'agent-stop' }, 'Stopping all ElizaOS agents');
217213

218214
// Check platform compatibility
219215
if (process.platform === 'win32') {
220-
logger.error('The --all flag requires Unix-like commands (pgrep, kill).');
221-
logger.error('On Windows, please use WSL 2 or stop agents individually with --name.');
222-
logger.error('See: https://learn.microsoft.com/en-us/windows/wsl/install-manual');
216+
logger.error({ src: 'cli', command: 'agent-stop' }, 'The --all flag requires Unix-like commands (pgrep, kill)');
217+
logger.error({ src: 'cli', command: 'agent-stop' }, 'On Windows, please use WSL 2 or stop agents individually with --name');
218+
logger.error({ src: 'cli', command: 'agent-stop', url: 'https://learn.microsoft.com/en-us/windows/wsl/install-manual' }, 'See WSL installation guide');
223219
process.exit(1);
224220
}
225221

@@ -251,11 +247,9 @@ export async function stopAgent(opts: OptionValues): Promise<void> {
251247
}
252248
}
253249

254-
logger.success('All ElizaOS agents stopped successfully!');
250+
logger.success({ src: 'cli', command: 'agent-stop' }, 'All ElizaOS agents stopped successfully');
255251
} catch (error) {
256-
logger.error(
257-
`Error stopping processes: ${error instanceof Error ? error.message : String(error)}`
258-
);
252+
logger.error({ src: 'cli', command: 'agent-stop', error: error instanceof Error ? error.message : String(error) }, 'Error stopping processes');
259253
process.exit(1);
260254
}
261255
return;

packages/cli/src/commands/containers/actions/delete.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ export async function deleteContainerAction(
3333
const apiUrl = options.apiUrl || 'https://www.elizacloud.ai';
3434

3535
if (!apiKey) {
36-
logger.error(
37-
'❌ Error: API key is required. Use --api-key or set ELIZA_SERVER_AUTH_TOKEN environment variable.'
38-
);
36+
logger.error({ src: 'cli', command: 'containers-delete' }, 'API key is required. Use --api-key or set ELIZA_SERVER_AUTH_TOKEN environment variable');
3937
process.exit(1);
4038
}
4139

@@ -46,7 +44,7 @@ export async function deleteContainerAction(
4644

4745
if (!targetContainerId) {
4846
projectName = options.projectName || path.basename(process.cwd());
49-
logger.info(`🔍 Auto-detecting container for project "${projectName}"...`);
47+
logger.info({ src: 'cli', command: 'containers-delete', projectName }, 'Auto-detecting container for project');
5048

5149
// Fetch all containers
5250
const listResponse = await fetch(`${apiUrl}/api/v1/containers`, {
@@ -69,25 +67,25 @@ export async function deleteContainerAction(
6967
const matchingContainer = containers.find((c) => c.project_name === projectName);
7068

7169
if (!matchingContainer) {
72-
logger.error(`❌ Error: No container found for project "${projectName}"`);
73-
logger.info(`\n💡 Available projects:`);
70+
logger.error({ src: 'cli', command: 'containers-delete', projectName }, 'No container found for project');
71+
logger.info({ src: 'cli', command: 'containers-delete' }, 'Available projects:');
7472
const uniqueProjects = [...new Set(containers.map((c) => c.project_name))];
7573
uniqueProjects.forEach((proj) => {
76-
logger.info(` - ${proj}`);
74+
logger.info({ src: 'cli', command: 'containers-delete', project: proj }, ' - ' + proj);
7775
});
78-
logger.info(`\nRun "elizaos containers list" to see all containers.`);
76+
logger.info({ src: 'cli', command: 'containers-delete' }, 'Run "elizaos containers list" to see all containers');
7977
process.exit(1);
8078
}
8179

8280
targetContainerId = matchingContainer.id;
8381
containerName = matchingContainer.name;
84-
logger.info(`✅ Found container: ${containerName} (${targetContainerId})`);
82+
logger.info({ src: 'cli', command: 'containers-delete', containerName, containerId: targetContainerId }, 'Found container');
8583
}
8684

8785
if (!options.force && containerName) {
8886
const confirmed = await confirmDeletion(containerName, projectName);
8987
if (!confirmed) {
90-
logger.info('❌ Deletion cancelled.');
88+
logger.info({ src: 'cli', command: 'containers-delete' }, 'Deletion cancelled');
9189
return;
9290
}
9391
} else if (!options.force) {
@@ -105,13 +103,13 @@ export async function deleteContainerAction(
105103
const container: Container = detailsResult.data;
106104
const confirmed = await confirmDeletion(container.name, container.project_name);
107105
if (!confirmed) {
108-
logger.info('❌ Deletion cancelled.');
106+
logger.info({ src: 'cli', command: 'containers-delete' }, 'Deletion cancelled');
109107
return;
110108
}
111109
}
112110
}
113111

114-
logger.info(`🗑️ Deleting container ${targetContainerId}...`);
112+
logger.info({ src: 'cli', command: 'containers-delete', containerId: targetContainerId }, 'Deleting container');
115113

116114
const response = await fetch(`${apiUrl}/api/v1/containers/${targetContainerId}`, {
117115
method: 'DELETE',
@@ -126,12 +124,10 @@ export async function deleteContainerAction(
126124
throw new Error(errorData.error || `Failed to delete container: ${response.statusText}`);
127125
}
128126

129-
logger.info(`✅ Container ${targetContainerId} deleted successfully.`);
130-
logger.info('ℹ️ Note: CloudFormation stack deletion may take a few minutes to complete.');
127+
logger.info({ src: 'cli', command: 'containers-delete', containerId: targetContainerId }, 'Container deleted successfully');
128+
logger.info({ src: 'cli', command: 'containers-delete' }, 'Note: CloudFormation stack deletion may take a few minutes to complete');
131129
} catch (error: unknown) {
132-
logger.error(
133-
`❌ Error: ${error instanceof Error ? error.message : 'Failed to delete container'}`
134-
);
130+
logger.error({ src: 'cli', command: 'containers-delete', error: error instanceof Error ? error.message : 'Failed to delete container' }, 'Error deleting container');
135131
process.exit(1);
136132
}
137133
}

packages/cli/src/commands/containers/actions/list.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ export async function listContainersAction(options: ContainersOptions) {
1111
const apiUrl = options.apiUrl || 'https://www.elizacloud.ai';
1212

1313
if (!apiKey) {
14-
logger.error(
15-
'❌ Error: API key is required. Use --api-key or set ELIZA_SERVER_AUTH_TOKEN environment variable.'
16-
);
14+
logger.error({ src: 'cli', command: 'containers-list' }, 'API key is required. Use --api-key or set ELIZA_SERVER_AUTH_TOKEN environment variable');
1715
process.exit(1);
1816
}
1917

20-
logger.info('📋 Fetching container list...');
18+
logger.info({ src: 'cli', command: 'containers-list' }, 'Fetching container list');
2119

2220
const response = await fetch(`${apiUrl}/api/v1/containers`, {
2321
method: 'GET',
@@ -41,11 +39,11 @@ export async function listContainersAction(options: ContainersOptions) {
4139
}
4240

4341
if (containers.length === 0) {
44-
logger.info('\n📦 No containers found.\n');
42+
logger.info({ src: 'cli', command: 'containers-list' }, 'No containers found');
4543
return;
4644
}
4745

48-
logger.info(`\n📦 Found ${containers.length} container(s):\n`);
46+
logger.info({ src: 'cli', command: 'containers-list', count: containers.length }, 'Found containers');
4947

5048
for (const container of containers) {
5149
console.log(` ID: ${container.id}`);
@@ -65,9 +63,7 @@ export async function listContainersAction(options: ContainersOptions) {
6563
console.log('');
6664
}
6765
} catch (error: unknown) {
68-
logger.error(
69-
`❌ Error: ${error instanceof Error ? error.message : 'Failed to list containers'}`
70-
);
66+
logger.error({ src: 'cli', command: 'containers-list', error: error instanceof Error ? error.message : 'Failed to list containers' }, 'Error listing containers');
7167
process.exit(1);
7268
}
7369
}

0 commit comments

Comments
 (0)