Advertisement

a51dev | Canada

a51 Logo
a a a
Page | Scrolling

Memorio Logger

🖥️ Browser Only: This feature is only available in browser console

Automatic logging middleware for tracking all state changes in Memorio.

Overview

The logger automatically tracks all operations (set, delete, clear) across all modules:

  • State
  • Store
  • Session
  • Cache

Configuration

configure(options)

Configure the logger.

memorio.logger.configure({
  enabled: true,           // Enable/disable logging
  logToConsole: true,     // Log to browser console
  customHandler: function(entry) { ... }, // Custom handler
  modules: ['state', 'store', 'session', 'cache'], // Modules to log
  maxEntries: 1000        // Maximum log history size
})

enable()

Enable logging.

memorio.logger.enable()

disable()

Disable logging.

memorio.logger.disable()

Methods

getHistory()

Get all log entries.

const history = memorio.logger.getHistory()
// Returns array of LogEntry objects

getStats()

Get statistics about logged operations.

const stats = memorio.logger.getStats()
// Returns: { total, state, store, session, cache, set, get, delete, clear }

clearHistory()

Clear log history.

memorio.logger.clearHistory()

exportLogs()

Export logs as JSON string.

const json = memorio.logger.exportLogs()

Log Entry Structure

{
  timestamp: "2026-02-18T12:00:00.000Z",
  module: "state",
  action: "set",
  path: "user.name",
  value: "John",
  previousValue: "Jane"
}

Examples

Basic usage

// Logging is enabled by default
state.user = { name: 'John' }
// Console: [Memorio:STATE] set user → value: { name: 'John' }

Get statistics

const stats = memorio.logger.getStats()
console.log(stats)
// { total: 15, state: 5, store: 3, session: 2, cache: 5, set: 10, get: 0, delete: 3, clear: 2 }

Disable specific modules

memorio.logger.configure({
  modules: ['state'] // Only log state changes
})

Custom handler

memorio.logger.configure({
  customHandler: (entry) => {
    // Send to analytics
    analytics.track('memorio_change', entry)
  }
})

Export and analyze

// Get all logs
const logs = memorio.logger.getHistory()

// Filter by module
const stateLogs = logs.filter(l => l.module === 'state')

// Filter by action
const setOperations = logs.filter(l => l.action === 'set')

// Export for debugging
console.log(memorio.logger.exportLogs())

Disclaimer
All content on this website, including text and images, has been generated using artificial intelligence technologies. While every effort is made to ensure quality and coherence, I do not assume responsibility for any inaccuracies, errors, or interpretations resulting from the use of this material.

Copyright and Intellectual property
All content on this website is copyrighted. Any copying, reproduction, distribution, or use of materials in any form is strictly forbidden without prior written permission. Violations will be subject to legal action in accordance with copyright law. We appreciate your understanding and compliance.