mobiletto 1.0.30 → 1.0.33

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 +29 -7
  2. package/index.js +3 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -12,9 +12,14 @@ 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
- * [Mobiletto on GitHub](https://github.com/cobbzilla/mobiletto)
17
- * [Mobiletto on npm](https://www.npmjs.com/package/mobiletto)
21
+ * [mobiletto on GitHub](https://github.com/cobbzilla/mobiletto)
22
+ * [mobiletto on npm](https://www.npmjs.com/package/mobiletto)
18
23
 
19
24
  ## TLDR
20
25
  A simple example using the mobiletto `s3` driver.
@@ -69,7 +74,7 @@ This code would run the same if the driver were `local`.
69
74
  // * readOnly: optional, never change anything on the filesystem; default is false
70
75
  // * fileMode: optional, permissions used when creating new files, default is 0600. can be string or integer
71
76
  // * dirMode: optional, permissions used when creating new directories, default is 0700. can be string or integer
72
- // * cacheSize: optional, LRU cache for `list` results
77
+ // * cacheSize: optional, LRU cache for `list` results, default is no cache
73
78
  const local = await mobiletto('local', '/home/ubuntu/tmp', null, {fileMode: 0o0600, dirMode: '0700', cacheSize: 100})
74
79
 
75
80
  // To use 's3' driver:
@@ -81,7 +86,7 @@ This code would run the same if the driver were `local`.
81
86
  // * region: optional, the AWS region to communicate with, default is us-east-1
82
87
  // * prefix: optional, all read/writes within the S3 bucket will be under this prefix
83
88
  // * delimiter: optional, directory delimiter, default is '/' (note: always '/' when encryption is enabled)
84
- // * cacheSize: optional, LRU cache for `list` results
89
+ // * cacheSize: optional, LRU cache for `list` results, default is no cache
85
90
  const s3 = await mobiletto('s3', aws_key, aws_secret, {bucket: 'bk', region: 'us-east-1', cacheSize: 100})
86
91
 
87
92
  // List files
@@ -304,8 +309,25 @@ The object that the storageClient function returns must define these functions:
304
309
  async remove (path, recursive = false, quiet = false)
305
310
 
306
311
  ## Logging
307
- Mobiletto uses the winston logging library. Set the log level with the `MOBILETTO_LOG_LEVEL` environment variable.
308
- The default level is `warn`. The most verbose level is `silly`, although currently mobiletto does not log at levels
309
- below `debug`
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`
310
321
 
311
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.30",
3
+ "version": "1.0.33",
4
4
  "description": "A storage abstraction layer",
5
5
  "main": "index.js",
6
6
  "author": "Jonathan Cobb",