supso 0.10.0
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 +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/DEV_README.md +28 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +8 -0
- data/README.md +25 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/bin/supso +6 -0
- data/docs/README.md +7 -0
- data/docs/commands/README.md +14 -0
- data/docs/commands/help.md +10 -0
- data/docs/commands/login.md +10 -0
- data/docs/commands/logout.md +7 -0
- data/docs/commands/show.md +21 -0
- data/docs/commands/update.md +7 -0
- data/docs/commands/version.md +12 -0
- data/docs/commands/whoami.md +5 -0
- data/docs/contents.yml +17 -0
- data/docs/errors/README.md +6 -0
- data/docs/errors/invalid_project_token.md +4 -0
- data/docs/errors/missing_project_token.md +4 -0
- data/docs/overview/README.md +16 -0
- data/docs/overview/getting_started.md +15 -0
- data/lib/helpers/module_vars.rb +19 -0
- data/lib/other/supso2.pub +9 -0
- data/lib/super_source/project.rb +9 -0
- data/lib/supso/commands.rb +155 -0
- data/lib/supso/config.rb +16 -0
- data/lib/supso/javascript.rb +57 -0
- data/lib/supso/logs.rb +49 -0
- data/lib/supso/organization.rb +95 -0
- data/lib/supso/project.rb +218 -0
- data/lib/supso/updater.rb +91 -0
- data/lib/supso/user.rb +161 -0
- data/lib/supso/util.rb +129 -0
- data/lib/supso/version.rb +8 -0
- data/lib/supso.rb +31 -0
- data/lib/templates/project_dir_readme.txt +44 -0
- data/lib/templates/user_dir_readme.txt +8 -0
- data/supso.gemspec +26 -0
- metadata +145 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dd3d0c661894c025b644939402b512d0a856a749
|
4
|
+
data.tar.gz: 296bd55c43d99e08ce1a4e84de3099f58ec6febb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9c207f50f11ff0b211b6aba820f06f035f2dfc0b79b649b012add56314ba55b70a21583042813ab669d2a85929a24db21b58ac899d13d1e72ca9557e14b3c979
|
7
|
+
data.tar.gz: 14d464d0dc69b0cd7baee6b43224bcfc03b46c5842dd6ed48532af79507cef82dc793e5202b55516c1b6aa5f707a4675269a357fcaefda9ce252a72899c6a530
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/DEV_README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Helpful things to remember when developing
|
2
|
+
|
3
|
+
## Publishing to Rubygems
|
4
|
+
|
5
|
+
Ensure the version number is updated (lib/supso/version.rb.
|
6
|
+
|
7
|
+
rspec
|
8
|
+
|
9
|
+
gem build supso.gemspec
|
10
|
+
|
11
|
+
Make sure your ~/.gem credentials are the correct one
|
12
|
+
|
13
|
+
gem push supso-VERSION.gem
|
14
|
+
|
15
|
+
## Requiring the local version of the Gem
|
16
|
+
|
17
|
+
Use something like this:
|
18
|
+
|
19
|
+
gem 'supso', '0.9.0', path: 'local/path/to/gem'
|
20
|
+
|
21
|
+
## Philosophy
|
22
|
+
|
23
|
+
Super Source is split into two types of packages: the supso command line interface,
|
24
|
+
and packages included with the projects that use Super Source.
|
25
|
+
|
26
|
+
This gem, the Super Source Ruby gem, is an example of the former: the command line interface.
|
27
|
+
|
28
|
+
The supso command line interface should never be directly added as a requirement from the projects.
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
Copyright (c) 2016 Jeff Pickhardt
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
5
|
+
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
7
|
+
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Super Source
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
##### Instructions for using Super Source
|
6
|
+
|
7
|
+
Create a new, empty directory. Inside this directory, create a file named Gemfile, and add the following to it:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
source 'https://rubygems.org'
|
11
|
+
|
12
|
+
gem 'super_source'
|
13
|
+
```
|
14
|
+
|
15
|
+
Then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
## Documentation
|
20
|
+
|
21
|
+
Visit the [docs page](http://supso.org/docs/overview/welcome) to read the documentation. The docs page is autogenerated from the files in this project's docs directory.
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
To contribute, get in touch at http://supso.org/ so that we can share the [Contributor License Agreement (CLA)](https://en.wikipedia.org/wiki/Contributor_License_Agreement) with you, then create a pull request.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "supso"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/bin/supso
ADDED
data/docs/README.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# Documentation
|
2
|
+
|
3
|
+
The documentation directory is viewable at http://supso.org/docs.
|
4
|
+
|
5
|
+
# Autogenerated
|
6
|
+
|
7
|
+
The documentation directory is autogenerated from the main Super Source git repo. If you would like to add or correct something in the documentation, let us know or make a pull request to (https://github.com/TODO/docs)[https://github.com/TODO/docs].
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Commands
|
2
|
+
|
3
|
+
Commands can be run by running `supso commandname` from the project directory, assuming that you've already
|
4
|
+
run `bundle install` to install the Super Source gem.
|
5
|
+
|
6
|
+
The list of commands is:
|
7
|
+
|
8
|
+
- [help](/docs/commands/[help])
|
9
|
+
- [login](/docs/commands/login)
|
10
|
+
- [logout](/docs/commands/logout)
|
11
|
+
- [show](/docs/commands/show)
|
12
|
+
- [update](/docs/commands/update)
|
13
|
+
- [version](/docs/commands/[version])
|
14
|
+
- [whoami](/docs/commands/whoami)
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# The `login` command
|
2
|
+
|
3
|
+
The `login` command will log in to your Super Source account. You will be prompted for your email address.
|
4
|
+
|
5
|
+
If you have never added a password to your account, you will then be prompted for a confirmation token sent to your
|
6
|
+
email address, to complete log in. If your account does have a password, you'll be prompted for your password instead.
|
7
|
+
|
8
|
+
Usage:
|
9
|
+
|
10
|
+
`$ supso login`
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# The `show` command
|
2
|
+
|
3
|
+
The `show` command shows a list of projects used by your project, and whether you have tokens for those projects.
|
4
|
+
|
5
|
+
Usage:
|
6
|
+
|
7
|
+
```
|
8
|
+
$ supso show
|
9
|
+
3 projects using Super Source.
|
10
|
+
dataduck-etl
|
11
|
+
Source: add (ruby)
|
12
|
+
Valid: Yes
|
13
|
+
js_supso_test
|
14
|
+
Source: npm
|
15
|
+
Valid: No
|
16
|
+
Reason: Missing client token. Run `supso update` to update the token.
|
17
|
+
yet-another-ruby-project
|
18
|
+
Source: add (ruby)
|
19
|
+
Valid: No
|
20
|
+
Reason: Missing client token. Run `supso update` to update the token.
|
21
|
+
```
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# The `version` command
|
2
|
+
|
3
|
+
The `version` command outputs the current version of the Supso command line interface.
|
4
|
+
|
5
|
+
Note: this version is for the Suspo command line interface, not any Super Source packages you may be using,
|
6
|
+
such as the Ruby gem super_source, or the Javascript package super-source.
|
7
|
+
|
8
|
+
Usage:
|
9
|
+
|
10
|
+
`$ supso version
|
11
|
+
0.9.1
|
12
|
+
`
|
data/docs/contents.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
"Overview":
|
2
|
+
"Welcome": README
|
3
|
+
"Getting Started": getting_started
|
4
|
+
|
5
|
+
"Commands":
|
6
|
+
"help": help
|
7
|
+
"login": login
|
8
|
+
"logout": logout
|
9
|
+
"show": show
|
10
|
+
"update": update
|
11
|
+
"version": version
|
12
|
+
"whoami": whoami
|
13
|
+
|
14
|
+
"Errors":
|
15
|
+
"Invalid Project Token": invalid_project_token
|
16
|
+
"Missing Project Token": missing_project_token
|
17
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Overview
|
2
|
+
|
3
|
+
Super Source let's you know who's using your software projects. If you have an open source project,
|
4
|
+
and would like to understand who your users are, you should use Super Source.
|
5
|
+
|
6
|
+
## Getting Started
|
7
|
+
|
8
|
+
Getting started with Super Source takes just a few minutes. For instructions, read the
|
9
|
+
[getting started](/docs/overview/getting_started) page.
|
10
|
+
|
11
|
+
## Why Use Super Source
|
12
|
+
|
13
|
+
- Learn who's using your project.
|
14
|
+
- Develop relationships with your users.
|
15
|
+
- Send announcements over email.
|
16
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Getting Started
|
2
|
+
|
3
|
+
The following explains how to get started with Super Source as the downstream user of a project that uses it.
|
4
|
+
If instead you are a developer looking to implement Super Source in your project, sign in to the website and visit the
|
5
|
+
Install page.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Run `gem install supso`
|
10
|
+
|
11
|
+
This installs supso, the command line interface for Super Source.
|
12
|
+
|
13
|
+
## Getting Client Tokens
|
14
|
+
|
15
|
+
Run `supso update` from your project's directory
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ModuleVars
|
2
|
+
def define_class_method(name, &block)
|
3
|
+
(class << self; self; end).instance_eval do
|
4
|
+
define_method(name, &block)
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
def create_module_var(name, val = nil)
|
9
|
+
class_variable_set("@@#{ name }", val)
|
10
|
+
|
11
|
+
define_class_method(name) do
|
12
|
+
class_variable_get("@@#{ name }")
|
13
|
+
end
|
14
|
+
|
15
|
+
define_class_method("#{name}=") do |set_to|
|
16
|
+
class_variable_set("@@#{ name }", set_to)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
-----BEGIN PUBLIC KEY-----
|
2
|
+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxa97nwFuinf275M/uCFL
|
3
|
+
MXDhR46lm3oCvEFMAPdqLJ4570DeJZK5MrsSeVaOtiMeW8eNAaLxNocL88QXojGm
|
4
|
+
Bm5jMWJeMwcs1iZTz+w+UwL4njhfE6fF81LeKJf0iq6gFsJE328RuFqj2fayn8sv
|
5
|
+
H5YTsPQhsm/dF2XkjWfQ2dSIHhjwBi0JUNgvZQDLmH6MbdQDenzMD2Z/MG+CMxyc
|
6
|
+
VqKOy+qaqx+eHdfgFk9zoU22cb2XifOSZzph/mGJim7g5N4LQb0zoeykGVvlZuKj
|
7
|
+
YiVCyjvHErM+iWqi7k2ZhlKacprI5Zm9tbZs+lFfmn8c1Ks11zUxeDPhkdUL/v38
|
8
|
+
YwIDAQAB
|
9
|
+
-----END PUBLIC KEY-----
|
@@ -0,0 +1,155 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'json'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'io/console'
|
5
|
+
require 'super_source'
|
6
|
+
|
7
|
+
module Supso
|
8
|
+
class Commands
|
9
|
+
def self.prepare_command_mode!
|
10
|
+
require File.dirname(__FILE__) + '/../super_source/project'
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.prompt_choices(choices = [])
|
14
|
+
while true
|
15
|
+
print "Enter a number 0 - #{ choices.length - 1}\n"
|
16
|
+
choices.each_with_index do |choice, idx|
|
17
|
+
choice_name = choice.is_a?(String) ? choice : choice[1]
|
18
|
+
print "#{ idx }: #{ choice_name }\n"
|
19
|
+
end
|
20
|
+
choice = STDIN.gets.strip.to_i
|
21
|
+
if 0 <= choice && choice < choices.length
|
22
|
+
selected = choices[choice]
|
23
|
+
return selected.is_a?(String) ? selected : selected[0]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.prompt_confirmation_token(to_email)
|
29
|
+
token = ''
|
30
|
+
while token.length < 4
|
31
|
+
puts "Enter the confirmation token that was sent to #{ to_email }: (or enter 'resend')"
|
32
|
+
token = STDIN.gets.strip
|
33
|
+
if token.length < 4
|
34
|
+
puts "Sorry, #{ token } is not a valid confirmation token."
|
35
|
+
end
|
36
|
+
end
|
37
|
+
token
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.prompt_email
|
41
|
+
email = ''
|
42
|
+
while !Util.is_email?(email)
|
43
|
+
puts "Enter your email address:"
|
44
|
+
email = STDIN.gets.strip
|
45
|
+
if !Util.is_email?(email)
|
46
|
+
puts "Sorry, #{ email } is not a valid email address."
|
47
|
+
end
|
48
|
+
end
|
49
|
+
email
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.advanced_commands
|
53
|
+
['logout', 'login', 'show', 'update', 'whoami']
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.simple_commands
|
57
|
+
['help', 'version']
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.all_commands
|
61
|
+
self.advanced_commands + self.simple_commands
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.update
|
65
|
+
Updater.update
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.whoami
|
69
|
+
user = User.current_user
|
70
|
+
puts user ? user.email : nil
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.logout
|
74
|
+
User.log_out!
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.login
|
78
|
+
email = Commands.prompt_email
|
79
|
+
|
80
|
+
without_password_response = Util.http_post("#{ Supso.supso_api_root }sign_in_request_token_api", email: email)
|
81
|
+
if !without_password_response['success']
|
82
|
+
puts without_password_response['reason']
|
83
|
+
return
|
84
|
+
end
|
85
|
+
|
86
|
+
if without_password_response['confirmation_token_sent']
|
87
|
+
succeeded = false
|
88
|
+
while !succeeded
|
89
|
+
token = Commands.prompt_confirmation_token(email)
|
90
|
+
succeeded, reason = User.log_in_with_confirmation_token!(email, token)
|
91
|
+
if !succeeded && reason
|
92
|
+
puts reason
|
93
|
+
end
|
94
|
+
end
|
95
|
+
else
|
96
|
+
succeeded = false
|
97
|
+
while !succeeded
|
98
|
+
puts "Enter your password:"
|
99
|
+
password = STDIN.noecho(&:gets).chomp
|
100
|
+
succeeded, reason = User.log_in_with_password!(email, password)
|
101
|
+
if !succeeded && reason
|
102
|
+
puts reason
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
puts "Successfully signed in as #{ email }."
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.show
|
111
|
+
Project.detect_all_projects!
|
112
|
+
if Project.projects.length == 0
|
113
|
+
puts "0 projects using Super Source."
|
114
|
+
else
|
115
|
+
puts "#{ Project.projects.length } #{ Util.pluralize(Project.projects.length, 'project') } using Super Source.\n"
|
116
|
+
Project.projects.each do |project|
|
117
|
+
project.puts_info
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def self.route_command(args)
|
123
|
+
if args.length == 0
|
124
|
+
return Commands.help
|
125
|
+
end
|
126
|
+
|
127
|
+
command = args[0]
|
128
|
+
if !Commands.all_commands.include?(command)
|
129
|
+
puts "No such command: #{ command }"
|
130
|
+
return Commands.help
|
131
|
+
end
|
132
|
+
|
133
|
+
if Commands.simple_commands.include?(command)
|
134
|
+
return Commands.public_send(command)
|
135
|
+
end
|
136
|
+
|
137
|
+
Commands.prepare_command_mode!
|
138
|
+
|
139
|
+
begin
|
140
|
+
Commands.public_send(command, *args[1..-1])
|
141
|
+
rescue StandardError => err
|
142
|
+
Logs.error(err)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def self.help
|
147
|
+
puts "Usage: supso command"
|
148
|
+
puts "Commands: #{ all_commands.sort.join(' ') }"
|
149
|
+
end
|
150
|
+
|
151
|
+
def self.version
|
152
|
+
puts Supso::VERSION
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
data/lib/supso/config.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Supso
|
2
|
+
class Config
|
3
|
+
def self.load_config!
|
4
|
+
if !Supso.project_supso_config_root
|
5
|
+
return
|
6
|
+
end
|
7
|
+
|
8
|
+
configs_to_load = ["/config.json"]
|
9
|
+
configs_to_load.each do |relative_path|
|
10
|
+
config_path = Supso.project_supso_config_root + relative_path
|
11
|
+
loaded_config = File.exist?(config_path) ? JSON.parse(File.read(config_path)) : {}
|
12
|
+
Supso.config = Util.deep_merge(Supso.config, loaded_config)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Supso
|
2
|
+
class Javascript
|
3
|
+
def self.detect_all_projects!
|
4
|
+
Javascript.detect_all_npm_projects!
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.npm_list_command_response
|
8
|
+
if Util.has_command?('npm')
|
9
|
+
`npm list --json`
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.npm_list_json
|
14
|
+
if !Util.has_command?('npm')
|
15
|
+
return
|
16
|
+
end
|
17
|
+
|
18
|
+
npm_list = Javascript.npm_list_command_response
|
19
|
+
npm_project_data = {}
|
20
|
+
begin
|
21
|
+
npm_project_data = JSON.parse(npm_list)
|
22
|
+
rescue
|
23
|
+
npm_project_data = {} # TODO maybe log this?
|
24
|
+
end
|
25
|
+
|
26
|
+
npm_project_data
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.detect_all_npm_projects!
|
31
|
+
if !Util.has_command?('npm')
|
32
|
+
return
|
33
|
+
end
|
34
|
+
|
35
|
+
root_project = Javascript.npm_list_json
|
36
|
+
Javascript.detect_npm_project!(root_project['name'], root_project)
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.detect_npm_project!(name, project)
|
40
|
+
if !project || !project['dependencies']
|
41
|
+
return
|
42
|
+
end
|
43
|
+
|
44
|
+
dependencies = project['dependencies']
|
45
|
+
dependencies.each_key do |dependency_name|
|
46
|
+
if dependency_name == 'super-source'
|
47
|
+
Project.add(name, nil, {
|
48
|
+
aliases: [{'name' => name, 'platform' => 'npm'}],
|
49
|
+
source: 'npm'
|
50
|
+
})
|
51
|
+
else
|
52
|
+
Javascript.detect_npm_project!(dependency_name, dependencies[dependency_name])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/supso/logs.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
module Supso
|
4
|
+
module Logs
|
5
|
+
@@ONE_MB_IN_BYTES = 1048576
|
6
|
+
|
7
|
+
@@logger = nil
|
8
|
+
|
9
|
+
def Logs.log_target
|
10
|
+
(Supso.project_root || Supso.user_supso_config_root) + '/log/supso.log'
|
11
|
+
end
|
12
|
+
|
13
|
+
def Logs.ensure_logger_exists!
|
14
|
+
log_file_path = Logs.log_target
|
15
|
+
Supso::Util.ensure_path_exists!(log_file_path)
|
16
|
+
@@logger ||= Logger.new(log_file_path, shift_age = 100, shift_size = 100 * @@ONE_MB_IN_BYTES)
|
17
|
+
end
|
18
|
+
|
19
|
+
def Logs.debug(message)
|
20
|
+
self.ensure_logger_exists!
|
21
|
+
|
22
|
+
puts "[DEBUG] #{ message }"
|
23
|
+
@@logger.debug(message)
|
24
|
+
end
|
25
|
+
|
26
|
+
def Logs.info(message)
|
27
|
+
self.ensure_logger_exists!
|
28
|
+
|
29
|
+
puts "[INFO] #{ message }"
|
30
|
+
@@logger.info(message)
|
31
|
+
end
|
32
|
+
|
33
|
+
def Logs.warn(message)
|
34
|
+
self.ensure_logger_exists!
|
35
|
+
|
36
|
+
puts "[WARN] #{ message }"
|
37
|
+
@@logger.warn(message)
|
38
|
+
end
|
39
|
+
|
40
|
+
def Logs.error(err, message = nil)
|
41
|
+
self.ensure_logger_exists!
|
42
|
+
message = err.to_s unless message
|
43
|
+
|
44
|
+
puts "[ERROR] #{ message }"
|
45
|
+
puts err.backtrace.join("\n")
|
46
|
+
@@logger.error(message)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|