ai_games-logger 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +147 -0
- data/.rubocop.yml +6 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +27 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +53 -0
- data/Rakefile +10 -0
- data/ai_games-logger.gemspec +33 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/ai_games/logger.rb +69 -0
- data/lib/ai_games/logger/version.rb +5 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a1f507f6b7cbff0369bf6f8772669a84923c9730
|
4
|
+
data.tar.gz: 309353b20f2b7bca996e6a5e3dacbb16b6adec43
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 19c71d32cb75bee8a068c864359af693732c3e2bffa229bc54bbb6d10a3a42f4957e8962739a02cbc46534ff728108e525df82e38e880a73304d6dd5c05ae71c
|
7
|
+
data.tar.gz: e5fb5fd0a83a1c9528904276d8b495cb44ae4e385d5df90a00c311e9a3a1c3147e677fae66612bece22617b141c2d03efe0fe0efbcfd5d937fae9705d05c8bed
|
data/.gitignore
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
# Created by https://www.gitignore.io/api/linux,osx,windows,ruby,rubymine
|
2
|
+
|
3
|
+
### Linux ###
|
4
|
+
*~
|
5
|
+
|
6
|
+
# KDE directory preferences
|
7
|
+
.directory
|
8
|
+
|
9
|
+
# Linux trash folder which might appear on any partition or disk
|
10
|
+
.Trash-*
|
11
|
+
|
12
|
+
|
13
|
+
### OSX ###
|
14
|
+
.DS_Store
|
15
|
+
.AppleDouble
|
16
|
+
.LSOverride
|
17
|
+
|
18
|
+
# Icon must end with two \r
|
19
|
+
Icon
|
20
|
+
|
21
|
+
|
22
|
+
# Thumbnails
|
23
|
+
._*
|
24
|
+
|
25
|
+
# Files that might appear in the root of a volume
|
26
|
+
.DocumentRevisions-V100
|
27
|
+
.fseventsd
|
28
|
+
.Spotlight-V100
|
29
|
+
.TemporaryItems
|
30
|
+
.Trashes
|
31
|
+
.VolumeIcon.icns
|
32
|
+
|
33
|
+
# Directories potentially created on remote AFP share
|
34
|
+
.AppleDB
|
35
|
+
.AppleDesktop
|
36
|
+
Network Trash Folder
|
37
|
+
Temporary Items
|
38
|
+
.apdisk
|
39
|
+
|
40
|
+
|
41
|
+
### Windows ###
|
42
|
+
# Windows image file caches
|
43
|
+
Thumbs.db
|
44
|
+
ehthumbs.db
|
45
|
+
|
46
|
+
# Folder config file
|
47
|
+
Desktop.ini
|
48
|
+
|
49
|
+
# Recycle Bin used on file shares
|
50
|
+
$RECYCLE.BIN/
|
51
|
+
|
52
|
+
# Windows Installer files
|
53
|
+
*.cab
|
54
|
+
*.msi
|
55
|
+
*.msm
|
56
|
+
*.msp
|
57
|
+
|
58
|
+
# Windows shortcuts
|
59
|
+
*.lnk
|
60
|
+
|
61
|
+
|
62
|
+
### Ruby ###
|
63
|
+
*.gem
|
64
|
+
*.rbc
|
65
|
+
/.config
|
66
|
+
/coverage/
|
67
|
+
/InstalledFiles
|
68
|
+
/pkg/
|
69
|
+
/spec/reports/
|
70
|
+
/spec/examples.txt
|
71
|
+
/test/tmp/
|
72
|
+
/test/version_tmp/
|
73
|
+
/tmp/
|
74
|
+
|
75
|
+
## Specific to RubyMotion:
|
76
|
+
.dat*
|
77
|
+
.repl_history
|
78
|
+
build/
|
79
|
+
|
80
|
+
## Documentation cache and generated files:
|
81
|
+
/.yardoc/
|
82
|
+
/_yardoc/
|
83
|
+
/doc/
|
84
|
+
/rdoc/
|
85
|
+
|
86
|
+
## Environment normalisation:
|
87
|
+
/.bundle/
|
88
|
+
/vendor/bundle
|
89
|
+
/lib/bundler/man/
|
90
|
+
|
91
|
+
# for a library or gem, you might want to ignore these files since the code is
|
92
|
+
# intended to run in multiple environments; otherwise, check them in:
|
93
|
+
Gemfile.lock
|
94
|
+
.ruby-version
|
95
|
+
.ruby-gemset
|
96
|
+
|
97
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
98
|
+
.rvmrc
|
99
|
+
|
100
|
+
|
101
|
+
### RubyMine ###
|
102
|
+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio
|
103
|
+
|
104
|
+
*.iml
|
105
|
+
|
106
|
+
## Directory-based project format:
|
107
|
+
.idea/
|
108
|
+
# if you remove the above rule, at least ignore the following:
|
109
|
+
|
110
|
+
# User-specific stuff:
|
111
|
+
# .idea/workspace.xml
|
112
|
+
# .idea/tasks.xml
|
113
|
+
# .idea/dictionaries
|
114
|
+
|
115
|
+
# Sensitive or high-churn files:
|
116
|
+
# .idea/dataSources.ids
|
117
|
+
# .idea/dataSources.xml
|
118
|
+
# .idea/sqlDataSources.xml
|
119
|
+
# .idea/dynamic.xml
|
120
|
+
# .idea/uiDesigner.xml
|
121
|
+
|
122
|
+
# Gradle:
|
123
|
+
# .idea/gradle.xml
|
124
|
+
# .idea/libraries
|
125
|
+
|
126
|
+
# Mongo Explorer plugin:
|
127
|
+
# .idea/mongoSettings.xml
|
128
|
+
|
129
|
+
## File-based project format:
|
130
|
+
*.ipr
|
131
|
+
*.iws
|
132
|
+
|
133
|
+
## Plugin-specific files:
|
134
|
+
|
135
|
+
# IntelliJ
|
136
|
+
/out/
|
137
|
+
|
138
|
+
# mpeltonen/sbt-idea plugin
|
139
|
+
.idea_modules/
|
140
|
+
|
141
|
+
# JIRA plugin
|
142
|
+
atlassian-ide-plugin.xml
|
143
|
+
|
144
|
+
# Crashlytics plugin (for Android Studio and IntelliJ)
|
145
|
+
com_crashlytics_export_strings.xml
|
146
|
+
crashlytics.properties
|
147
|
+
crashlytics-build.properties
|
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people
|
4
|
+
who contribute through reporting issues, posting feature requests, updating
|
5
|
+
documentation, submitting pull requests or patches, and other activities.
|
6
|
+
|
7
|
+
We are committed to making participation in this project a harassment-free
|
8
|
+
experience for everyone, regardless of level of experience, gender, gender
|
9
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
10
|
+
body size, race, ethnicity, age, or religion.
|
11
|
+
|
12
|
+
Examples of unacceptable behavior by participants include the use of sexual
|
13
|
+
language or imagery, derogatory comments or personal attacks, trolling, public
|
14
|
+
or private harassment, insults, or other unprofessional conduct.
|
15
|
+
|
16
|
+
Project maintainers have the right and responsibility to remove, edit, or reject
|
17
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
18
|
+
not aligned to this Code of Conduct. Project maintainers who do not follow the
|
19
|
+
Code of Conduct may be removed from the project team.
|
20
|
+
|
21
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
22
|
+
reported by opening an issue or contacting one or more of the project
|
23
|
+
maintainers.
|
24
|
+
|
25
|
+
This Code of Conduct is adapted from the
|
26
|
+
[Contributor Covenant](http://contributor-covenant.org), version 1.0.0,
|
27
|
+
available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Jan David Nose
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# AIGames::Logger
|
2
|
+
|
3
|
+
This gem contains a simple logging facility that can be used in The AI Games'
|
4
|
+
competitions to log events. It provides several log levels and prints the output
|
5
|
+
to STDERR, where it is picked up by The AI Games' game engines.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your bot's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'ai_games-logger'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install ai_games-logger
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
First, import the logger using the following `require` statement:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require 'ai_games/logger'
|
29
|
+
```
|
30
|
+
|
31
|
+
Now, you can use the logger like this:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
Logger.debug 'Hello World!' if Logger.debug?
|
35
|
+
```
|
36
|
+
|
37
|
+
## Development
|
38
|
+
|
39
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
40
|
+
`rake test` to run the tests. You can also run `bin/console` for an interactive
|
41
|
+
prompt that will allow you to experiment.
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
Bug reports and pull requests are welcome on GitHub at
|
46
|
+
https://github.com/jdno/ai_games-logger. This project is intended to be a safe,
|
47
|
+
welcoming space for collaboration, and contributors are expected to adhere to
|
48
|
+
the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
49
|
+
|
50
|
+
## License
|
51
|
+
|
52
|
+
The gem is available as open source under the terms of the
|
53
|
+
[MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ai_games/logger/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'ai_games-logger'
|
8
|
+
spec.version = AIGames::Logger::VERSION
|
9
|
+
spec.authors = ['Jan David Nose']
|
10
|
+
spec.email = ['jandavid@awesometechnology.de']
|
11
|
+
|
12
|
+
spec.summary = "Simple logger for bots in The AI Games' competitions"
|
13
|
+
spec.description = <<-EOF
|
14
|
+
This gem contains a simple logging facility that can be used in The AI Games'
|
15
|
+
competitions to log events. It provides several log levels and prints the output
|
16
|
+
to STDERR, where it is picked up by The AI Games' game engines.
|
17
|
+
EOF
|
18
|
+
spec.homepage = 'https://github.com/jdno/ai_games-logger'
|
19
|
+
spec.license = 'MIT'
|
20
|
+
|
21
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
22
|
+
f.match(%r{^(test|spec|features)/})
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.bindir = 'exe'
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ['lib']
|
28
|
+
|
29
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
30
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
31
|
+
spec.add_development_dependency 'minitest', '~> 5.8'
|
32
|
+
spec.add_development_dependency 'rubocop', '~> 0.35'
|
33
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ai_games/logger"
|
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
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'ai_games/logger/version'
|
2
|
+
|
3
|
+
module AIGames
|
4
|
+
# The Logger is a simple logging facility that is indented to be used by bots
|
5
|
+
# in any competition by The AI Games. It provides four log levels (DEBUG,
|
6
|
+
# INFO, WARN and ERROR) and writes the logs to STDERR, where they are picked
|
7
|
+
# up by The AI Games' game engines.
|
8
|
+
module Logger
|
9
|
+
DEBUG = 0
|
10
|
+
INFO = 1
|
11
|
+
WARN = 2
|
12
|
+
ERROR = 3
|
13
|
+
|
14
|
+
class << self
|
15
|
+
# Sets the output stream the logger uses. For tests, pass StringIO.new. If
|
16
|
+
# you do not initialize the output stream, $stderr is used.
|
17
|
+
attr_writer :output
|
18
|
+
|
19
|
+
# Returns the log level. If the log level has not been set, the default
|
20
|
+
# log level is returned.
|
21
|
+
def log_level
|
22
|
+
@log_level ||= WARN
|
23
|
+
end
|
24
|
+
|
25
|
+
# Sets the log level. Available options are DEBUG, INFO, WARN,ERROR.
|
26
|
+
def log_level=(log_level)
|
27
|
+
@log_level = log_level if [DEBUG, INFO, WARN, ERROR].include?(log_level)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Returns true if the log level is currently set to DEBUG. Use this before
|
31
|
+
# calling `Logger.debug(log)` to prevent the unnecessary (and costly)
|
32
|
+
# creation of strings.
|
33
|
+
def debug?
|
34
|
+
DEBUG == log_level
|
35
|
+
end
|
36
|
+
|
37
|
+
# Prints a debug log. If the log level is not set to debug, no action is
|
38
|
+
# taken.
|
39
|
+
def debug(log)
|
40
|
+
output.puts log if log_level <= DEBUG
|
41
|
+
end
|
42
|
+
|
43
|
+
# Prints an info log. If the log level is not set to info or lower, no
|
44
|
+
# action is taken.
|
45
|
+
def info(log)
|
46
|
+
output.puts log if log_level <= INFO
|
47
|
+
end
|
48
|
+
|
49
|
+
# Prints a warn log. If the log level is not set to warn or lower, no
|
50
|
+
# action is taken.
|
51
|
+
def warn(log)
|
52
|
+
output.puts log if log_level <= WARN
|
53
|
+
end
|
54
|
+
|
55
|
+
# Prints an error log.
|
56
|
+
def error(log)
|
57
|
+
output.puts log if log_level <= ERROR
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
# Returns the output stream. If the logger has not been initializes with
|
63
|
+
# an output stream, $stderr is returned.
|
64
|
+
def output
|
65
|
+
@output ||= $stderr
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ai_games-logger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jan David Nose
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.8'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.8'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.35'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.35'
|
69
|
+
description: |
|
70
|
+
This gem contains a simple logging facility that can be used in The AI Games'
|
71
|
+
competitions to log events. It provides several log levels and prints the output
|
72
|
+
to STDERR, where it is picked up by The AI Games' game engines.
|
73
|
+
email:
|
74
|
+
- jandavid@awesometechnology.de
|
75
|
+
executables: []
|
76
|
+
extensions: []
|
77
|
+
extra_rdoc_files: []
|
78
|
+
files:
|
79
|
+
- ".gitignore"
|
80
|
+
- ".rubocop.yml"
|
81
|
+
- ".travis.yml"
|
82
|
+
- CODE_OF_CONDUCT.md
|
83
|
+
- Gemfile
|
84
|
+
- LICENSE.txt
|
85
|
+
- README.md
|
86
|
+
- Rakefile
|
87
|
+
- ai_games-logger.gemspec
|
88
|
+
- bin/console
|
89
|
+
- bin/setup
|
90
|
+
- lib/ai_games/logger.rb
|
91
|
+
- lib/ai_games/logger/version.rb
|
92
|
+
homepage: https://github.com/jdno/ai_games-logger
|
93
|
+
licenses:
|
94
|
+
- MIT
|
95
|
+
metadata: {}
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 2.4.6
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: Simple logger for bots in The AI Games' competitions
|
116
|
+
test_files: []
|