npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cctail

v1.6.0

Published

Salesforce Commerce Cloud logs remote tail

Downloads

399

Readme

Salesforce Commerce Cloud log tail

Remote tail Salesforce Commerce Cloud logs via webdav. Allow to monitor more logs at once, merging the content of all the files in a single stream. Reports either to console or a FluentD collector.

Features

  • Authentication using API Client (recommended) OR Business Manager (deprecated)
  • Interactive prompt for logs selection OR selection of logs by config file.
  • Supports configuration of multiple instances OR standard dw.json config file
  • Outputs to console OR FluentD collector
  • Multiple log tailing, with merging of log entries
  • In Console mode:
    • Sorts log entries by timestamp
    • Colors output based on log levels
    • Converts log timestamp to local timezone

Installation

$ npm i -g cctail

Requirements

  • Node >= 10

Configuration

Requires one of the following configuration files:

  • a log.conf.json file with multiple environments configured. This may be used if you want to easily switch between multiple instances
  • a standard dw.json file, tipically pointing to your working sandbox.

cctail requires a correctly configured API client id/secret OR Business Manager username/password for accessing logs via webdav. API client authentication is recommended, because it is faster after the initial authorization, and Business Manager authentication to WebDAV has been deprecated by SalesForce.

Optional Configurations

  • "profiles": - Standard log types: analytics, api, console, customdebug, customerror, customfatal, custominfo, customwarn, dbinit-sql, debug, deprecation, error, fatal, info, jobs, migration, performance, quota, sql, staging, sysevent, syslog, warn
    • "log_types": ["log", "types", "array"] (default: all log types) - In non-interactive mode, defining this will limit the log types that cctail collects to this list.
      • Standard log types: analytics, api, codeprofiler, console, customdebug, customerror, customfatal, custominfo, customwarn, dbinit-sql, debug, deprecation, error, fatal, info, jobs, migration, performance, quota, sql, staging, sysevent, syslog, warn
    • "polling_interval": nnn (default: 3) - Frequency (seconds) with which cctail will poll the logs.
      • If you are using non-interactive mode to pipe the logs elsewhere (i.e. FluentD), a longer interval is recommended (i.e. 30 or 60).
    • "refresh_loglist_interval": nnn (default: 600) - In non-interactive mode, this is the frequency (seconds) in which cctail will check the WebDAV server for new logs that match your log_types criteria.
  • "interactive": true|false (default: true) - Interactive mode asks which logs you will want to tail. If false, cctail will tail all of today's logs by default.

FluentD

NOTE: All configurations for fluentD are optional, except enabled must be set to true if you want to use it.

  • fluent:
    • "enabled": true|false (default: false) - If enabled, logs will be directed to the Fluent collector.
    • "host": "fluentd.yourco.com" (default: localhost) - FluentD collector host
    • "port": nnn (default: 24224) - FluentD collector port
    • "reconnect_interval": nnn (default: 600) - If the collector can't be reached, cctail will try to reconnect again in nnn seconds.
    • "timeout": nnn (default: 3) - Timeout to connect to FluentD collector
    • "tag_prefix": "your_tag_prefix" (default: sfcc) - All logs sent to FluentD will have this prefix, followed by the log type (i.e. "sfcc.customerror").

Sample configuration files

Sample dw.json:

{
  "hostname": "dev01-mysandbox.demandware.net",
  "client_id": "a12464ae-b484-4b90-4dfe-17e20844e9f0",
  "client_secret": "mysupersecretpassword"
}

Sample log.conf.json:

{
  "profiles": {
    "dev01-api-client-example": {
      "hostname": "dev01-mysandbox.demandware.net",
      "client_id": "a12345ae-b678-9b01-2dfe-34e56789e0f1",
      "client_secret": "mysupersecretsecret",
      "polling_interval": 30,
			"refresh_loglist_interval": 900
    },
    "dev02-bm-example": {
      "hostname": "dev02-mysandbox.demandware.net",
      "username": "[email protected]",
      "password": "mysupersecretpassword",
      "log_types": [ "customerror", "customwarn", "error", "jobs", "warn" ],
      "polling_interval": 60
    }
  },
  "interactive": false,
  "fluent": {
    "enabled": true
  }
}

If multiple instances are configured, you may directly pass the name of the instance for skipping the interactive selection prompt, e.g.:

$ cctail dev02

API client configuration

The API client id must be created in the account.demandware.com console. Before being able to use cctail you must grant the required permissions to that client id for accessing the logs folder through WebDAV in any target SFCC instance.

To do so, access Business Manager and add the following to Administration -> Organization -> WebDAV Client Permissions, replacing the client_id value with your client id. Note: you may need to merge these settings with existing ones.

{
  "clients": [
    {
      "client_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "permissions": [
        {
          "path": "/logs",
          "operations": ["read_write"]
        }
      ]
    }
  ]
}

Usage

$ cctail

Run cctail in a folder containing either a log.conf-json or dw.json config file. The tool will display the list of available logs in order to let you interactively select the ones you want to monitor.

License

Released under the MIT license.