lib/log4r/outputter/evernoteoutputter.rb in log4ever-0.0.6 vs lib/log4r/outputter/evernoteoutputter.rb in log4ever-0.0.7
- old
+ new
@@ -13,10 +13,17 @@
def initialize(_name, hash = {})
super(_name, hash)
validate(hash)
end
+
+ # synchronize note
+ def sync
+ @note = @evernote.get_note(@notebook)
+ set_maxsize(@hash) # for rolling
+ set_shift_age(@hash) # for rolling
+ end
# validation of evernote parameters
def validate(hash)
env = hash[:env] || hash['env'] || 'sandbox'
if env == 'sandbox'
@@ -31,20 +38,20 @@
notebook_name = hash[:notebook] || hash['notebook'] || ""
raise ArgumentError, "Must specify from notebook" if notebook_name.empty?
stack_name = hash[:stack] || hash['stack']
@evernote = MyEvernote.new(@env, @auth_token)
tags = @evernote.get_tags(hash[:tags] || hash['tags'] || [])
- notebook = @evernote.get_notebook(notebook_name, stack_name)
- @note = @evernote.get_note(notebook)
@tags = tags.map{|tag_obj| tag_obj.guid}
- set_maxsize(hash) # for rolling
- set_shift_age(hash) # for rolling
+ @notebook = @evernote.get_notebook(notebook_name, stack_name)
+ @hash = hash
+ sync
end
def canonical_log(logevent); super end
# write log
def write(content)
+ sync
if note_size_requires_roll? || time_requires_roll?
create_log(content)
else
update_log(content)
end
\ No newline at end of file