logzomg 0.1.0.3 → 0.1.0.3.1
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.
- checksums.yaml +4 -4
- data/lib/logzomg/version.rb +1 -1
- data/lib/logzomg.rb +8 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3edce9006c7d9c5d0fb96daa8671efffd8693819
|
4
|
+
data.tar.gz: 177c2829fa844c7ce3cd52288b309281e34e183e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e79975670e86e61d65629da16c9bc4c85971e111ccf469e756a38873c0b4a1b6a8037eabd9fdebda2b18c72b571efa4fc705038dc29de5c9fb54251d6893b69d
|
7
|
+
data.tar.gz: 4f6872fa4d8085c88a5164cc64e62590fc578cf0dfe6588a9e086df0803b89628a1881452a743010b3c52b8df6dae853674424c413a29aa9c7b9e90a3acbc268
|
data/lib/logzomg/version.rb
CHANGED
data/lib/logzomg.rb
CHANGED
@@ -4,15 +4,16 @@ require "logzomg/version"
|
|
4
4
|
module Logzomg
|
5
5
|
class Logger
|
6
6
|
# TODO change this to proper file path
|
7
|
-
LOG_PATH = File.expand_path(Rails.root.join('logs',__FILE__))
|
8
7
|
LEVELS = ['debug','info','warning','error','fatal']
|
9
8
|
|
10
9
|
UnsupportedType = Class.new(StandardError)
|
11
10
|
UnsupportedLevel = Class.new(StandardError)
|
12
11
|
|
12
|
+
attr_accessor :log_path
|
13
|
+
|
13
14
|
def initialize(**args, &block)
|
14
15
|
# Set some default values
|
15
|
-
|
16
|
+
@log_path = File.expand_path(get_path + '/log/')
|
16
17
|
@level = args[:level] ? args[:level] : "warning"
|
17
18
|
@formatter = args[:formatter] ? args[:formatter] : TextFormatter.new {|f| f.with_color = true}
|
18
19
|
if block_given?
|
@@ -96,9 +97,13 @@ module Logzomg
|
|
96
97
|
# If given one in hash[:file] use that
|
97
98
|
def write(hash, msg)
|
98
99
|
file = hash.has_key?(:file) ? "/" + hash[:file] : '/log.txt'
|
99
|
-
File.open(
|
100
|
+
File.open(@log_path + file, 'a') {|f| f.write(msg) }
|
100
101
|
end
|
101
102
|
|
103
|
+
def get_path
|
104
|
+
Dir.pwd
|
105
|
+
end
|
106
|
+
|
102
107
|
# Checks if message is hash
|
103
108
|
def valid_hash?(hash)
|
104
109
|
return hash.class == Hash
|