mlserver 1.0.1 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 565870637b0850519fc89c56d3aa2dbf8a400d26577440d81b1db195ce4eae78
4
- data.tar.gz: 8632c4624dcd90c02a76ba2437a92ca74d3fa4d93c709f3e75b0332f0f5b668b
3
+ metadata.gz: 86fe66bb2ece6aa1aeb92f25f69b88d266f8743bf9b931aa40bfdd1a22945fba
4
+ data.tar.gz: f1a46e419ab1b5474006064c28593a14f1f741bc6bdfd95fa68463bb45507346
5
5
  SHA512:
6
- metadata.gz: beb25988af8aeda7895d8fbc794c1cf9f4c3d6b9efc32ad9886bf09534eff26c525d0d2a5108d34d0d265029524d3c9a4615fc1d36df7ad2420dc0e450ea9d89
7
- data.tar.gz: a07ce050c8f7efd559218c5ed1ca9f852aa582cb0186ff35f7ac644e3dedc0849fda84d0cabbf4dbff9bf6a4b4d035f257b7a509eee7e7128b4fa35eac4f3e54
6
+ metadata.gz: 9e0813a7844e61e75e1fb5bc95271bed3c1f7af903055aa16e8293d0c588669e67c172f05810d3dd7b74d1ca49351a771ef34877b88c2eddb78066aca3166bb9
7
+ data.tar.gz: 39c3f002aa07a6fd5e36e69748b1a0432d3d6bf7e9d438efd0ff977660d40c4bb6ce4322e8014d05dcd2df01d8bea99390412ec4358edfb1c2e1e522426c94ef
data/bin/mlserver CHANGED
@@ -11,6 +11,24 @@ s = {}
11
11
  x = ArgsParser::Args.new(options: o, switches: s)
12
12
 
13
13
  conf_file = x.data[0]
14
- require_relative conf_file
14
+
15
+ if !conf_file
16
+ conf_file = "mlserver.conf.rb"
17
+ end
18
+
19
+ if File.directory?(conf_file)
20
+ conf_file = "#{conf_file}/mlserver.conf.rb"
21
+ end
22
+
23
+ if !File.exist?(conf_file)
24
+ STDERR.puts "Error: Conf file does not exist"
25
+ exit 1
26
+ end
27
+
28
+ full_conf_file_path = File.expand_path(conf_file, Dir.pwd)
29
+
30
+ Dir.chdir(File.dirname full_conf_file_path)
31
+
32
+ require full_conf_file_path
15
33
 
16
34
  MLserver::Server.start()
@@ -1,12 +1,13 @@
1
1
  module MLserver
2
2
  class Logger
3
- @@log_levels = [:info, :warn, :error]
3
+ @@log_levels = [:info, :warn, :error, :traffic_in, :traffic_out]
4
4
 
5
- def initialize(out:, err:, log_colors: {}, outputs: {error: :err})
5
+ def initialize(out:, err:, log_colors: {}, outputs: {error: :err}, levels_with_timestamp: [:traffic_in, :traffic_out])
6
6
  @out = out
7
7
  @err = err
8
8
  @log_colors = log_colors
9
9
  @outputs = outputs
10
+ @levels_with_timestamp = levels_with_timestamp
10
11
  end
11
12
 
12
13
  def log(message, level = :info)
@@ -16,6 +17,9 @@ module MLserver
16
17
  if @log_colors[level]
17
18
  message = message.color @log_colors[level]
18
19
  end
20
+
21
+ message = "#{Time.now} | #{message}" if @levels_with_timestamp.include?(level)
22
+
19
23
  out.puts message
20
24
  end
21
25
 
@@ -38,13 +42,15 @@ module MLserver
38
42
  def log_traffic(ip, direction, data)
39
43
  symbol = (direction == :incoming ? "=>" : "<=")
40
44
 
41
- log("#{format_ip_address ip} #{symbol} #{data}")
45
+ log("#{format_ip_address ip} #{symbol} #{data}", (direction == :incoming ? :traffic_in : :traffic_out))
42
46
  end
43
47
  end
44
48
 
45
49
  dlcolors = {
46
50
  warn: :yellow,
47
- error: :red
51
+ error: :red,
52
+ traffic_in: :green,
53
+ traffic_out: :blue
48
54
  }
49
55
 
50
56
  DefaultLogger = Logger.new(out: STDOUT, err: STDERR, log_colors: dlcolors)
data/lib/MLserver.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module MLserver
2
2
  def self.version
3
- "1.0.1"
3
+ "1.0.2"
4
4
  end
5
5
  end
6
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mlserver
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthias Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-29 00:00:00.000000000 Z
11
+ date: 2023-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: argparse