datata-logger 0.0.3 → 1.0.0

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 (2) hide show
  1. package/index.js +10 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -4,7 +4,15 @@ const fs = require('fs')
4
4
  const date = () => {
5
5
  return new Date().toLocaleString('es-Es')
6
6
  }
7
- const stream = fs.createWriteStream('log.txt', { flags: 'a' })
7
+
8
+ let stream
9
+
10
+ const configure = (logPath = './tmp/logs.log') => {
11
+ const fullPath = path.resolve(process.cwd(), logPath)
12
+ fs.mkdirSync(path.dirname(fullPath), { recursive: true })
13
+ stream = fs.createWriteStream(fullPath, { flags: 'a' })
14
+ }
15
+
8
16
  const info = message => {
9
17
  const logMessage = `[INFO] [${date()}] ${message}\n`
10
18
  console.log(chalk.blue(logMessage))
@@ -16,7 +24,6 @@ function close() {
16
24
  stream.end()
17
25
  }
18
26
 
19
- process.on('SIGINT', closeStream)
20
-
21
27
  exports.info = info
22
28
  exports.close = close
29
+ exports.configure = configure
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datata-logger",
3
- "version": "0.0.3",
3
+ "version": "1.0.0",
4
4
  "description": "Logger",
5
5
  "main": "index.js",
6
6
  "scripts": {},