new-log

1.1.11 • Public • Published

NotEnoughWood - NEW

npm npm bundle size

NotEnoughWood - A simple way to access your logs via http/s.
Show the results of commands in the web. No need for a ssh session to check the log files.

Features

  • Access the logs of commands, like docker logs <container-name>.
  • If the logs are written to disk, you can host these logfiles.
  • Use cURL to access the service, or add the plain query to the url to show the result without html. Like http://localhost:4200/test.log?plain=true
  • Use the query param tail you can specify the lines (from the ending) you want to see. Something Like http://localhost:4200/test.log?tail=10 means seeing the last 10 lines of the command output.
███╗░░██╗███████╗░██╗░░░░░░░██╗
████╗░██║██╔════╝░██║░░██╗░░██║
██╔██╗██║█████╗░░░╚██╗████╗██╔╝
██║╚████║██╔══╝░░░░████╔═████║░
██║░╚███║███████╗░░╚██╔╝░╚██╔╝░
╚═╝░░╚══╝╚══════╝░░░╚═╝░░░╚═╝░░
NotEnoughWood <version>
Created by open-schnick

--------------------------------------
Logfile: whoami.log
Source: (Executing) whoami
Next update in 9 seconds
--------------------------------------

open-schnick

Install

Just install new-log globally

npm install -g new-log

Usage

# new-log --help
███╗░░██╗███████╗░██╗░░░░░░░██╗
████╗░██║██╔════╝░██║░░██╗░░██║
██╔██╗██║█████╗░░░╚██╗████╗██╔╝
██║╚████║██╔══╝░░░░████╔═████║░
██║░╚███║███████╗░░╚██╔╝░╚██╔╝░
╚═╝░░╚══╝╚══════╝░░░╚═╝░░░╚═╝░░

Usage
  $ new-log <input>

Necessary arguments:
  --config, -c  specify the config path

Options
  --port, -p    specify the port.
  --folder, -f  specify the folder containing the logs. (By default the current working directory)
  --silent, -s  turn of own log messages to stout.
  --debug, -d   turn on debug log messages.

Examples
  $ new-log --port 3000 --config ./config.json --silent

--config

The core work to do to run new is to create a config file The config file contains various key to configure the service. You can find a dummy config file in the repository or below.

{
  "virtualFolderName": "Not enough wood!",
  "defaultCachingTime": 10,
  "defaultTailLines": 100,
  "faviconPath": "https://www.gnu.org/graphics/heckert_gnu.transp.small.png",
  "authentication": {
    "enabled": true,
    "username": "user",
    "password": "1234"
  },
  "logs": [
    {
      "name": "test",
      "cachingTime": 3600,
      "source": {
        "type": "command",
        "resource": "npm -v"
      }
    },
    {
      "name": "static file",
      "source": {
        "type": "file",
        "resource": "<absolute-path-to-file-here>"
      }
    },
    {
      "name": "caching disabled",
      "cachingEnabled": false,
      "source": {
        "type": "command",
        "resource": "whoami"
      }
    },
    {
      "name": "log is tailed to 20 lines",
      "tailLines": 20,
      "source": {
        "type": "command",
        "resource": "journalctl"
      }
    },
    {
      "name": "log is tailed to default 100 lines",
      "source": {
        "type": "command",
        "resource": "journalctl"
      }
    }
  ]
}
  • virtualFolderName - the name of the folder containing the logs. (This will appear in the web interface)
  • defaultCachingTime - the default time in seconds to cache log results. (any number)
  • faviconPath - sets the favicon of NEW to the result of an valid url. (valid url)
  • defaultTailLines - the default amount of lines tailed when the log size is too big. (200k bytes) (any number)
  • authentication - require authentication to access the log files.
    • enabled - set to true to require authentication.
    • username & password - credentials to log in.
  • logs - log objects need name and command keys, other keys shown are optional. All keys:
    • name - name of the log / log file (any string)
    • tailLines (optional) - amount of lines to tail for if the source returned too much. (200k bytes) (any number)
    • cachingTime (optional) - custom caching time for the log. Also in seconds (any number)
    • cachingEnabled (optional) - en/disble caching for the log. (any boolean)
    • source - a JSON object representing the info about the source of the logs
      • type - a string specifing the type of the log. Avaiable options are file and command.
      • resource - depending on the type above either the command to execute in the shell, or the absolute path to a static file. (any string)

--port

Specify a custom port for the web interface. Defaults to port 4200.

--folder

Specify a different directory for the logs (this will contain the folder with the name specified by the virtualFolderName key.

--silent

Use the --silent / -s flag to disable logging of own logs to stout.

--debug

When provided NEW does log additional info to stout

--help

Show a little help message.

Package Sidebar

Install

npm i new-log

Weekly Downloads

0

Version

1.1.11

License

GPL-3.0

Unpacked Size

60.7 kB

Total Files

9

Last publish

Collaborators

  • open-schnick