utils/log
Logging Service
  README.md
# StdLib Logging This is a simple logging service to provide a logging layer for services that you build on top of StdLib. The service gives you the ability to store logs, warnings and errors to up to 10,000 lines per service. ## Usage You can use the `log`, `warn` and `error` methods to for logging and the `read` comment to read them. You **must** be authenticated with a StdLib Library Token to use this service. You can do that by initializing `lib` like this: ```javascript // Retrieve your Library Token on the StdLib Dashboard const lib = require('lib')({ token: STDLIB_LIBRARY_TOKEN }); ``` You can create tokens in your [dashboard](https://dashboard.stdlib.com/dashboard). You also **must** pass in your service name. This can be done by initializing the `utils` service: ```javascript const utils = lib.utils({ service: 'service-name' }); ``` ### utils.log ```javascript utils.log("log content", "function accepts multiple arguments", { accepts: 'objects, too' }, (err) => { // Handle error }); ``` ### utils.log.error ```javascript utils.log.error("error content", new Error("Accepts error objects"), { accepts: 'objects, too' }, (err) => { // Handle error }); ``` ### utils.log.warn ```javascript utils.log.warn("warning content", "accepts multiple arguments", { accepts: 'objects, too' }, (err) => { // Handle error }); ``` ### utils.log.read You can use this function to read the logs of your services. | Param | Description | | ----- | ----------- | | service | Required: service name | | num | Optional: number of lines to return. Default is 100. | | json | Optional: whether to return the results in JSON format. Default is false. | ```bash # -t has to be passed with your library token lib utils.log.read -t STDLIB_LIBRARY_TOKEN --service service-name ```
Playground
  Published by utils on Wednesday, March 15th, 2017, 1:47:52 AM
This service has 4 functions
  log default function
  Pricing
 per request
 per second
  Logs information
   Arguments
[0] anything to log
[1] you can use multiple arguments to log
   Keyword Arguments
   HTTPS Execution
default https://utils.stdlib.com/log
explicit https://utils.stdlib.com/log/log
  read
  Pricing
 per request
 per second
  Read your logs
   Arguments
No Arguments Expected
   Keyword Arguments
length (optional) number of lines to read. Default: 100. Maximum: 10000.
service (required) name of your service
   HTTPS Execution
https://utils.stdlib.com/log/read
  warn
  Pricing
 per request
 per second
  Logs a warning
   Arguments
[0] anything to log
[1] you can use multiple arguments to log
   Keyword Arguments
   HTTPS Execution
https://utils.stdlib.com/log/warn
  error
  Pricing
 per request
 per second
  Logs an error.
   Arguments
[0] anything to log
[1] you can use multiple arguments to log
   Keyword Arguments
   HTTPS Execution
https://utils.stdlib.com/log/error