Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including logatron with all npm packages installed. Try it out:

var logatron = require("logatron")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

logatron v1.1.2

In-memory logging server with network support and per-client state dictionary


Logatron is a simple in-memory logging server with the following features:

  • clients connect and identify via TCP
  • per-connection circular buffer for log messages
  • per-connection updateable state (key/value pairs)
  • query interface


const logatron = require('logatron');
const log = logatron();
log.listen(2212, '');


log = logatron(opts)

Create a new instance. Valid options:

  • bufferSize: size of each client's circular log buffer. Defaults to 128.

log.listen(port, [host])

Start the logging server.


Return an array of the names of all connected clients.


Return a map of client name => { connectedAt: ..., log: ..., state: ... }


Get an array of log entries for client name. Each log entry is an array of [timestamp, logMessage]. Throws an error if no such client exists.


Get a the state dictionary for client name. Throws an error if no such client exists.


Logatron instances are EventEmitters and emit the following events:

  • 'ready' (clientName): a new client has connected and identified
  • 'log' (clientName, message): client clientName logged message
  • 'set' (clientName, key, value): client clientName set key to value
  • 'close' (clientName): client clientName closed its connection


Logatron's wire protocol is UTF-8, one command per line.

The first thing clients must do is identify:

IAM bob\n

If the identify command fails (i.e. a syntax error or a client with the given name is already connected), the server will terminate the connection.

Thereafter you can either LOG a message or SET a key/value pair:

LOG this is my log message\n
SET foo bar\n
SET foo keys can have multiple words too!\n

That's all there is to it.


  • startup script
  • HTTP interface for status reports
  • websocket streaming



RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free