winston-azure-table-storage

A Windows Azure table storage transport for winston, updated with Azure SDK and winston library

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
winston-azure-table-storage
1.0.94 years ago5 years agoMinified + gzip package size for winston-azure-table-storage in KB

Readme

winston-azure-table-storage
Table storage transport for winston1 Microsoft azure2 SDK. Fork of original winston-azure-sw0 project.
In short, with this library you can use account/key as well as host/sas.
Also, it fixes bug with generation of entity key (if your app logs too fast, it's possible to generate same keys for different entities.) in original lib.

Installation

``` bash $ npm install winston $ npm install winston-azure-table-storage ```

Usage

Here is the use of account/key pair. ``` js var winston = require('winston'); require('winston-azure-table-storage'); winston.configure({
transports: [
new (winston.transports.AzureTable) ({
account: "Azure storage account sub domain ([A-Za-z0-9])",
key: "The long Azure storage secret key",
table: "The name of the table (why not just 'log'?)",
partition: require('os').hostname(),
level: 'warn',
metaAsColumns: true
})
]
}); winston.warn('Hello toto!'); ``` And here is the use of host/sas pair, created with Access Policies and SAS (See Storage Explorer4 fro details) ``` js var winston = require('winston'); require('winston-azure-table-storage'); winston.configure({
transports: [
new (winston.transports.AzureTable) ({
host: "somestorage.table.core.windows.net", 
sas: "The long Azure SAS", // something like '?sv=2015-12-11&si=Folder1-A123&tn=folder1&sig=BLA-BLA'
table: "Folder1", //SAS usssualy also contains it
partition: require('os').hostname(),
level: 'warn',
metaAsColumns: true
})
]
}); winston.warn('Hello toto!'); ``` The Azure transport accepts the following options:
  • level: Level of messages that this transport should log (defaults to info).
  • account: The name of the Windows Azure storage account to use
  • key: The access key used to authenticate into this storage account
  • host: The name of the Windows Azure storage host
  • sas: The SAS used to authenticate and associated with given Access Policy
  • table: The name of the table to log to (defaults to 'log'). Must already exist.
  • partition: The value to use for the PartitionKey in each row (defaults to 'log').
  • metaAsColumns: If true, the transport will store the metadata key/value pairs in individual columns (this can be helpful when querying table storage for log entries with specific metadata values). The default is to store the entire meta value as a single JSON string in a 'meta' column.
  • rowKeyBuilder: A function to build the primary key, default is:
``` js
function()
{
var rtext = '';
var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
for (var i = 0; i < 5; i++)
rtext += possible.charAt(Math.floor(Math.random() * possible.length));
return (new Date()).getTime() + '_' + (new Date()).getMilliseconds() + '_' + rtext;
}
```