mcp-grocy 2.5.0 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +28 -4
  2. package/README.md +13 -0
  3. package/build/resources/CHANGELOG.md +30 -4
  4. package/build/resources/README.md +13 -0
  5. package/build/resources/config.md +21 -4
  6. package/build/resources/response-format.md +12 -8
  7. package/package.json +14 -2
  8. package/build/api/client.js +0 -119
  9. package/build/config/index.js +0 -259
  10. package/build/main.js +0 -44
  11. package/build/server/http-server.js +0 -330
  12. package/build/server/mcp-server.js +0 -210
  13. package/build/server/resources.js +0 -73
  14. package/build/server/tool-input-zod.js +0 -86
  15. package/build/tools/base.js +0 -145
  16. package/build/tools/household/definitions.js +0 -161
  17. package/build/tools/household/handlers.js +0 -109
  18. package/build/tools/household/index.js +0 -25
  19. package/build/tools/index.js +0 -2
  20. package/build/tools/inventory/definitions.js +0 -416
  21. package/build/tools/inventory/handlers.js +0 -443
  22. package/build/tools/inventory/index.js +0 -32
  23. package/build/tools/module-loader.js +0 -154
  24. package/build/tools/recipes/definitions.js +0 -278
  25. package/build/tools/recipes/handlers.js +0 -477
  26. package/build/tools/recipes/index.js +0 -33
  27. package/build/tools/recipes/validations.js +0 -29
  28. package/build/tools/shopping/definitions.js +0 -73
  29. package/build/tools/shopping/handlers.js +0 -43
  30. package/build/tools/shopping/index.js +0 -14
  31. package/build/tools/system/definitions.js +0 -89
  32. package/build/tools/system/handlers.js +0 -156
  33. package/build/tools/system/index.js +0 -16
  34. package/build/tools/types.js +0 -1
  35. package/build/tools/validation-helpers.js +0 -39
  36. package/build/types/index.js +0 -64
  37. package/build/utils/errors.js +0 -143
  38. package/build/utils/logger.js +0 -142
@@ -1,89 +0,0 @@
1
- import { config } from '../../config/index.js';
2
- export const systemToolDefinitions = [
3
- // ==================== CORE SYSTEM UTILITIES ====================
4
- {
5
- name: 'system_locations_get',
6
- description: '[SYSTEM/LOCATIONS] Get **home storage / stock** locations (freezer, pantry, fridge—where inventory lives). NOT retail stores—use shopping_locations_get for shop/store IDs (storeId). Use this for locationId on stock, transfers, and purchases.',
7
- annotations: { readOnlyHint: true },
8
- inputSchema: {
9
- type: 'object',
10
- properties: {},
11
- required: [],
12
- },
13
- },
14
- {
15
- name: 'system_units_get',
16
- description: '[SYSTEM/UNITS] Get all quantity units from your Grocy instance.',
17
- annotations: { readOnlyHint: true },
18
- inputSchema: {
19
- type: 'object',
20
- properties: {},
21
- required: [],
22
- },
23
- },
24
- {
25
- name: 'system_users_get',
26
- description: '[SYSTEM/USERS] Get all users from your Grocy instance.',
27
- annotations: { readOnlyHint: true },
28
- inputSchema: {
29
- type: 'object',
30
- properties: {},
31
- required: [],
32
- },
33
- },
34
- // ==================== DEVELOPER UTILITIES ====================
35
- {
36
- name: 'system_dev_call_api',
37
- description: '[SYSTEM/DEV] Call a specific Grocy API endpoint with custom parameters.',
38
- inputSchema: {
39
- type: 'object',
40
- properties: {
41
- endpoint: {
42
- type: 'string',
43
- description: 'Grocy API endpoint to call (e.g., "objects/products"). Do not include /api/ prefix.',
44
- },
45
- method: {
46
- type: 'string',
47
- enum: ['GET', 'POST', 'PUT', 'DELETE'],
48
- description: 'HTTP method to use',
49
- default: 'GET',
50
- },
51
- body: {
52
- type: 'object',
53
- description: 'Optional request body for POST/PUT requests',
54
- },
55
- },
56
- required: ['endpoint'],
57
- },
58
- },
59
- {
60
- name: 'system_dev_test_request',
61
- description: `[SYSTEM/DEV] Test a REST API endpoint and get detailed response information. Base URL: ${config.grocy.base_url} | SSL Verification enabled | Authentication: ${config.grocy.api_key ? 'API Key using header: GROCY-API-KEY' : 'No authentication configured'}`,
62
- inputSchema: {
63
- type: 'object',
64
- properties: {
65
- method: {
66
- type: 'string',
67
- enum: ['GET', 'POST', 'PUT', 'DELETE'],
68
- description: 'HTTP method to use',
69
- },
70
- endpoint: {
71
- type: 'string',
72
- description: 'Endpoint path (e.g. "/users"). Do not include full URLs - only the path.',
73
- },
74
- body: {
75
- type: 'object',
76
- description: 'Optional request body for POST/PUT requests',
77
- },
78
- headers: {
79
- type: 'object',
80
- description: 'Optional request headers for one-time use.',
81
- additionalProperties: {
82
- type: 'string',
83
- },
84
- },
85
- },
86
- required: ['method', 'endpoint'],
87
- },
88
- },
89
- ];
@@ -1,156 +0,0 @@
1
- import { BaseToolHandler } from '../base.js';
2
- import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
3
- import apiClient from '../../api/client.js';
4
- import { config } from '../../config/index.js';
5
- import { logger } from '../../utils/logger.js';
6
- export class SystemToolHandlers extends BaseToolHandler {
7
- redactHeaders(headers) {
8
- const redacted = { ...headers };
9
- const sensitiveHeaders = new Set([
10
- 'grocy-api-key',
11
- 'authorization',
12
- 'x-api-key',
13
- 'proxy-authorization',
14
- ]);
15
- for (const key of Object.keys(redacted)) {
16
- if (sensitiveHeaders.has(key.toLowerCase())) {
17
- redacted[key] = '[REDACTED]';
18
- }
19
- }
20
- return redacted;
21
- }
22
- /**
23
- * Truncate a string to at most `maxBytes` UTF-8 bytes without splitting a codepoint.
24
- */
25
- truncateStringToUtf8Bytes(str, maxBytes) {
26
- const buf = Buffer.from(str, 'utf8');
27
- if (buf.length <= maxBytes) {
28
- return { text: str, byteLength: buf.length };
29
- }
30
- let end = maxBytes;
31
- while (end > 0) {
32
- while (end > 0 && (buf[end - 1] & 0xc0) === 0x80) {
33
- end--;
34
- }
35
- if (end === 0) {
36
- break;
37
- }
38
- const text = buf.subarray(0, end).toString('utf8');
39
- if (Buffer.byteLength(text, 'utf8') === end) {
40
- return { text, byteLength: end };
41
- }
42
- end--;
43
- }
44
- return { text: '', byteLength: 0 };
45
- }
46
- applyResponseSizeLimit(body) {
47
- const sizeLimit = config.grocy.response_size_limit;
48
- const jsonBody = JSON.stringify(body);
49
- const originalSize = Buffer.byteLength(jsonBody, 'utf8');
50
- if (originalSize <= sizeLimit) {
51
- return { body };
52
- }
53
- const { text: truncatedJsonBody, byteLength: prefixBytes } = this.truncateStringToUtf8Bytes(jsonBody, sizeLimit);
54
- const returnedSize = Buffer.byteLength(truncatedJsonBody, 'utf8');
55
- return {
56
- body: `${truncatedJsonBody}...[TRUNCATED]`,
57
- truncated: {
58
- originalSize,
59
- returnedSize,
60
- truncationPoint: prefixBytes,
61
- sizeLimit,
62
- },
63
- };
64
- }
65
- // ==================== CORE SYSTEM UTILITIES ====================
66
- getLocations = async () => {
67
- return this.executeToolHandler(async () => {
68
- const data = await this.apiCall('/objects/locations');
69
- return this.createSuccess(data);
70
- });
71
- };
72
- getQuantityUnits = async () => {
73
- return this.executeToolHandler(async () => {
74
- const data = await this.apiCall('/objects/quantity_units');
75
- return this.createSuccess(data);
76
- });
77
- };
78
- getUsers = async () => {
79
- return this.executeToolHandler(async () => {
80
- const data = await this.apiCall('/users');
81
- return this.createSuccess(data);
82
- });
83
- };
84
- // ==================== DEVELOPER UTILITIES ====================
85
- callGrocyApi = async (args) => {
86
- const { endpoint, method = 'GET', body = null } = args;
87
- if (!endpoint) {
88
- throw new McpError(ErrorCode.InvalidParams, 'Missing required parameter: endpoint');
89
- }
90
- // Remove leading /api/ if present
91
- const cleanEndpoint = endpoint.replace(/^\/?(?:api\/)?/, '');
92
- try {
93
- const response = await apiClient.request(`/${cleanEndpoint}`, {
94
- method,
95
- body,
96
- });
97
- return this.createSuccess(response.data);
98
- }
99
- catch (error) {
100
- logger.error(`Error calling Grocy API endpoint ${endpoint}`, 'api', { error });
101
- return this.createError(`Failed to call Grocy API endpoint ${endpoint}: ${error.message}`);
102
- }
103
- };
104
- testRequest = async (args) => {
105
- const { method, endpoint, body, headers = {} } = args;
106
- if (!method || !endpoint) {
107
- throw new McpError(ErrorCode.InvalidParams, 'method and endpoint are required');
108
- }
109
- const normalizedEndpoint = `/${endpoint.replace(/^\/+|\/+$/g, '')}`;
110
- const requestHeaders = { ...config.getCustomHeaders(), ...headers };
111
- const safeRequestHeaders = this.redactHeaders(requestHeaders);
112
- try {
113
- const startTime = Date.now();
114
- const response = await apiClient.request(normalizedEndpoint, {
115
- method,
116
- body,
117
- headers: requestHeaders,
118
- });
119
- const endTime = Date.now();
120
- const responseWithLimit = this.applyResponseSizeLimit(response.data);
121
- const responseObj = {
122
- request: {
123
- url: `${config.grocy.base_url}${normalizedEndpoint}`,
124
- method,
125
- headers: safeRequestHeaders,
126
- body,
127
- authMethod: config.grocy.api_key ? 'apikey' : 'none',
128
- },
129
- response: {
130
- statusCode: response.status,
131
- timing: `${endTime - startTime}ms`,
132
- headers: response.headers,
133
- body: responseWithLimit.body,
134
- },
135
- validation: {
136
- isError: response.status >= 400,
137
- messages: response.status >= 400
138
- ? [`Request failed with status ${response.status}`]
139
- : ['Request completed successfully'],
140
- ...(responseWithLimit.truncated ? { truncated: responseWithLimit.truncated } : {}),
141
- },
142
- };
143
- return this.createSuccess(responseObj);
144
- }
145
- catch (error) {
146
- return this.createError(`Test request failed: ${error.message}`, {
147
- request: {
148
- url: `${config.grocy.base_url}${normalizedEndpoint}`,
149
- method,
150
- headers: safeRequestHeaders,
151
- body,
152
- },
153
- });
154
- }
155
- };
156
- }
@@ -1,16 +0,0 @@
1
- import { systemToolDefinitions } from './definitions.js';
2
- import { SystemToolHandlers } from './handlers.js';
3
- const handlers = new SystemToolHandlers();
4
- export const systemModule = {
5
- definitions: systemToolDefinitions,
6
- handlers: {
7
- // Core System Utilities
8
- system_locations_get: handlers.getLocations,
9
- system_units_get: handlers.getQuantityUnits,
10
- system_users_get: handlers.getUsers,
11
- // Developer Utilities
12
- system_dev_call_api: handlers.callGrocyApi,
13
- system_dev_test_request: handlers.testRequest,
14
- },
15
- };
16
- export * from './definitions.js';
@@ -1 +0,0 @@
1
- export {};
@@ -1,39 +0,0 @@
1
- /**
2
- * Common validation utility functions
3
- */
4
- import { ValidationError } from '../utils/errors.js';
5
- export class ValidationHelpers {
6
- static validateBoolean(value, fieldName) {
7
- if (value !== undefined && typeof value !== 'boolean') {
8
- throw new ValidationError(`${fieldName} must be a boolean`, 'sub-config validation');
9
- }
10
- }
11
- static validateString(value, fieldName) {
12
- if (value !== undefined && typeof value !== 'string') {
13
- throw new ValidationError(`${fieldName} must be a string`, 'sub-config validation');
14
- }
15
- }
16
- static validateNumber(value, fieldName, options) {
17
- if (value !== undefined) {
18
- if (typeof value !== 'number') {
19
- throw new ValidationError(`${fieldName} must be a number`, 'sub-config validation');
20
- }
21
- if (options?.min !== undefined && value < options.min) {
22
- throw new ValidationError(`${fieldName} must be at least ${options.min}`, 'sub-config validation');
23
- }
24
- if (options?.max !== undefined && value > options.max) {
25
- throw new ValidationError(`${fieldName} must be at most ${options.max}`, 'sub-config validation');
26
- }
27
- }
28
- }
29
- static validateKnownOptions(subConfigs, knownOptions, toolName) {
30
- for (const [key] of subConfigs) {
31
- if (!knownOptions.has(key)) {
32
- const validOptions = Array.from(knownOptions)
33
- .filter((k) => k !== 'ack_token')
34
- .join(', ');
35
- throw new ValidationError(`Unknown sub-configuration option '${key}' for ${toolName} tool. Valid options are: ${validOptions}`, 'sub-config validation');
36
- }
37
- }
38
- }
39
- }
@@ -1,64 +0,0 @@
1
- /**
2
- * Improved type definitions for better type safety
3
- */
4
- import { z } from 'zod';
5
- // Configuration types
6
- export const ConfigSchema = z.object({
7
- env: z.object({
8
- GROCY_API_KEY: z.string().optional(),
9
- RELEASE_VERSION: z.string().optional(),
10
- NODE_ENV: z.enum(['development', 'production', 'test']).optional(),
11
- }),
12
- yaml: z.object({
13
- server: z.object({
14
- enable_http_server: z.boolean().default(false),
15
- http_server_port: z.number().min(1).max(65535).default(8080),
16
- }),
17
- grocy: z.object({
18
- base_url: z.string().url(),
19
- enable_ssl_verify: z.boolean().default(true),
20
- response_size_limit: z.number().positive().default(10000),
21
- }),
22
- tools: z.record(z.string(), z
23
- .object({
24
- enabled: z.boolean().default(false),
25
- ack_token: z.string().optional(),
26
- })
27
- .catchall(z.unknown())),
28
- }),
29
- });
30
- // Validation schemas for runtime type checking
31
- export const ToolResultSchema = z.object({
32
- success: z.boolean(),
33
- data: z.any().optional(),
34
- error: z.string().optional(),
35
- message: z.string().optional(),
36
- details: z.any().optional(),
37
- });
38
- export const ToolDefinitionSchema = z.object({
39
- name: z.string(),
40
- description: z.string(),
41
- inputSchema: z.object({
42
- type: z.literal('object'),
43
- properties: z.record(z.string(), z.any()),
44
- required: z.array(z.string()).optional(),
45
- }),
46
- });
47
- export const ToolModuleSchema = z.object({
48
- definitions: z.array(ToolDefinitionSchema),
49
- handlers: z.record(z.string(), z.custom((v) => typeof v === 'function')),
50
- });
51
- // Type guards
52
- export function isToolResult(obj) {
53
- return ToolResultSchema.safeParse(obj).success;
54
- }
55
- export function isToolDefinition(obj) {
56
- return ToolDefinitionSchema.safeParse(obj).success;
57
- }
58
- export function isToolModule(obj) {
59
- return (obj &&
60
- typeof obj === 'object' &&
61
- Array.isArray(obj.definitions) &&
62
- typeof obj.handlers === 'object' &&
63
- obj.definitions.every((def) => isToolDefinition(def)));
64
- }
@@ -1,143 +0,0 @@
1
- /**
2
- * Simplified error handling system
3
- */
4
- import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
5
- import { logger } from './logger.js';
6
- /**
7
- * Simplified application error
8
- */
9
- export class AppError extends Error {
10
- category;
11
- statusCode;
12
- operation;
13
- details;
14
- timestamp = new Date();
15
- constructor(message, category, statusCode, operation, details) {
16
- super(message);
17
- this.name = 'AppError';
18
- this.category = category;
19
- this.statusCode = statusCode;
20
- this.operation = operation;
21
- this.details = details;
22
- Object.setPrototypeOf(this, AppError.prototype);
23
- }
24
- toMcpError() {
25
- const errorCode = this.getErrorCode();
26
- return new McpError(errorCode, this.message);
27
- }
28
- getErrorCode() {
29
- switch (this.category) {
30
- case 'VALIDATION':
31
- return ErrorCode.InvalidParams;
32
- case 'AUTH':
33
- return ErrorCode.InvalidRequest;
34
- case 'API':
35
- if (this.statusCode === 404)
36
- return ErrorCode.InvalidRequest;
37
- if (this.statusCode === 401 || this.statusCode === 403)
38
- return ErrorCode.InvalidRequest;
39
- return ErrorCode.InternalError;
40
- default:
41
- return ErrorCode.InternalError;
42
- }
43
- }
44
- }
45
- /**
46
- * API-specific error
47
- */
48
- export class ApiError extends AppError {
49
- constructor(message, statusCode, operation, details) {
50
- super(message, 'API', statusCode, operation, details);
51
- this.name = 'ApiError';
52
- }
53
- static fromAxiosError(error, operation) {
54
- if (error.response) {
55
- return new ApiError(error.response.data?.message || `HTTP ${error.response.status}`, error.response.status, operation, { url: error.config?.url, method: error.config?.method });
56
- }
57
- if (error.request) {
58
- return new ApiError('Network error - unable to reach server', undefined, operation, {
59
- url: error.config?.url,
60
- });
61
- }
62
- return new ApiError(error.message || 'Request error', undefined, operation);
63
- }
64
- }
65
- /**
66
- * Validation error
67
- */
68
- export class ValidationError extends AppError {
69
- constructor(message, operation, details) {
70
- super(message, 'VALIDATION', undefined, operation, details);
71
- this.name = 'ValidationError';
72
- }
73
- }
74
- /**
75
- * Configuration error
76
- */
77
- export class ConfigError extends AppError {
78
- constructor(message, operation, details) {
79
- super(message, 'CONFIG', undefined, operation, details);
80
- this.name = 'ConfigError';
81
- }
82
- }
83
- /**
84
- * Centralized error handler
85
- */
86
- export class ErrorHandler {
87
- /**
88
- * Handle async operations with error wrapping
89
- */
90
- static async handleAsync(operation, context) {
91
- try {
92
- return await operation();
93
- }
94
- catch (error) {
95
- this.logError(error, context);
96
- throw this.wrapError(error, context);
97
- }
98
- }
99
- /**
100
- * Log error with context
101
- */
102
- static logError(error, context) {
103
- const errorMessage = error instanceof Error ? error.message : String(error);
104
- const fullContext = context ? `${context}: ${errorMessage}` : errorMessage;
105
- if (error instanceof AppError) {
106
- logger.warn(fullContext, 'ERROR', {
107
- category: error.category,
108
- statusCode: error.statusCode,
109
- operation: error.operation,
110
- details: error.details,
111
- });
112
- }
113
- else {
114
- logger.error(fullContext, 'ERROR', { error });
115
- }
116
- }
117
- /**
118
- * Wrap unknown errors in AppError
119
- */
120
- static wrapError(error, context) {
121
- if (error instanceof AppError) {
122
- return error;
123
- }
124
- if (error instanceof McpError) {
125
- return new AppError(error.message, 'INTERNAL', undefined, context);
126
- }
127
- const message = error instanceof Error ? error.message : String(error);
128
- return new AppError(message, 'INTERNAL', undefined, context);
129
- }
130
- /**
131
- * Convert error to MCP error
132
- */
133
- static toMcpError(error, fallbackMessage = 'Internal error') {
134
- if (error instanceof McpError) {
135
- return error;
136
- }
137
- if (error instanceof AppError) {
138
- return error.toMcpError();
139
- }
140
- const message = error instanceof Error ? error.message : fallbackMessage;
141
- return new McpError(ErrorCode.InternalError, message);
142
- }
143
- }
@@ -1,142 +0,0 @@
1
- /**
2
- * Centralized logging utility with configurable levels and structured output
3
- */
4
- export var LogLevel;
5
- (function (LogLevel) {
6
- LogLevel[LogLevel["ERROR"] = 0] = "ERROR";
7
- LogLevel[LogLevel["WARN"] = 1] = "WARN";
8
- LogLevel[LogLevel["INFO"] = 2] = "INFO";
9
- LogLevel[LogLevel["DEBUG"] = 3] = "DEBUG";
10
- LogLevel[LogLevel["TRACE"] = 4] = "TRACE";
11
- })(LogLevel || (LogLevel = {}));
12
- export class Logger {
13
- static instance;
14
- logLevel;
15
- enabledCategories = null;
16
- constructor() {
17
- // Default to INFO level, but allow override via environment
18
- this.logLevel = this.parseLogLevel(process.env.LOG_LEVEL || 'INFO');
19
- // Allow filtering by categories
20
- const categories = process.env.LOG_CATEGORIES;
21
- if (categories) {
22
- this.enabledCategories = new Set(categories.split(',').map((c) => c.trim().toUpperCase()));
23
- }
24
- }
25
- static getInstance() {
26
- if (!Logger.instance) {
27
- Logger.instance = new Logger();
28
- }
29
- return Logger.instance;
30
- }
31
- parseLogLevel(level) {
32
- const upperLevel = level.toUpperCase();
33
- switch (upperLevel) {
34
- case 'ERROR':
35
- return LogLevel.ERROR;
36
- case 'WARN':
37
- return LogLevel.WARN;
38
- case 'INFO':
39
- return LogLevel.INFO;
40
- case 'DEBUG':
41
- return LogLevel.DEBUG;
42
- case 'TRACE':
43
- return LogLevel.TRACE;
44
- default:
45
- return LogLevel.INFO;
46
- }
47
- }
48
- shouldLog(level, category) {
49
- // Check log level
50
- if (level > this.logLevel) {
51
- return false;
52
- }
53
- // Check category filter
54
- if (this.enabledCategories && category) {
55
- return this.enabledCategories.has(category.toUpperCase());
56
- }
57
- return true;
58
- }
59
- formatMessage(entry) {
60
- const timestamp = entry.timestamp.toISOString();
61
- const level = LogLevel[entry.level].padEnd(5);
62
- const category = entry.category ? `[${entry.category}]` : '';
63
- const data = entry.data ? ` ${JSON.stringify(entry.data)}` : '';
64
- return `${timestamp} ${level} ${category} ${entry.message}${data}`;
65
- }
66
- log(level, message, category, data) {
67
- if (!this.shouldLog(level, category)) {
68
- return;
69
- }
70
- const entry = {
71
- level,
72
- message,
73
- category: category || undefined,
74
- data,
75
- timestamp: new Date(),
76
- };
77
- const formattedMessage = this.formatMessage(entry);
78
- // Use stderr for all logs to avoid interfering with MCP stdio protocol
79
- console.error(formattedMessage);
80
- }
81
- error(message, category, data) {
82
- this.log(LogLevel.ERROR, message, category, data);
83
- }
84
- warn(message, category, data) {
85
- this.log(LogLevel.WARN, message, category, data);
86
- }
87
- info(message, category, data) {
88
- this.log(LogLevel.INFO, message, category, data);
89
- }
90
- debug(message, category, data) {
91
- this.log(LogLevel.DEBUG, message, category, data);
92
- }
93
- trace(message, category, data) {
94
- this.log(LogLevel.TRACE, message, category, data);
95
- }
96
- // Convenience methods for common categories
97
- config(message, data) {
98
- this.info(message, 'CONFIG', data);
99
- }
100
- api(message, data) {
101
- this.debug(message, 'API', data);
102
- }
103
- module(message, data) {
104
- this.debug(message, 'MODULE', data);
105
- }
106
- tools(message, data) {
107
- this.info(message, 'TOOLS', data);
108
- }
109
- server(message, data) {
110
- this.info(message, 'SERVER', data);
111
- }
112
- // Testing utilities
113
- setLogLevel(level) {
114
- this.logLevel = level;
115
- }
116
- setEnabledCategories(categories) {
117
- this.enabledCategories = categories ? new Set(categories.map((c) => c.toUpperCase())) : null;
118
- }
119
- }
120
- // Export singleton instance
121
- export const logger = Logger.getInstance();
122
- // Convenience function for quick logging
123
- export function log(level, message, category, data) {
124
- // Access the private log method through the public methods
125
- switch (level) {
126
- case LogLevel.ERROR:
127
- logger.error(message, category, data);
128
- break;
129
- case LogLevel.WARN:
130
- logger.warn(message, category, data);
131
- break;
132
- case LogLevel.INFO:
133
- logger.info(message, category, data);
134
- break;
135
- case LogLevel.DEBUG:
136
- logger.debug(message, category, data);
137
- break;
138
- case LogLevel.TRACE:
139
- logger.trace(message, category, data);
140
- break;
141
- }
142
- }