log4ever 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/.gitignore +33 -0
  2. data/.project +11 -0
  3. data/README.md +36 -0
  4. data/config/evernote.auth.test.yml +1 -0
  5. data/config/log4r.xml +19 -0
  6. data/lib/log4r/evernote/lib/Evernote/EDAM/errors_constants.rb +14 -0
  7. data/lib/log4r/evernote/lib/Evernote/EDAM/errors_types.rb +128 -0
  8. data/lib/log4r/evernote/lib/Evernote/EDAM/limits_constants.rb +240 -0
  9. data/lib/log4r/evernote/lib/Evernote/EDAM/limits_types.rb +13 -0
  10. data/lib/log4r/evernote/lib/Evernote/EDAM/note_store.rb +5487 -0
  11. data/lib/log4r/evernote/lib/Evernote/EDAM/note_store_constants.rb +14 -0
  12. data/lib/log4r/evernote/lib/Evernote/EDAM/note_store_types.rb +1012 -0
  13. data/lib/log4r/evernote/lib/Evernote/EDAM/types_constants.rb +20 -0
  14. data/lib/log4r/evernote/lib/Evernote/EDAM/types_types.rb +1792 -0
  15. data/lib/log4r/evernote/lib/Evernote/EDAM/user_store.rb +549 -0
  16. data/lib/log4r/evernote/lib/Evernote/EDAM/user_store_constants.rb +18 -0
  17. data/lib/log4r/evernote/lib/Evernote/EDAM/user_store_types.rb +415 -0
  18. data/lib/log4r/evernote/lib/thrift/client.rb +62 -0
  19. data/lib/log4r/evernote/lib/thrift/core_ext/fixnum.rb +29 -0
  20. data/lib/log4r/evernote/lib/thrift/core_ext.rb +23 -0
  21. data/lib/log4r/evernote/lib/thrift/exceptions.rb +84 -0
  22. data/lib/log4r/evernote/lib/thrift/processor.rb +57 -0
  23. data/lib/log4r/evernote/lib/thrift/protocol/base_protocol.rb +290 -0
  24. data/lib/log4r/evernote/lib/thrift/protocol/binary_protocol.rb +229 -0
  25. data/lib/log4r/evernote/lib/thrift/protocol/binary_protocol_accelerated.rb +39 -0
  26. data/lib/log4r/evernote/lib/thrift/protocol/compact_protocol.rb +426 -0
  27. data/lib/log4r/evernote/lib/thrift/serializer/deserializer.rb +33 -0
  28. data/lib/log4r/evernote/lib/thrift/serializer/serializer.rb +34 -0
  29. data/lib/log4r/evernote/lib/thrift/server/base_server.rb +31 -0
  30. data/lib/log4r/evernote/lib/thrift/server/mongrel_http_server.rb +58 -0
  31. data/lib/log4r/evernote/lib/thrift/server/nonblocking_server.rb +305 -0
  32. data/lib/log4r/evernote/lib/thrift/server/simple_server.rb +43 -0
  33. data/lib/log4r/evernote/lib/thrift/server/thread_pool_server.rb +75 -0
  34. data/lib/log4r/evernote/lib/thrift/server/threaded_server.rb +47 -0
  35. data/lib/log4r/evernote/lib/thrift/struct.rb +237 -0
  36. data/lib/log4r/evernote/lib/thrift/struct_union.rb +192 -0
  37. data/lib/log4r/evernote/lib/thrift/thrift_native.rb +24 -0
  38. data/lib/log4r/evernote/lib/thrift/transport/base_server_transport.rb +37 -0
  39. data/lib/log4r/evernote/lib/thrift/transport/base_transport.rb +107 -0
  40. data/lib/log4r/evernote/lib/thrift/transport/buffered_transport.rb +108 -0
  41. data/lib/log4r/evernote/lib/thrift/transport/framed_transport.rb +116 -0
  42. data/lib/log4r/evernote/lib/thrift/transport/http_client_transport.rb +53 -0
  43. data/lib/log4r/evernote/lib/thrift/transport/io_stream_transport.rb +39 -0
  44. data/lib/log4r/evernote/lib/thrift/transport/memory_buffer_transport.rb +125 -0
  45. data/lib/log4r/evernote/lib/thrift/transport/server_socket.rb +63 -0
  46. data/lib/log4r/evernote/lib/thrift/transport/socket.rb +137 -0
  47. data/lib/log4r/evernote/lib/thrift/transport/unix_server_socket.rb +60 -0
  48. data/lib/log4r/evernote/lib/thrift/transport/unix_socket.rb +40 -0
  49. data/lib/log4r/evernote/lib/thrift/types.rb +101 -0
  50. data/lib/log4r/evernote/lib/thrift/union.rb +179 -0
  51. data/lib/log4r/evernote/lib/thrift.rb +64 -0
  52. data/lib/log4r/evernote.rb +206 -0
  53. data/lib/log4r/outputter/evernoteoutputter.rb +156 -0
  54. data/spec/log4ever_spec.rb +94 -0
  55. data/spec/spec_helper.rb +14 -0
  56. metadata +105 -0
@@ -0,0 +1,64 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+ # Contains some contributions under the Thrift Software License.
20
+ # Please see doc/old-thrift-license.txt in the Thrift distribution for
21
+ # details.
22
+
23
+ $:.unshift File.dirname(__FILE__)
24
+
25
+ require 'thrift/core_ext'
26
+ require 'thrift/exceptions'
27
+ require 'thrift/types'
28
+ require 'thrift/processor'
29
+ require 'thrift/client'
30
+ require 'thrift/struct'
31
+ require 'thrift/union'
32
+ require 'thrift/struct_union'
33
+
34
+ # serializer
35
+ require 'thrift/serializer/serializer'
36
+ require 'thrift/serializer/deserializer'
37
+
38
+ # protocol
39
+ require 'thrift/protocol/base_protocol'
40
+ require 'thrift/protocol/binary_protocol'
41
+ require 'thrift/protocol/binary_protocol_accelerated'
42
+ require 'thrift/protocol/compact_protocol'
43
+
44
+ # transport
45
+ require 'thrift/transport/base_transport'
46
+ require 'thrift/transport/base_server_transport'
47
+ require 'thrift/transport/socket'
48
+ require 'thrift/transport/server_socket'
49
+ require 'thrift/transport/unix_socket'
50
+ require 'thrift/transport/unix_server_socket'
51
+ require 'thrift/transport/buffered_transport'
52
+ require 'thrift/transport/framed_transport'
53
+ require 'thrift/transport/http_client_transport'
54
+ require 'thrift/transport/io_stream_transport'
55
+ require 'thrift/transport/memory_buffer_transport'
56
+
57
+ # server
58
+ require 'thrift/server/base_server'
59
+ require 'thrift/server/nonblocking_server'
60
+ require 'thrift/server/simple_server'
61
+ require 'thrift/server/threaded_server'
62
+ require 'thrift/server/thread_pool_server'
63
+
64
+ require 'thrift/thrift_native'
@@ -0,0 +1,206 @@
1
+ # -*- coding: utf-8 -*-
2
+ $: << File.dirname(__FILE__) + "/evernote/lib"
3
+ $: << File.dirname(__FILE__) + "/evernote/lib/thrift"
4
+ $: << File.dirname(__FILE__) + "/evernote/lib/Evernote/EDAM"
5
+ require 'log4r/outputter/evernoteoutputter'
6
+ require "thrift/types"
7
+ require "thrift/struct"
8
+ require "thrift/protocol/base_protocol"
9
+ require "thrift/protocol/binary_protocol"
10
+ require "thrift/transport/base_transport"
11
+ require "thrift/transport/http_client_transport"
12
+ require "Evernote/EDAM/user_store"
13
+ require "Evernote/EDAM/user_store_constants.rb"
14
+ require "Evernote/EDAM/note_store"
15
+ require "Evernote/EDAM/limits_constants.rb"
16
+
17
+ module Log4ever
18
+ VERSION = '0.0.1'
19
+ class TypeError < StandardError; end
20
+ module ShiftAge
21
+ DAILY = 1
22
+ WEEKLY = 2
23
+ MONTHLY = 3
24
+ end
25
+ end
26
+
27
+ module Log4r
28
+ include Log4ever
29
+ class MyEvernote
30
+ @@note_store = nil
31
+ def initialize(env, auth_token)
32
+ if @@note_store.nil?
33
+ @env = env
34
+ @@auth_token = auth_token
35
+ userStoreTransport = Thrift::HTTPClientTransport.new(@env)
36
+ userStoreProtocol = Thrift::BinaryProtocol.new(userStoreTransport)
37
+ user_store = Evernote::EDAM::UserStore::UserStore::Client.new(userStoreProtocol)
38
+ noteStoreUrl = user_store.getNoteStoreUrl(@@auth_token)
39
+ noteStoreTransport = Thrift::HTTPClientTransport.new(noteStoreUrl)
40
+ noteStoreProtocol = Thrift::BinaryProtocol.new(noteStoreTransport)
41
+ @@note_store = Evernote::EDAM::NoteStore::NoteStore::Client.new(noteStoreProtocol)
42
+ end
43
+ end
44
+
45
+ # get registered notebook or create new notebook
46
+ def get_notebook(notebook_name, stack_name)
47
+ Notebook.new(notebook_name, stack_name)
48
+ end
49
+
50
+ # get registered note or create new note
51
+ def get_note(notebook_obj)
52
+ Note.new(notebook_obj)
53
+ end
54
+
55
+ # get registerd tag list
56
+ def get_tags(tag_names)
57
+ tag_names.map{|tag_name| get_tag(tag_name)}
58
+ end
59
+
60
+ # get registered tag object
61
+ def get_tag(tag_name)
62
+ return if tag_name.empty?
63
+ tag_name = to_ascii(tag_name)
64
+ @@note_store.listTags(@@auth_token).each do |tag|
65
+ return tag if tag_name == tag.name
66
+ end
67
+ nil
68
+ end
69
+
70
+ def to_ascii(str)
71
+ str.force_encoding("ASCII-8BIT") unless str.nil?
72
+ end
73
+ end
74
+
75
+ class Notebook < MyEvernote
76
+ def initialize(notebook_name, stack_name)
77
+ return unless @notebook.nil?
78
+ @@note_store.listNotebooks(@@auth_token).each do |notebook|
79
+ notebook_name = to_ascii(notebook_name)
80
+ stack_name = to_ascii(stack_name)
81
+ if notebook.name == notebook_name && notebook.stack == stack_name
82
+ @notebook = notebook
83
+ break
84
+ end
85
+ end
86
+ end
87
+
88
+ def guid; @notebook.guid end
89
+
90
+ # clear notebook object
91
+ def clear
92
+ @notebook = nil
93
+ initialize(@env, @@auth_token)
94
+ end
95
+ end
96
+
97
+ class Note < MyEvernote
98
+ XML_TEMPLATE_BYTE = 237
99
+
100
+ def initialize(notebook)
101
+ return unless @params.nil? || @params.empty?
102
+ @params = {}
103
+ @notebook = notebook
104
+ if !@notebook.kind_of? Notebook
105
+ raise TypeError, 'Expected kind of Notebook, got #{@notebook.class}', caller
106
+ elsif !@notebook.respond_to? 'guid'
107
+ raise NoMethodError, '#{@notebook.class} do not has method: guid', caller
108
+ end
109
+ getNote
110
+ end
111
+
112
+ # content size
113
+ def size
114
+ content.bytesize > 0 ? content.bytesize - XML_TEMPLATE_BYTE : 0
115
+ end
116
+
117
+ # note guid
118
+ def guid; @note.guid end
119
+
120
+ # set new title
121
+ def title=(str)
122
+ @params[:title] = to_ascii(str)
123
+ end
124
+
125
+ # set tags
126
+ def tags=(list)
127
+ @params[:tagGuids] = list
128
+ end
129
+
130
+ # append content
131
+ def addContent(text)
132
+ new_html = "<div style='font-family: Courier New'>#{text}</div>"
133
+ content_xml.at('en-note').inner_html += new_html
134
+ @params[:content] = @content_ = to_ascii(content_xml.to_xml)
135
+ end
136
+
137
+ # set new content
138
+ def content=(text)
139
+ @params[:content] = @content_ = to_ascii("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
140
+ "<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">\n" +
141
+ "<en-note style=\"word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;\">\n" +
142
+ "<div style=\"font-family: Courier New\">#{text}</div></en-note>")
143
+ end
144
+
145
+ # create note
146
+ def create
147
+ @@note_store.createNote(@@auth_token, createNote)
148
+ clear
149
+ end
150
+
151
+ # update note
152
+ def update
153
+ @@note_store.updateNote(@@auth_token, updateNote)
154
+ end
155
+
156
+ # clear note object
157
+ def clear
158
+ @params = {}
159
+ @note = @content_ = @content_xml = nil
160
+ initialize(@notebook)
161
+ end
162
+
163
+ def getNote
164
+ filter = Evernote::EDAM::NoteStore::NoteFilter.new
165
+ filter.order = Evernote::EDAM::Type::NoteSortOrder::CREATED
166
+ filter.notebookGuid = @notebook.guid
167
+ filter.timeZone = "Asia/Tokyo"
168
+ filter.ascending = false # descending
169
+ note_list = @@note_store.findNotes(@@auth_token, filter, 0, 1)
170
+ if note_list.notes.empty?
171
+ Logger.log_internal { "Note not found at #{@notebook.guid}" }
172
+ @note = Evernote::EDAM::Type::Note.new
173
+ else
174
+ @note = note_list.notes[0]
175
+ end
176
+ @note
177
+ end
178
+
179
+ # create note object
180
+ def createNote
181
+ @note = Evernote::EDAM::Type::Note.new
182
+ @note.notebookGuid = @notebook.guid
183
+ @params.each{|method, value| @note.send("#{method.to_s}=", value)}
184
+ @note
185
+ end
186
+
187
+ # get note object
188
+ def updateNote
189
+ getNote if @note.nil?
190
+ @note.content = @params[:content]
191
+ @note
192
+ end
193
+
194
+ # get note content text
195
+ def content
196
+ return @content_ unless @content_.nil?
197
+ @content_ = !@note.nil? && !@note.guid.nil? ? @@note_store.getNoteContent(@@auth_token, @note.guid) : ""
198
+ end
199
+
200
+ # get note content xml object
201
+ def content_xml
202
+ return @content_xml unless @content_xml.nil?
203
+ @content_xml = Nokogiri::XML(content)
204
+ end
205
+ end
206
+ end
@@ -0,0 +1,156 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'nokogiri'
3
+ require 'log4r/outputter/outputter'
4
+ require "log4r/staticlogger"
5
+ require 'active_support'
6
+ require 'active_support/time'
7
+ require 'active_support/core_ext'
8
+
9
+ module Log4r
10
+ class EvernoteOutputter < Outputter
11
+ SANDBOX_HOST = 'sandbox.evernote.com'
12
+ PRODUCTION_HOST = 'www.evernote.com'
13
+
14
+ def initialize(_name, hash = {})
15
+ super(_name, hash)
16
+ validate(hash)
17
+ end
18
+
19
+ # validation of evernote parameters
20
+ def validate(hash)
21
+ set_maxsize(hash) # for rolling
22
+ set_shift_age(hash) # for roling
23
+
24
+ env = hash[:env] || hash['env'] || 'sandbox'
25
+ if env == 'sandbox'
26
+ @env = "https://#{SANDBOX_HOST}/edam/user"
27
+ elsif env == 'production'
28
+ @env = "https://#{PRODUCTION_HOST}/edam/user"
29
+ else
30
+ raise ArgumentError, "Must specify from env 'sandbox' or 'production'"
31
+ end
32
+ @auth_token = hash[:auth_token] || hash['auth_token'] || ""
33
+ raise ArgumentError, "Must specify from auth token" if @auth_token.empty?
34
+ @evernote = MyEvernote.new(@env, @auth_token)
35
+ notebook = hash[:notebook] || hash['notebook'] || ""
36
+ raise ArgumentError, "Must specify from notebook" if notebook.empty?
37
+ tags = @evernote.get_tags(hash[:tags] || hash['tags'] || [])
38
+ stack = hash[:stack] || hash['stack']
39
+ @evernote = MyEvernote.new(@env, @auth_token)
40
+ @notebook = @evernote.get_notebook(notebook, stack)
41
+ @note = @evernote.get_note(@notebook)
42
+ @tags = tags.map{|tag_obj| tag_obj.guid}
43
+ end
44
+
45
+ def canonical_log(logevent); super end
46
+
47
+ def write(content)
48
+ @content = content
49
+ if note_size_requires_roll? || time_requires_roll?
50
+ create_log
51
+ else
52
+ update_log
53
+ end
54
+ end
55
+
56
+ private
57
+ def create_log
58
+ @note.clear
59
+ @note.title = @name + " - " + Time.now.strftime("%Y-%m-%d %H:%M:%S")
60
+ @note.tags = @tags
61
+ @note.content = @content
62
+ @note.create
63
+ Logger.log_internal { "Create note: #{@note.guid}" }
64
+ end
65
+
66
+ def update_log
67
+ @note.addContent(@content)
68
+ @note.update
69
+ Logger.log_internal { "Update note: #{@note.guid}" }
70
+ end
71
+
72
+ # more expensive, only for startup
73
+ def note_size_requires_roll?
74
+ @note.size == 0 || (@maxsize > 0 && @note.size >= @maxsize)
75
+ end
76
+
77
+ def time_requires_roll?
78
+ !@endTime.nil? && Time.now.to_i >= @endTime
79
+ end
80
+
81
+ def set_maxsize(options)
82
+ if options.has_key?(:maxsize) || options.has_key?('maxsize')
83
+ maxsize = options[:maxsize] || options['maxsize']
84
+
85
+ multiplier = 1
86
+ if (maxsize =~ /\d+KB/)
87
+ multiplier = 1024
88
+ elsif (maxsize =~ /\d+MB/)
89
+ multiplier = 1024 * 1024
90
+ elsif (maxsize =~ /\d+GB/)
91
+ multiplier = 1024 * 1024 * 1024
92
+ end
93
+
94
+ _maxsize = maxsize.to_i * multiplier
95
+
96
+ if _maxsize.class != Fixnum and _maxsize.class != Bignum
97
+ raise TypeError, "Argument 'maxsize' must be an Fixnum", caller
98
+ end
99
+ if _maxsize == 0
100
+ raise TypeError, "Argument 'maxsize' must be > 0", caller
101
+ end
102
+ @maxsize = _maxsize
103
+ else
104
+ @maxsize = 0
105
+ end
106
+ end
107
+
108
+ def set_maxtime(options)
109
+ if options.has_key?(:maxtime) || options.has_key?('maxtime')
110
+ _maxtime = (options[:maxtime] or options['maxtime']).to_i
111
+ if _maxtime.class != Fixnum
112
+ raise TypeError, "Argument 'maxtime' must be an Fixnum", caller
113
+ end
114
+ if _maxtime == 0
115
+ raise TypeError, "Argument 'maxtime' must be > 0", caller
116
+ end
117
+ @maxtime = _maxtime
118
+ @startTime = Time.now
119
+ else
120
+ @maxtime = 0
121
+ @startTime = 0
122
+ end
123
+ end
124
+
125
+ def set_shift_age(options)
126
+ if options.has_key?(:shift_age) || options.has_key?('shift_age')
127
+ _shift_age = (options[:shift_age] or options['shift_age']).to_i
128
+ if _shift_age.class != Fixnum
129
+ raise TypeError, "Argument 'shift_age' must be an Fixnum", caller
130
+ end
131
+ unless _shift_age.nil?
132
+ unless [Log4ever::ShiftAge::DAILY, Log4ever::ShiftAge::WEEKLY,
133
+ Log4ever::ShiftAge::MONTHLY].include? _shift_age
134
+ raise TypeError, "Argument 'shift_age' must be > 0", caller
135
+ end
136
+
137
+ now = Time.now
138
+ case _shift_age
139
+ when Log4ever::ShiftAge::DAILY
140
+ tomorrow = Time.local(now.tomorrow.year, now.tomorrow.month, now.tomorrow.day)
141
+ @endTime = tomorrow.to_i
142
+ when Log4ever::ShiftAge::WEEKLY
143
+ next_week = Time.local(now.next_week.year, now.next_week.month, now.next_week.day)
144
+ @endTime = next_week.to_i
145
+ when Log4ever::ShiftAge::MONTHLY
146
+ next_month = Time.local(now.next_month.year, now.next_month.month, now.next_month.day)
147
+ @endTime = next_month.to_i
148
+ else
149
+ raise TypeError, "Argument 'shift_age' must be '1' or '2' or '3'", caller
150
+ end
151
+ end
152
+ end
153
+ end
154
+ end
155
+
156
+ end
@@ -0,0 +1,94 @@
1
+ # -*- coding: utf-8 -*-
2
+ $: << File.dirname(__FILE__) + "/../lib"
3
+ require 'log4r'
4
+ require 'log4r/evernote'
5
+ require 'log4r/configurator'
6
+ require File.expand_path(File.dirname(__FILE__) + '/../spec/spec_helper')
7
+
8
+ describe Log4ever, 'が実行する処理' do
9
+ include Log4r
10
+ LOGGER_NAME = 'Log4ever'
11
+
12
+ before do
13
+ @formatter = PatternFormatter.new(
14
+ :pattern => "%d %C[%l]: %M ",
15
+ :date_format => "%Y/%m/%d %H:%M:%Sm"
16
+ )
17
+ @params = {
18
+ :env => "production",
19
+ :auth_token => Log4ever::evernote_auth,
20
+ :stack => "Log4ever",
21
+ :notebook => "DevelopmentLog",
22
+ :tags => ['Log'],
23
+ :maxsize => 500,
24
+ #:shift_age => Log4ever::ShiftAge::DAILY,
25
+ :formatter => @formatter
26
+ }
27
+ end
28
+
29
+ let(:logger) {Logger.new(LOGGER_NAME)}
30
+ let(:evernoteOutputter) {
31
+ EvernoteOutputter.new('evernote', @params)
32
+ }
33
+
34
+ before do
35
+ @config_xml = Log4ever::config_xml
36
+ end
37
+
38
+ describe 'Log4rのEvernote書き出し処理' do
39
+ it '書き出しが成功すること' do
40
+ log_content = "aaa"
41
+ formatter_content = "\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\s.*?\[.*?\]:\s(.*)\\n"
42
+
43
+ logger.outputters = evernoteOutputter
44
+ logger.debug(log_content)
45
+
46
+ @evernote = MyEvernote.new(@params[:env], @params[:auth_token])
47
+ @notebook = @evernote.get_notebook(@params[:notebook], @params[:stack])
48
+ @note = @evernote.get_note(@notebook)
49
+ write_log = @note.content_xml.children[1].children.reverse[1].text
50
+ if /\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\s.*?\[.*?\]:\s(.*)/ =~ write_log
51
+ log_content.should == $1.strip
52
+ else
53
+ "".should be_nil
54
+ end
55
+ end
56
+ end
57
+
58
+ describe 'Log4rの初期化処理(正常系)' do
59
+ it 'パラメータのチェックでエラーが出ないこと' do
60
+ logger.outputters = EvernoteOutputter.new(LOGGER_NAME, @params)
61
+ logger.name.should == LOGGER_NAME
62
+ end
63
+
64
+ it 'XMLから読み込んだパラメータのチェックでエラーが出ないこと' do
65
+ Configurator.load_xml_file(@config_xml).should_not be_nil
66
+ end
67
+ end
68
+
69
+ describe 'Log4rの初期化処理(異常系)' do
70
+ it "envパラメータのチェックでエラーが出ること" do
71
+ proc {
72
+ logger.outputters = EvernoteOutputter.new(LOGGER_NAME, @params.merge(
73
+ :env => "aaa"
74
+ ))
75
+ }.should raise_error(ArgumentError)
76
+ end
77
+
78
+ it "auth_token必須パラメータのチェックでエラーが出ること" do
79
+ proc {
80
+ logger.outputters = EvernoteOutputter.new(LOGGER_NAME, @params.merge(
81
+ :auth_token => nil
82
+ ))
83
+ }.should raise_error(ArgumentError)
84
+ end
85
+
86
+ it "notebook必須パラメータのチェックでエラーが出ること" do
87
+ proc {
88
+ logger.outputters = EvernoteOutputter.new(LOGGER_NAME, @params.merge(
89
+ :notebook => nil
90
+ ))
91
+ }.should raise_error(ArgumentError)
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,14 @@
1
+ require 'rspec'
2
+
3
+ module Log4ever
4
+ class << self
5
+ def config_xml
6
+ File.dirname(__FILE__) + "/../config/log4r.xml"
7
+ end
8
+
9
+ def evernote_auth
10
+ path = File.dirname(__FILE__) + "/../config/evernote.auth.yml"
11
+ YAML.load_file(path)["auth_token"]
12
+ end
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: log4ever
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - mapserver2007
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-06 00:00:00.000000000 +09:00
13
+ default_executable:
14
+ dependencies: []
15
+ description: log4ever is simple logger for evernote. It is available as an extension
16
+ of log4r.
17
+ email:
18
+ - mapserver2007@gmail.com
19
+ executables: []
20
+ extensions: []
21
+ extra_rdoc_files: []
22
+ files:
23
+ - .gitignore
24
+ - .project
25
+ - README.md
26
+ - config/evernote.auth.test.yml
27
+ - config/log4r.xml
28
+ - lib/log4r/evernote.rb
29
+ - lib/log4r/evernote/lib/Evernote/EDAM/errors_constants.rb
30
+ - lib/log4r/evernote/lib/Evernote/EDAM/errors_types.rb
31
+ - lib/log4r/evernote/lib/Evernote/EDAM/limits_constants.rb
32
+ - lib/log4r/evernote/lib/Evernote/EDAM/limits_types.rb
33
+ - lib/log4r/evernote/lib/Evernote/EDAM/note_store.rb
34
+ - lib/log4r/evernote/lib/Evernote/EDAM/note_store_constants.rb
35
+ - lib/log4r/evernote/lib/Evernote/EDAM/note_store_types.rb
36
+ - lib/log4r/evernote/lib/Evernote/EDAM/types_constants.rb
37
+ - lib/log4r/evernote/lib/Evernote/EDAM/types_types.rb
38
+ - lib/log4r/evernote/lib/Evernote/EDAM/user_store.rb
39
+ - lib/log4r/evernote/lib/Evernote/EDAM/user_store_constants.rb
40
+ - lib/log4r/evernote/lib/Evernote/EDAM/user_store_types.rb
41
+ - lib/log4r/evernote/lib/thrift.rb
42
+ - lib/log4r/evernote/lib/thrift/client.rb
43
+ - lib/log4r/evernote/lib/thrift/core_ext.rb
44
+ - lib/log4r/evernote/lib/thrift/core_ext/fixnum.rb
45
+ - lib/log4r/evernote/lib/thrift/exceptions.rb
46
+ - lib/log4r/evernote/lib/thrift/processor.rb
47
+ - lib/log4r/evernote/lib/thrift/protocol/base_protocol.rb
48
+ - lib/log4r/evernote/lib/thrift/protocol/binary_protocol.rb
49
+ - lib/log4r/evernote/lib/thrift/protocol/binary_protocol_accelerated.rb
50
+ - lib/log4r/evernote/lib/thrift/protocol/compact_protocol.rb
51
+ - lib/log4r/evernote/lib/thrift/serializer/deserializer.rb
52
+ - lib/log4r/evernote/lib/thrift/serializer/serializer.rb
53
+ - lib/log4r/evernote/lib/thrift/server/base_server.rb
54
+ - lib/log4r/evernote/lib/thrift/server/mongrel_http_server.rb
55
+ - lib/log4r/evernote/lib/thrift/server/nonblocking_server.rb
56
+ - lib/log4r/evernote/lib/thrift/server/simple_server.rb
57
+ - lib/log4r/evernote/lib/thrift/server/thread_pool_server.rb
58
+ - lib/log4r/evernote/lib/thrift/server/threaded_server.rb
59
+ - lib/log4r/evernote/lib/thrift/struct.rb
60
+ - lib/log4r/evernote/lib/thrift/struct_union.rb
61
+ - lib/log4r/evernote/lib/thrift/thrift_native.rb
62
+ - lib/log4r/evernote/lib/thrift/transport/base_server_transport.rb
63
+ - lib/log4r/evernote/lib/thrift/transport/base_transport.rb
64
+ - lib/log4r/evernote/lib/thrift/transport/buffered_transport.rb
65
+ - lib/log4r/evernote/lib/thrift/transport/framed_transport.rb
66
+ - lib/log4r/evernote/lib/thrift/transport/http_client_transport.rb
67
+ - lib/log4r/evernote/lib/thrift/transport/io_stream_transport.rb
68
+ - lib/log4r/evernote/lib/thrift/transport/memory_buffer_transport.rb
69
+ - lib/log4r/evernote/lib/thrift/transport/server_socket.rb
70
+ - lib/log4r/evernote/lib/thrift/transport/socket.rb
71
+ - lib/log4r/evernote/lib/thrift/transport/unix_server_socket.rb
72
+ - lib/log4r/evernote/lib/thrift/transport/unix_socket.rb
73
+ - lib/log4r/evernote/lib/thrift/types.rb
74
+ - lib/log4r/evernote/lib/thrift/union.rb
75
+ - lib/log4r/outputter/evernoteoutputter.rb
76
+ - spec/log4ever_spec.rb
77
+ - spec/spec_helper.rb
78
+ has_rdoc: true
79
+ homepage: https://github.com/mapserver2007/log4ever
80
+ licenses: []
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 1.6.2
100
+ signing_key:
101
+ specification_version: 3
102
+ summary: log4ever is simple logger for evernote.
103
+ test_files:
104
+ - spec/log4ever_spec.rb
105
+ - spec/spec_helper.rb