Class: Log4r::EvernoteOutputter
- Inherits:
-
Outputter
- Object
- Outputter
- Log4r::EvernoteOutputter
- Defined in:
- lib/log4r/outputter/evernoteoutputter.rb
Instance Method Summary collapse
- #canonical_log(logevent) ⇒ Object
-
#initialize(_name, hash = {}) ⇒ EvernoteOutputter
constructor
A new instance of EvernoteOutputter.
-
#sync_note ⇒ Object
sync.
-
#validate(hash) ⇒ Object
validation of evernote parameters.
-
#write(content) ⇒ Object
write log.
Constructor Details
#initialize(_name, hash = {}) ⇒ EvernoteOutputter
Returns a new instance of EvernoteOutputter.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/log4r/outputter/evernoteoutputter.rb', line 13 def initialize(_name, hash = {}) super(_name, hash) validate(hash) evernote = Log4ever::Evernote.new(@auth_token, @is_sandbox) @notebook = evernote.notebook.get(@notebook_name, @stack_name) @note = evernote.note(@notebook) @tag = evernote.tag(@note) @tag.names = @tags set_maxsize(hash) # for rolling set_shift_age(hash) # for rolling @hash = hash end |
Instance Method Details
#canonical_log(logevent) ⇒ Object
38 |
# File 'lib/log4r/outputter/evernoteoutputter.rb', line 38 def canonical_log(logevent); super end |
#sync_note ⇒ Object
sync
41 42 43 44 |
# File 'lib/log4r/outputter/evernoteoutputter.rb', line 41 def sync_note @note.get! update_maxtime(@hash) # update rolling status end |
#validate(hash) ⇒ Object
validation of evernote parameters
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/log4r/outputter/evernoteoutputter.rb', line 27 def validate(hash) @is_sandbox = hash[:sandbox] || hash['sandbox'] || false raise ArgumentError, "Sandbox must be type of boolean" unless @is_sandbox == false || @is_sandbox == true @auth_token = hash[:auth_token] || hash['auth_token'] || "" raise ArgumentError, "Must specify from auth token" if @auth_token.empty? @notebook_name = to_utf8(hash[:notebook] || hash['notebook'] || "") raise ArgumentError, "Must specify from notebook" if @notebook_name.empty? @stack_name = to_utf8(hash[:stack] || hash['stack']) @tags = to_utf8(hash[:tags] || hash['tags'] || []) end |
#write(content) ⇒ Object
write log
47 48 49 50 51 52 53 54 |
# File 'lib/log4r/outputter/evernoteoutputter.rb', line 47 def write(content) if note_size_requires_roll? || time_requires_roll? || different_tag? create_log(content) sync_note else update_log(content) end end |