uniq_logger 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- uniq_logger (0.1.3)
4
+ uniq_logger (0.1.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # UniqLogger
2
2
 
3
- TODO: Write a gem description
3
+ - Add entries to an logfile, only if an uniq id is not already used.
4
+ - automaticaly generate logfile rotations: new logfile für every day, motnh or year
5
+ - send your logentries to another server per api using the same gem once as client and as a server
6
+ - creates an CSV formated file which can be easely opened in e.g. Excel for endusers
4
7
 
5
8
  ## Installation
6
9
 
@@ -20,7 +23,63 @@ Or install it yourself as:
20
23
 
21
24
  ## Usage
22
25
 
23
- TODO: Write usage instructions here
26
+ Create a configuration file config/uniq_logger.yml (view section 'Configuration')
27
+
28
+ To create a logentry use:
29
+
30
+ ```ruby
31
+ require 'uniq_logger'
32
+ uniq_logger = UniqLogger.new
33
+ uniq_logger.create("UniqID", ["data","to","save"] )
34
+ ```
35
+
36
+ ## Configuration File
37
+
38
+ app/config/uniq_logger.yml
39
+
40
+ ```yml
41
+ #Use a additional Log-Rotator which generates new logfiles for ['day','month','year'].
42
+ #Default 'none'
43
+ log_rotator: "month"
44
+
45
+ #If log_rotator is set, this will be the prefix for the file name
46
+ log_rotator_prefix: "uniq_logger-"
47
+
48
+
49
+ #Use a global LogFile [true,false]. Chech for existin logs only looks in global logfile
50
+ #Default true
51
+ global_logger: true
52
+
53
+ #Name of the logfile to write to
54
+ global_log_file_name: "uniq_logger.log"
55
+
56
+
57
+ #if set to true, logentry creation returns 'false' if a logentry already exists with this ID
58
+ # This is only on global Logfiles possible
59
+ validates_uniqness_of_id: true
60
+
61
+ #If a local Logfile should be created or a ftp Account ['local', 'remote']
62
+ logfile_destination: "local"
63
+
64
+ #Path where Logfiles should be saved
65
+ path_to_local_logfiles: "../log/"
66
+
67
+ #If logfile_destination is set to 'remote' use folloing api credentials
68
+ remote:
69
+ auth_token: "xyz123abc"
70
+ server: "http://www.server.de"
71
+ endpoint: "/api/v1/logger"
72
+ url_param_for_id: "id"
73
+ url_param_for_data: "data"
74
+ basic_auth:
75
+ username: ""
76
+ password: ""
77
+
78
+ #CSV Export Settings: Encoding Type (default 'utf8'), Column Separator (default ';')
79
+ csv:
80
+ encoding: "UTF8"
81
+ col_sep: ";"
82
+ ```
24
83
 
25
84
  ## Contributing
26
85
 
@@ -14,7 +14,7 @@ module UniqLogger
14
14
  elsif config["logfile_destination"] == "remote"
15
15
  create_remote_log_entry(uniq_id, data_to_save)
16
16
  else
17
- puts "logfile_destination is not set to [local,ftp]"
17
+ puts "logfile_destination is not set to [local,remote]"
18
18
  return false
19
19
  end
20
20
  end
@@ -27,7 +27,7 @@ module UniqLogger
27
27
  logfilename = File.join(config["path_to_local_logfiles"], config["global_log_file_name"])
28
28
  logfile = File.open( File.expand_path(logfilename), "a" )
29
29
 
30
- if is_uniq_id_in_log_hostory?(uniq_id,logfile)
30
+ if is_uniq_id_in_log_history?(uniq_id,logfile)
31
31
  return false
32
32
  end
33
33
 
@@ -49,14 +49,10 @@ module UniqLogger
49
49
  end
50
50
 
51
51
 
52
- def is_uniq_id_in_log_hostory?(uniq_id,logfile)
52
+ def is_uniq_id_in_log_history?(uniq_id,logfile)
53
53
  if config["validates_uniqness_of_id"] == true
54
- data = CSV.read(logfile, {:col_sep => config["csv"]["col_sep"], :encoding => config["csv"]["encoding"] })
55
- list_of_ids = data.map{ |a| a[0]}
56
- #puts data
57
- if list_of_ids.include?(uniq_id)
58
- return true
59
- end
54
+ regexp_uniq_id = /^#{uniq_id};/
55
+ return open(logfile).grep(regexp_uniq_id).any?
60
56
  end
61
57
  return false
62
58
  end
@@ -1,3 +1,3 @@
1
1
  module UniqLogger
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -27,6 +27,8 @@ describe UniqLogger::Base do
27
27
  end
28
28
 
29
29
  it 'should write a log to a logfile with validation of ID true' do
30
+ expect(@logger.create("12343", ["Vorname", "12344", "Strasse"])).to eq(true)
31
+ expect(@logger.create("12344", ["Vorname", "12343", "Strasse"])).to eq(true)
30
32
  expect(@logger.create("12345", ["Vorname", "Nachname", "Strasse"])).to eq(true)
31
33
  expect(@logger.create("12346", ["Vorname2", "Nachname2", "Strasse2"])).to eq(true)
32
34
  expect(@logger.create("12346", ["Vorname3", "Nachname3", "Strasse3"])).to eq(false)
Binary file
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Marco Metz"]
10
10
  spec.email = ["marco.metz@gmail.com"]
11
11
  spec.summary = %q{checks for existing Logentries and adds new LogEntries}
12
- spec.description = %q{Adds Entries to an Logfile, only if not already exist. Logfile can be on an ftp account}
12
+ spec.description = %q{Adds entries to a logfile, only if they don't already exist. The logfile can be on a remote server}
13
13
  spec.homepage = "https://github.com/ikuseiGmbH/uniq_logger"
14
14
  spec.license = "GNU GENERAL PUBLIC LICENSE"
15
15
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uniq_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-01-29 00:00:00.000000000 Z
12
+ date: 2015-01-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -91,8 +91,8 @@ dependencies:
91
91
  - - ! '>='
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
- description: Adds Entries to an Logfile, only if not already exist. Logfile can be
95
- on an ftp account
94
+ description: Adds entries to a logfile, only if they don't already exist. The logfile
95
+ can be on a remote server
96
96
  email:
97
97
  - marco.metz@gmail.com
98
98
  executables: []
@@ -116,6 +116,7 @@ files:
116
116
  - template/uniq_logger.yml
117
117
  - uniq_logger-0.1.1.gem
118
118
  - uniq_logger-0.1.2.gem
119
+ - uniq_logger-0.1.4.gem
119
120
  - uniq_logger.gemspec
120
121
  homepage: https://github.com/ikuseiGmbH/uniq_logger
121
122
  licenses: