Skip to content

agent-plugin-logging / Exports / LoggingPlugin

Class: LoggingPlugin

Logs agent operations using configurable storage backends.

Supports console, file, remote, and silent strategies with configurable log levels and optional formatting via ILogFormatter implementations.

Lifecycle hooks used: AbstractPlugin.onModuleEvent | onModuleEvent

See

  • ILogStorage - storage backend contract
  • ILogFormatter - log formatting contract
  • ILoggingPluginOptions - configuration options

Example

ts
const plugin = new LoggingPlugin({
  strategy: 'console',
  level: 'info',
});
await plugin.info('Agent started');

Hierarchy

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new LoggingPlugin(options): LoggingPlugin

Parameters

NameType
optionsILoggingPluginOptions

Returns

LoggingPlugin

Overrides

AbstractPlugin<ILoggingPluginOptions, ILoggingPluginStats>.constructor

Defined in

agent-plugin-logging/src/logging-plugin.ts:89

Properties

enabled

enabled: boolean

Inherited from

AbstractPlugin.enabled

Defined in

agent-core/dist/node/index.d.ts:1049


category

category: PluginCategory

Inherited from

AbstractPlugin.category

Defined in

agent-core/dist/node/index.d.ts:1050


priority

priority: number

Inherited from

AbstractPlugin.priority

Defined in

agent-core/dist/node/index.d.ts:1051


name

name: string = 'LoggingPlugin'

Overrides

AbstractPlugin.name

Defined in

agent-plugin-logging/src/logging-plugin.ts:77


version

version: string = '1.0.0'

Overrides

AbstractPlugin.version

Defined in

agent-plugin-logging/src/logging-plugin.ts:78

Methods

initialize

initialize(options?): Promise<void>

Parameters

NameType
options?ILoggingPluginOptions

Returns

Promise<void>

Inherited from

AbstractPlugin.initialize

Defined in

agent-core/dist/node/index.d.ts:1063


subscribeToModuleEvents

subscribeToModuleEvents(eventEmitter): Promise<void>

Parameters

NameType
eventEmitterIEventEmitterPlugin

Returns

Promise<void>

Inherited from

AbstractPlugin.subscribeToModuleEvents

Defined in

agent-core/dist/node/index.d.ts:1064


unsubscribeFromModuleEvents

unsubscribeFromModuleEvents(eventEmitter): Promise<void>

Parameters

NameType
eventEmitterIEventEmitterPlugin

Returns

Promise<void>

Inherited from

AbstractPlugin.unsubscribeFromModuleEvents

Defined in

agent-core/dist/node/index.d.ts:1065


dispose

dispose(): Promise<void>

Returns

Promise<void>

Inherited from

AbstractPlugin.dispose

Defined in

agent-core/dist/node/index.d.ts:1066


enable

enable(): void

Returns

void

Inherited from

AbstractPlugin.enable

Defined in

agent-core/dist/node/index.d.ts:1067


disable

disable(): void

Returns

void

Inherited from

AbstractPlugin.disable

Defined in

agent-core/dist/node/index.d.ts:1068


isEnabled

isEnabled(): boolean

Returns

boolean

Inherited from

AbstractPlugin.isEnabled

Defined in

agent-core/dist/node/index.d.ts:1069


getConfig

getConfig(): IPluginConfig

Returns

IPluginConfig

Inherited from

AbstractPlugin.getConfig

Defined in

agent-core/dist/node/index.d.ts:1070


updateConfig

updateConfig(_config): void

Parameters

NameType
_configIPluginConfig

Returns

void

Inherited from

AbstractPlugin.updateConfig

Defined in

agent-core/dist/node/index.d.ts:1071


getData

getData(): IPluginData

Returns

IPluginData

Inherited from

AbstractPlugin.getData

Defined in

agent-core/dist/node/index.d.ts:1072


clearData

clearData(): void

Returns

void

Inherited from

AbstractPlugin.clearData

Defined in

agent-core/dist/node/index.d.ts:1073


getStatus

getStatus(): Object

Returns

Object

NameType
namestring
versionstring
enabledboolean
initializedboolean
categoryPluginCategory
prioritynumber
subscribedEventsCountnumber
hasEventEmitterboolean

Inherited from

AbstractPlugin.getStatus

Defined in

agent-core/dist/node/index.d.ts:1074


getStats

getStats(): ILoggingPluginStats

Returns

ILoggingPluginStats

Inherited from

AbstractPlugin.getStats

Defined in

agent-core/dist/node/index.d.ts:1084


beforeRun

beforeRun(input, options?): Promise<void>

Parameters

NameType
inputstring
options?IRunOptions

Returns

Promise<void>

Inherited from

AbstractPlugin.beforeRun

Defined in

agent-core/dist/node/index.d.ts:1087


afterRun

afterRun(input, response, options?): Promise<void>

Parameters

NameType
inputstring
responsestring
options?IRunOptions

Returns

Promise<void>

Inherited from

AbstractPlugin.afterRun

Defined in

agent-core/dist/node/index.d.ts:1088


beforeExecution

beforeExecution(context): Promise<void>

Parameters

NameType
contextIPluginExecutionContext

Returns

Promise<void>

Inherited from

AbstractPlugin.beforeExecution

Defined in

agent-core/dist/node/index.d.ts:1089


afterExecution

afterExecution(context, result): Promise<void>

Parameters

NameType
contextIPluginExecutionContext
resultIPluginExecutionResult

Returns

Promise<void>

Inherited from

AbstractPlugin.afterExecution

Defined in

agent-core/dist/node/index.d.ts:1090


beforeConversation

beforeConversation(context): Promise<void>

Parameters

NameType
contextIPluginExecutionContext

Returns

Promise<void>

Inherited from

AbstractPlugin.beforeConversation

Defined in

agent-core/dist/node/index.d.ts:1091


afterConversation

afterConversation(context, result): Promise<void>

Parameters

NameType
contextIPluginExecutionContext
resultIPluginExecutionResult

Returns

Promise<void>

Inherited from

AbstractPlugin.afterConversation

Defined in

agent-core/dist/node/index.d.ts:1092


beforeToolCall

beforeToolCall(toolName, parameters): Promise<void>

Parameters

NameType
toolNamestring
parametersTToolParameters

Returns

Promise<void>

Inherited from

AbstractPlugin.beforeToolCall

Defined in

agent-core/dist/node/index.d.ts:1093


beforeToolExecution

beforeToolExecution(context, toolData): Promise<void>

Parameters

NameType
contextIPluginExecutionContext
toolDataIToolExecutionContext

Returns

Promise<void>

Inherited from

AbstractPlugin.beforeToolExecution

Defined in

agent-core/dist/node/index.d.ts:1094


afterToolCall

afterToolCall(toolName, parameters, result): Promise<void>

Parameters

NameType
toolNamestring
parametersTToolParameters
resultIToolExecutionResult

Returns

Promise<void>

Inherited from

AbstractPlugin.afterToolCall

Defined in

agent-core/dist/node/index.d.ts:1095


afterToolExecution

afterToolExecution(context, toolResults): Promise<void>

Parameters

NameType
contextIPluginExecutionContext
toolResultsIPluginExecutionResult

Returns

Promise<void>

Inherited from

AbstractPlugin.afterToolExecution

Defined in

agent-core/dist/node/index.d.ts:1096


beforeProviderCall

beforeProviderCall(messages): Promise<void>

Parameters

NameType
messagesTUniversalMessage[]

Returns

Promise<void>

Inherited from

AbstractPlugin.beforeProviderCall

Defined in

agent-core/dist/node/index.d.ts:1097


afterProviderCall

afterProviderCall(messages, response): Promise<void>

Parameters

NameType
messagesTUniversalMessage[]
responseTUniversalMessage

Returns

Promise<void>

Inherited from

AbstractPlugin.afterProviderCall

Defined in

agent-core/dist/node/index.d.ts:1098


onStreamingChunk

onStreamingChunk(chunk): Promise<void>

Parameters

NameType
chunkTUniversalMessage

Returns

Promise<void>

Inherited from

AbstractPlugin.onStreamingChunk

Defined in

agent-core/dist/node/index.d.ts:1099


onError

onError(error, context?): Promise<void>

Parameters

NameType
errorError
context?IPluginErrorContext

Returns

Promise<void>

Inherited from

AbstractPlugin.onError

Defined in

agent-core/dist/node/index.d.ts:1100


onMessageAdded

onMessageAdded(message): Promise<void>

Parameters

NameType
messageTUniversalMessage

Returns

Promise<void>

Inherited from

AbstractPlugin.onMessageAdded

Defined in

agent-core/dist/node/index.d.ts:1101


onModuleEvent

onModuleEvent(eventName, eventData): Promise<void>

Routes module lifecycle events (initialize, execute, dispose) to the appropriate log level. Errors are logged but never re-thrown.

Parameters

NameType
eventNameTEventName
eventDataIEventEmitterEventData

Returns

Promise<void>

Overrides

AbstractPlugin.onModuleEvent

Defined in

agent-plugin-logging/src/logging-plugin.ts:194


log

log(level, message, context?, metadata?): Promise<void>

Writes a log entry to the configured storage if the level meets the current threshold. Logging failures are swallowed to prevent cascading errors.

Parameters

NameType
levelTLogLevel
messagestring
context?ILoggingContextData
metadata?Object
metadata.executionId?string
metadata.conversationId?string
metadata.userId?string
metadata.sessionId?string
metadata.operation?string
metadata.duration?number

Returns

Promise<void>

Defined in

agent-plugin-logging/src/logging-plugin.ts:248


debug

debug(message, context?, metadata?): Promise<void>

Log debug message

Parameters

NameType
messagestring
context?ILoggingContextData
metadata?Object
metadata.executionId?string
metadata.conversationId?string
metadata.userId?string
metadata.sessionId?string
metadata.operation?string
metadata.duration?number

Returns

Promise<void>

Defined in

agent-plugin-logging/src/logging-plugin.ts:280


info

info(message, context?, metadata?): Promise<void>

Log info message

Parameters

NameType
messagestring
context?ILoggingContextData
metadata?Object
metadata.executionId?string
metadata.conversationId?string
metadata.userId?string
metadata.sessionId?string
metadata.operation?string
metadata.duration?number

Returns

Promise<void>

Defined in

agent-plugin-logging/src/logging-plugin.ts:291


warn

warn(message, context?, metadata?): Promise<void>

Log warning message

Parameters

NameType
messagestring
context?ILoggingContextData
metadata?Object
metadata.executionId?string
metadata.conversationId?string
metadata.userId?string
metadata.sessionId?string
metadata.operation?string
metadata.duration?number

Returns

Promise<void>

Defined in

agent-plugin-logging/src/logging-plugin.ts:302


error

error(message, error?, context?, metadata?): Promise<void>

Log error message

Parameters

NameType
messagestring
error?Error
context?ILoggingContextData
metadata?Object
metadata.executionId?string
metadata.conversationId?string
metadata.userId?string
metadata.sessionId?string
metadata.operation?string
metadata.duration?number

Returns

Promise<void>

Defined in

agent-plugin-logging/src/logging-plugin.ts:313


logExecutionStart

logExecutionStart(executionId, userInput, metadata?): Promise<void>

Logs the start of an agent execution, truncating user input to 100 characters.

Parameters

NameType
executionIdstring
userInputstring
metadata?Object
metadata.executionId?string
metadata.conversationId?string
metadata.userId?string
metadata.sessionId?string
metadata.operation?string
metadata.duration?number

Returns

Promise<void>

Defined in

agent-plugin-logging/src/logging-plugin.ts:335


logExecutionComplete

logExecutionComplete(executionId, duration, metadata?): Promise<void>

Logs the completion of an agent execution with its duration.

Parameters

NameType
executionIdstring
durationnumber
metadata?Object
metadata.executionId?string
metadata.conversationId?string
metadata.userId?string
metadata.sessionId?string
metadata.operation?string
metadata.duration?number

Returns

Promise<void>

Defined in

agent-plugin-logging/src/logging-plugin.ts:354


logToolExecution

logToolExecution(toolName, executionId, duration?, success?, metadata?): Promise<void>

Logs a tool execution result at info (success) or error (failure) level.

Parameters

NameType
toolNamestring
executionIdstring
duration?number
success?boolean
metadata?Object
metadata.executionId?string
metadata.conversationId?string
metadata.userId?string
metadata.sessionId?string
metadata.operation?string
metadata.duration?number

Returns

Promise<void>

Defined in

agent-plugin-logging/src/logging-plugin.ts:374


flush

flush(): Promise<void>

Flushes any buffered log entries to the underlying storage.

Returns

Promise<void>

Throws

PluginError if the flush operation fails

Defined in

agent-plugin-logging/src/logging-plugin.ts:398


destroy

destroy(): Promise<void>

Closes the underlying storage and releases resources.

Returns

Promise<void>

Defined in

agent-plugin-logging/src/logging-plugin.ts:411

Released under the MIT License.