Skip to content

Yet another Windows Azure table storage transport for the node.js Winston logging framework, updated with new Azure SDK.

License

Notifications You must be signed in to change notification settings

kalatchev/winston-azure-sw

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

winston-azure-sw

npm version

Table storage transport for winston with latest (January 2017) Microsoft azure SDK. Fork of original winston-azure 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

  $ npm install winston
  $ npm install winston-azure-sw

Usage

Here is the use of account/key pair.

  var winston = require('winston');
  require('winston-azure-sw');
  
  var logger = new (winston.Logger)({
    transports: [
        new (winston.transports.Azure)({
            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
        })
    ]
  });
  
  logger.warn('Hello toto!');

And here is the use of host/sas pair, created with Access Policies and SAS (See Storage Explorer fro details)

  var winston = require('winston');
  require('winston-azure-sw');
  
  var logger = new (winston.Logger)({
    transports: [
        new (winston.transports.Azure)({
            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
        })
    ]
  });
  
  logger.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:
    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;
    }

About

Yet another Windows Azure table storage transport for the node.js Winston logging framework, updated with new Azure SDK.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%