Comparing version 0.6.1 to 0.6.2
17
index.js
@@ -237,7 +237,7 @@ const fs = require("fs"); | ||
fs.writeFile(filename, text, err => { | ||
fs.writeFile(filename, formatText(text), err => { | ||
if (err) return reject(err); | ||
}); | ||
} else { | ||
writeStream.write(text); | ||
writeStream.write(formatText(text)); | ||
} | ||
@@ -308,1 +308,14 @@ }); | ||
} | ||
function formatText(text) { | ||
let formattedText = text; | ||
if (typeof text === "object") { | ||
formattedText = JSON.stringify(text); | ||
} | ||
if (user_config.file.newline) { | ||
formattedText += "\n"; | ||
} | ||
return formattedText; | ||
} |
{ | ||
"name": "simplert", | ||
"version": "0.6.1", | ||
"version": "0.6.2", | ||
"description": "Simple way to send alerts via Slack, Email, Discord, SMS, etc.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -29,3 +29,4 @@ # Simplert | ||
"filesize": 10, | ||
"maxfiles": 10 | ||
"maxfiles": 10, | ||
"newline": true | ||
}, | ||
@@ -60,2 +61,3 @@ "slack": { | ||
***file:maxfiles*** - The maximum number of logs files to generate during log rotation. Example: a maxfiles of 10 and filesize of 5 would log the most recent 50MB of data across log.txt, log1.txt, log2.txt ... log9.txt | ||
***file:newline*** - If true, will automatically add a newline to any text written. Default: true | ||
***slack:send_to*** - The channel or user you want to send the message to. Examples: #some_channel or @some_user | ||
@@ -97,3 +99,3 @@ ***slack:token*** - The token of your Slack bot. Make sure it has the right permissions setup to send messages. | ||
*Send text to a file* | ||
All values have to be set under `file:*` in your configuration file. Note: This will not add any newlines when writing to the file. | ||
All values have to be set under `file:*` in your configuration file. Note: This function will automatically call JSON.stringify on any object passed in. | ||
@@ -104,3 +106,3 @@ const simplert = require("simplert"); | ||
simplert.file("some event"); | ||
simplert.file(JSON.stringify({"data": "some data"})); | ||
simplert.file({"data": "some data"}); | ||
--- | ||
@@ -107,0 +109,0 @@ #### **simplert.slack(message,[send_to])** |
@@ -21,3 +21,4 @@ { | ||
"filesize": 10, | ||
"maxfiles": 10 | ||
"maxfiles": 10, | ||
"newline": true | ||
}, | ||
@@ -24,0 +25,0 @@ "slack": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22943
428
155