Skip to content

Commit b9a54c7

Browse files
author
remi Taylor
authored
Merge pull request #37 from GoogleCloudPlatform/logging-sample
Samples for Stackdriver Logging API
2 parents 0772497 + f7d8e3d commit b9a54c7

8 files changed

Lines changed: 636 additions & 0 deletions

File tree

.rubocop.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,61 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# RubyCop configuration file
16+
#
17+
# RuboCop
18+
# http://batsov.com/rubocop/
19+
#
20+
# Style cops
21+
# http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style
22+
#
23+
# Lint cops
24+
# http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Lint
25+
26+
# Prefer double quotes for consistency (regardless of interpolation)
1527
Style/StringLiterals:
1628
EnforcedStyle: double_quotes
29+
30+
# Prefer no parentheses for method definitions and invocations
1731
Style/MethodDefParentheses:
1832
EnforcedStyle: require_no_parentheses
33+
34+
# Use %[ ] for string arrays
35+
# Use %{ } for other delimiters, eg. %{ } sometimes used for multiline strings
36+
Style/PercentLiteralDelimiters:
37+
Enabled: false
38+
39+
# Always use 2 spaces for indentation
40+
# Sometimes method invokations might be additionally indented for clarity
41+
Style/MultilineMethodCallIndentation:
42+
Enabled: false
43+
44+
# Unused block arguments are OK
45+
# They can add clarity to code to demonstrate available arguments
46+
Lint/UnusedBlockArgument:
47+
Enabled: false
48+
49+
# Usage of // or %r{ } is acceptable for regular expressions
50+
# Please use // unless %r{ } adds clarity, eg. slashes used in expression
51+
Style/RegexpLiteral:
52+
Enabled: false
53+
54+
# Use of parenthesis is optional in nested method calls
55+
# This cop is optional mostly to support RSpec expectations
56+
# If the code sample is: service.add "variable"
57+
# Then the spec can use: expect { service.add "variable" }
58+
Style/NestedParenthesizedCalls:
59+
Enabled: false
60+
61+
# In production code, yield is prefered over block.call
62+
# For code samples, explicitly calling a block by name can add clarity
63+
Performance/RedundantBlockCall:
64+
Enabled: false
65+
66+
# Empty line at top of block is sometimes OK, eg. for RSpec describe blocks
67+
Style/EmptyLinesAroundBlockBody:
68+
Enabled: false
69+
1970
Style/NumericLiterals:
2071
Enabled: false
2172
Style/SpaceAroundOperators:

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ env:
3636
- TEST_DIR=pubsub
3737
- TEST_DIR=bigquery
3838
- TEST_DIR=datastore
39+
- TEST_DIR=logging
3940
- TEST_DIR=appengine/endpoints
4041

4142
before_install:

logging/Gemfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright 2016 Google, Inc
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
source "https://rubygems.org"
16+
17+
gem "gcloud"
18+
19+
group :test do
20+
gem "rake"
21+
gem "rubocop"
22+
gem "rspec"
23+
gem "rack-test"
24+
end

logging/Gemfile.lock

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
activesupport (4.2.6)
5+
i18n (~> 0.7)
6+
json (~> 1.7, >= 1.7.7)
7+
minitest (~> 5.1)
8+
thread_safe (~> 0.3, >= 0.3.4)
9+
tzinfo (~> 1.1)
10+
addressable (2.4.0)
11+
ast (2.3.0)
12+
autoparse (0.3.3)
13+
addressable (>= 2.3.1)
14+
extlib (>= 0.9.15)
15+
multi_json (>= 1.0.0)
16+
diff-lcs (1.2.5)
17+
digest-crc (0.4.1)
18+
extlib (0.9.16)
19+
faraday (0.9.2)
20+
multipart-post (>= 1.2, < 3)
21+
gcloud (0.9.0)
22+
digest-crc (~> 0.4)
23+
google-api-client (~> 0.8.3)
24+
google-protobuf (~> 3.0.0.alpha.5.0.5)
25+
grpc (~> 0.13.1)
26+
mime-types (~> 2.4)
27+
zonefile (~> 1.04)
28+
google-api-client (0.8.6)
29+
activesupport (>= 3.2)
30+
addressable (~> 2.3)
31+
autoparse (~> 0.3)
32+
extlib (~> 0.9)
33+
faraday (~> 0.9)
34+
googleauth (~> 0.3)
35+
launchy (~> 2.4)
36+
multi_json (~> 1.10)
37+
retriable (~> 1.4)
38+
signet (~> 0.6)
39+
google-protobuf (3.0.0.alpha.5.0.5.1)
40+
googleauth (0.5.1)
41+
faraday (~> 0.9)
42+
jwt (~> 1.4)
43+
logging (~> 2.0)
44+
memoist (~> 0.12)
45+
multi_json (~> 1.11)
46+
os (~> 0.9)
47+
signet (~> 0.7)
48+
grpc (0.13.1)
49+
google-protobuf (~> 3.0.0.alpha.5.0.3)
50+
googleauth (~> 0.5.1)
51+
i18n (0.7.0)
52+
json (1.8.3)
53+
jwt (1.5.4)
54+
launchy (2.4.3)
55+
addressable (~> 2.3)
56+
little-plugger (1.1.4)
57+
logging (2.1.0)
58+
little-plugger (~> 1.1)
59+
multi_json (~> 1.10)
60+
memoist (0.14.0)
61+
mime-types (2.99.2)
62+
minitest (5.9.0)
63+
multi_json (1.12.1)
64+
multipart-post (2.0.0)
65+
os (0.9.6)
66+
parser (2.3.1.2)
67+
ast (~> 2.2)
68+
powerpack (0.1.1)
69+
rack (1.6.4)
70+
rack-test (0.6.3)
71+
rack (>= 1.0)
72+
rainbow (2.1.0)
73+
rake (11.1.2)
74+
retriable (1.4.1)
75+
rspec (3.4.0)
76+
rspec-core (~> 3.4.0)
77+
rspec-expectations (~> 3.4.0)
78+
rspec-mocks (~> 3.4.0)
79+
rspec-core (3.4.4)
80+
rspec-support (~> 3.4.0)
81+
rspec-expectations (3.4.0)
82+
diff-lcs (>= 1.2.0, < 2.0)
83+
rspec-support (~> 3.4.0)
84+
rspec-mocks (3.4.1)
85+
diff-lcs (>= 1.2.0, < 2.0)
86+
rspec-support (~> 3.4.0)
87+
rspec-support (3.4.1)
88+
rubocop (0.42.0)
89+
parser (>= 2.3.1.1, < 3.0)
90+
powerpack (~> 0.1)
91+
rainbow (>= 1.99.1, < 3.0)
92+
ruby-progressbar (~> 1.7)
93+
unicode-display_width (~> 1.0, >= 1.0.1)
94+
ruby-progressbar (1.8.1)
95+
signet (0.7.2)
96+
addressable (~> 2.3)
97+
faraday (~> 0.9)
98+
jwt (~> 1.5)
99+
multi_json (~> 1.10)
100+
thread_safe (0.3.5)
101+
tzinfo (1.2.2)
102+
thread_safe (~> 0.1)
103+
unicode-display_width (1.1.0)
104+
zonefile (1.04)
105+
106+
PLATFORMS
107+
ruby
108+
109+
DEPENDENCIES
110+
gcloud
111+
rack-test
112+
rake
113+
rspec
114+
rubocop
115+
116+
BUNDLED WITH
117+
1.12.5

logging/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Stackdriver Logging Sample
2+
3+
This sample provides example code for
4+
[cloud.google.com/logging/docs](https://cloud.google.com/logging/docs).
5+
6+
## Setup
7+
8+
Before you can run or test the sample, you will need to enable the Stackdriver Logging API in the [Google Developers Console](https://console.developers.google.com/projectselector/apis/api/datastore/overview).
9+
10+
## Testing
11+
12+
The tests for the sample are integration tests that run against the Logging
13+
service and require authentication.
14+
15+
### Authenticating
16+
17+
Set one of the following environment variables to your Google Cloud Platform
18+
project ID:
19+
20+
* `GCLOUD_PROJECT`
21+
* `GOOGLE_CLOUD_PROJECT`
22+
23+
For more information, see
24+
[Authentication](https://googlecloudplatform.github.io/gcloud-ruby/#/docs/guides/authentication).
25+
26+
### Running the tests
27+
28+
```bash
29+
$ bundle exec rake spec
30+
```
31+

logging/Rakefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2016 Google, Inc
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
require "rspec/core/rake_task"
16+
RSpec::Core::RakeTask.new(:spec)
17+
18+
require "rubocop/rake_task"
19+
RuboCop::RakeTask.new
20+
21+
task default: :spec

0 commit comments

Comments
 (0)