-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- New API, please read new updated README.md - Compatibility with Meteor >= 1.3.* - Performance and Security enhancements - All code is asynchronous! - Use own namespace
- Loading branch information
1 parent
b9d5fcc
commit 37ab907
Showing
8 changed files
with
227 additions
and
121 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
[email protected]_1 | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
ostrio:[email protected] | ||
ostrio:[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
ostrio:[email protected] | ||
ostrio:[email protected] | ||
ostrio:[email protected] | ||
promise@0.5.1 | ||
[email protected].5 | ||
[email protected].6 | ||
[email protected].9 | ||
[email protected].4 | ||
promise@0.6.6 | ||
[email protected].8 | ||
[email protected].8 | ||
[email protected].12 | ||
[email protected].7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,3 @@ | ||
Changelog | ||
========= | ||
- [[`v1.0.1`](https://github.com/VeliovGroup/Meteor-logger-file/releases/tag/1.0.1)] *03/23/2016* | ||
- Dependencies update | ||
- Better Windows support | ||
- [[`v1.0.0`](https://github.com/VeliovGroup/Meteor-logger-file/releases/tag/v1.0.0)] *07/01/2015* | ||
- Deps packages update see [ostrio:logger@1.0.0](https://github.com/VeliovGroup/Meteor-logger/releases/tag/v1.0.0) | ||
- [[`v0.0.11`](https://github.com/VeliovGroup/Meteor-logger-file/releases/tag/v0.0.11)] *06/07/2015* | ||
- Deps packages update | ||
- [[`v0.0.10`](https://github.com/VeliovGroup/Meteor-logger-file/releases/tag/v0.0.10)] *05/29/2015* | ||
- Deps packages update | ||
- Add Changelog.md | ||
- [[`v0.0.9`](https://github.com/VeliovGroup/Meteor-logger-file/releases/tag/v0.0.9)] *05/28/2015* | ||
- Fix issue #2 | ||
- Remove colon from file names, to avoid Windows compilation issues | ||
- License update | ||
- [[`v0.0.8`](https://github.com/VeliovGroup/Meteor-logger-file/releases/tag/v0.0.8)] *05/25/2015* | ||
- Deps packages update | ||
- [[`v0.0.7`](https://github.com/VeliovGroup/Meteor-logger-file/releases/tag/v0.0.7)] *04/12/2015* | ||
- Use `ostrio:meteor-root` to find Meteor's root folder | ||
- [[`v0.0.6`](https://github.com/VeliovGroup/Meteor-logger-file/releases/tag/v0.0.6)] *04/10/2015* | ||
- Fix storage path for PRODUCTION ENV | ||
- [[`v0.0.5`](https://github.com/VeliovGroup/Meteor-logger-file/releases/tag/v0.0.5)] Initial, please see docs | ||
For full package history, please see [releases at GitHub](https://github.com/VeliovGroup/Meteor-logger-file/releases) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
History | ||
========= | ||
For full package history, please see [releases at GitHub](https://github.com/VeliovGroup/Meteor-logger-file/releases) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,102 @@ | ||
Meteor file adapter for ostrio:logger | ||
Logging: To File | ||
======== | ||
Simply store application logs into file within [ostrio:logger](https://atmospherejs.com/ostrio/logger) package | ||
|
||
*Whenever you log message(s) on client or sever, it goes directly to log-file on your server.* | ||
|
||
Installation: | ||
======== | ||
```shell | ||
meteor add ostrio:logger # If not yet installed | ||
meteor add ostrio:loggerfile | ||
``` | ||
|
||
Usage | ||
======== | ||
##### Log [`Server` & `Client`] | ||
##### Initialization [*Isomorphic*] | ||
`new LoggerFile(LoggerInstance, options)` | ||
- `LoggerInstance` {*Logger*} - from `new Logger()` | ||
- `options` {*Object*} | ||
- `options.fileNameFormat` {*Function*} - Log file name, use to adjust file creation frequency, arguments: | ||
- `time` {*Date*} | ||
- `options.format` {*Function*} - Log record format, arguments: | ||
- `time` {*Date*} | ||
- `level` {*String*} - 'ERROR', 'FATAL', 'WARN', 'DEBUG', 'INFO' | ||
- `message` {*String*} | ||
- `data` {*Object*} | ||
- `userId` {*String*} - set if user is logged in and package `accounts-base` is installed | ||
- Note: Do not forget `\r\n` at the end of record-line | ||
- `path` {*String*} - Log's storage path, absolute, or relative to NodeJS process, note: do not use '~' (path relative to user)! | ||
|
||
Example: | ||
```javascript | ||
/* | ||
message {String} - Any text message | ||
data {Object} - [optional] Any additional info as object | ||
userId {String} - [optional] Current user id | ||
*/ | ||
Meteor.log.info(message, data, userId); | ||
Meteor.log.debug(message, data, userId); | ||
Meteor.log.error(message, data, userId); | ||
Meteor.log.fatal(message, data, userId); | ||
Meteor.log.warn(message, data, userId); | ||
Meteor.log.trace(message, data, userId); | ||
Meteor.log._(message, data, userId); //--> Shortcut for logging without message, e.g.: simple plain log | ||
this.Log = new Logger(); | ||
var LogFile = new LoggerFile(Log, { | ||
fileNameFormat: function(time) { | ||
/* Create log-files hourly */ | ||
return (time.getDate()) + "-" + (time.getMonth() + 1) + "-" + (time.getFullYear()) + "_" + (time.getHours()) + ".log"; | ||
}, | ||
format: function(time, level, message, data, userId) { | ||
/* Omit Date and hours from messages */ | ||
return "[" + level + "] | " + (time.getMinutes()) + ":" + (time.getSeconds()) + " | \"" + message + "\" | User: " + userId + "\r\n"; | ||
}, | ||
path: '/data/logs/' /* Use absolute storage path */ | ||
}); | ||
``` | ||
|
||
##### Activate and set adapter settings [`Server` & `Client`] | ||
##### Activate and set adapter settings [*Isomorphic*] | ||
```javascript | ||
Meteor.log.rule('File', | ||
{ | ||
this.Log = new Logger(); | ||
new LoggerFile(Log, {}).enable({ | ||
enable: true, | ||
filter: ['ERROR', 'FATAL', 'WARN'], /* Filters: 'ERROR', 'FATAL', 'WARN', 'DEBUG', 'INFO', '*' */ | ||
filter: ['ERROR', 'FATAL', 'WARN'], /* Filters: 'ERROR', 'FATAL', 'WARN', 'DEBUG', 'INFO', 'TRACE', '*' */ | ||
client: false, /* This allows to call, but not execute on Client */ | ||
server: true /* Calls from client will be executed on Server */ | ||
}); | ||
``` | ||
|
||
##### Change string format [`Server`] | ||
Default format: | ||
```coffeescript | ||
"#{time.getDate()}-#{time.getMonth()}-#{time.getFullYear()} #{time.getHours()}:#{time.getMinutes()}:#{time.getSeconds()} | [#{level}] | Message: \"#{message}\" | User: #{userId} | data: #{data}\r\n" | ||
``` | ||
##### Log [*Isomorphic*] | ||
```javascript | ||
this.Log = new Logger(); | ||
new LoggerFile(Log).enable(); | ||
|
||
To change format set `Meteor.log.file.format` function | ||
```coffeescript | ||
if Meteor.isServer | ||
Meteor.log.file.format = (time, level, message, data, userId) -> | ||
"#{+time} [#{level}]: \"#{message}\" \r\n" | ||
``` | ||
/* | ||
message {String} - Any text message | ||
data {Object} - [optional] Any additional info as object | ||
userId {String} - [optional] Current user id | ||
*/ | ||
Log.info(message, data, userId); | ||
Log.debug(message, data, userId); | ||
Log.error(message, data, userId); | ||
Log.fatal(message, data, userId); | ||
Log.warn(message, data, userId); | ||
Log.trace(message, data, userId); | ||
Log._(message, data, userId); //--> Shortcut for logging without message, e.g.: simple plain log | ||
|
||
##### Change file name format [`Server`] | ||
Default format: | ||
```coffeescript | ||
# New file will be created every day | ||
"#{time.getDate()}-#{time.getMonth()}-#{time.getFullYear()}.log" | ||
/* Use with throw */ | ||
throw Log.error(message, data, userId); | ||
``` | ||
|
||
To change format set `Meteor.log.file.fileNameFormat` function | ||
```coffeescript | ||
if Meteor.isServer | ||
Meteor.log.file.fileNameFormat = (time) -> | ||
# New file will be created every hour | ||
"#{time.getHours()}_#{time.getDate()}-#{time.getMonth()}-#{time.getFullYear()}.log" | ||
##### Use multiple logger(s) with different settings: | ||
```javascript | ||
this.Log1 = new Logger(); | ||
this.Log2 = new Logger(); | ||
|
||
new LoggerFile(Log1).enable({ | ||
client: false, | ||
server: true | ||
}); | ||
|
||
new LoggerFile(Log2, { | ||
fileNameFormat: function(time) { | ||
return (time.getDate()) + "-" + (time.getMonth() + 1) + "-" + (time.getFullYear()) + "_" + (time.getHours()) + ".log"; | ||
}, | ||
format: function(time, level, message, data, userId) { | ||
return "[" + level + "] | " + (time.getMinutes()) + ":" + (time.getSeconds()) + " | \"" + message + "\" | User: " + userId + "\r\n"; | ||
}, | ||
path: '/data/logs/' | ||
}).enable({ | ||
client: false, | ||
server: true | ||
}); | ||
``` |
Oops, something went wrong.