mobiletto 1.0.29 → 1.0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +33 -3
  2. package/index.js +3 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -12,12 +12,17 @@ Today the supported drivers are:
12
12
  * `s3`: read/write an Amazon S3 bucket
13
13
  * `local`: read/write to local filesystem
14
14
 
15
+ ### mobiletto-cli
16
+ Mobiletto is intended to be used as a library by other JavaScript code.
17
+
18
+ To work with mobiletto at the command-line, use [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli)
19
+
15
20
  ### Source
16
21
  * [Mobiletto on GitHub](https://github.com/cobbzilla/mobiletto)
17
22
  * [Mobiletto on npm](https://www.npmjs.com/package/mobiletto)
18
23
 
19
24
  ## TLDR
20
- A simple CRUD example using the mobiletto `s3` driver.
25
+ A simple example using the mobiletto `s3` driver.
21
26
 
22
27
  This code would run the same if the driver were `local`.
23
28
 
@@ -54,6 +59,7 @@ This code would run the same if the driver were `local`.
54
59
  * [Transparent encryption](#Transparent-encryption)
55
60
  * [Key rotation](#Key-rotation)
56
61
  * [Driver interface](#Driver-interface)
62
+ * [Logging](#Logging)
57
63
  ----
58
64
  ## Basic usage
59
65
  const { mobiletto } = require('mobiletto')
@@ -68,7 +74,7 @@ This code would run the same if the driver were `local`.
68
74
  // * readOnly: optional, never change anything on the filesystem; default is false
69
75
  // * fileMode: optional, permissions used when creating new files, default is 0600. can be string or integer
70
76
  // * dirMode: optional, permissions used when creating new directories, default is 0700. can be string or integer
71
- // * cacheSize: optional, LRU cache for `list` results
77
+ // * cacheSize: optional, LRU cache for `list` results, default is no cache
72
78
  const local = await mobiletto('local', '/home/ubuntu/tmp', null, {fileMode: 0o0600, dirMode: '0700', cacheSize: 100})
73
79
 
74
80
  // To use 's3' driver:
@@ -80,7 +86,7 @@ This code would run the same if the driver were `local`.
80
86
  // * region: optional, the AWS region to communicate with, default is us-east-1
81
87
  // * prefix: optional, all read/writes within the S3 bucket will be under this prefix
82
88
  // * delimiter: optional, directory delimiter, default is '/' (note: always '/' when encryption is enabled)
83
- // * cacheSize: optional, LRU cache for `list` results
89
+ // * cacheSize: optional, LRU cache for `list` results, default is no cache
84
90
  const s3 = await mobiletto('s3', aws_key, aws_secret, {bucket: 'bk', region: 'us-east-1', cacheSize: 100})
85
91
 
86
92
  // List files
@@ -301,3 +307,27 @@ The object that the storageClient function returns must define these functions:
301
307
  // Remove a file, or recursively delete a directory
302
308
  // returns a string of a single path removed, or an array of multiple paths removed
303
309
  async remove (path, recursive = false, quiet = false)
310
+
311
+ ## Logging
312
+ Mobiletto uses the [winston](https://www.npmjs.com/package/winston) logging library.
313
+
314
+ Logs **will** contain file paths and error messages, but will **never** contain keys, secrets,
315
+ or any other connection configuration information.
316
+
317
+ ### Log level
318
+ Use the `MOBILETTO_LOG_LEVEL` environment variable to set the log level.
319
+ The default level is `warn`. The most verbose level is `silly`, although currently mobiletto
320
+ does not log at levels below `debug`
321
+
322
+ MOBILETTO_LOG_LEVEL=silly
323
+
324
+ ### Log file
325
+ By default, the logger writes to the console. To send logs to a file, set the `MOBILETTO_LOG_FILE`
326
+ environment variable. When logging to a file, logs will no longer be written to the console.
327
+
328
+ MOBILETTO_LOG_FILE=/var/my_mobiletto_log
329
+
330
+ To turn off logging:
331
+
332
+ MOBILETTO_LOG_FILE=/dev/null
333
+ MOBILETTO_LOG_LEVEL=emerg # not strictly necessary; minimizes time spent in logging code
package/index.js CHANGED
@@ -11,7 +11,9 @@ const {DEFAULT_CRYPT_ALGO, normalizeKey, normalizeIV, encrypt, decrypt} = requir
11
11
  const logger = winston.createLogger({
12
12
  level: process.env.MOBILETTO_LOG_LEVEL || 'warn',
13
13
  format: winston.format.simple(),
14
- transports: [ new winston.transports.Console() ]
14
+ transports: process.env.MOBILETTO_LOG_FILE
15
+ ? [ new winston.transports.File({ filename: process.env.MOBILETTO_LOG_FILE }) ]
16
+ : [ new winston.transports.Console() ]
15
17
  })
16
18
 
17
19
  const setLogLevel = (level) => { logger.level = level }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobiletto",
3
- "version": "1.0.29",
3
+ "version": "1.0.32",
4
4
  "description": "A storage abstraction layer",
5
5
  "main": "index.js",
6
6
  "author": "Jonathan Cobb",