Skip to content

Commit 02f50a4

Browse files
committed
Update usage of Console logger.
1 parent dfd9419 commit 02f50a4

File tree

9 files changed

+35
-35
lines changed

9 files changed

+35
-35
lines changed

examples/container.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212

1313
container = Async::Container.new
1414

15-
Console.logger.debug "Spawning 2 containers..."
15+
Console.debug "Spawning 2 containers..."
1616

1717
2.times do
1818
container.spawn do |task|
19-
Console.logger.debug task, "Sleeping..."
19+
Console.debug task, "Sleeping..."
2020
sleep(2)
21-
Console.logger.debug task, "Waking up!"
21+
Console.debug task, "Waking up!"
2222
end
2323
end
2424

25-
Console.logger.debug "Waiting for container..."
25+
Console.debug "Waiting for container..."
2626
container.wait
27-
Console.logger.debug "Finished."
27+
Console.debug "Finished."

examples/controller.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ class Controller < Async::Container::Controller
1111
def setup(container)
1212
container.run(count: 1, restart: true) do |instance|
1313
if container.statistics.failed?
14-
Console.logger.debug(self, "Child process restarted #{container.statistics.restarts} times.")
14+
Console.debug(self, "Child process restarted #{container.statistics.restarts} times.")
1515
else
16-
Console.logger.debug(self, "Child process started.")
16+
Console.debug(self, "Child process started.")
1717
end
1818

1919
instance.ready!
2020

2121
while true
2222
sleep 1
2323

24-
Console.logger.debug(self, "Work")
24+
Console.debug(self, "Work")
2525

2626
if rand < 0.5
27-
Console.logger.debug(self, "Should exit...")
27+
Console.debug(self, "Should exit...")
2828
sleep 0.5
2929
exit(1)
3030
end
@@ -35,7 +35,7 @@ def setup(container)
3535

3636
Console.logger.debug!
3737

38-
Console.logger.debug(self, "Starting up...")
38+
Console.debug(self, "Starting up...")
3939

4040
controller = Controller.new
4141

guides/getting-started/readme.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ Console.logger.debug!
2929
container = Async::Container.new
3030

3131
container.spawn do |task|
32-
Console.logger.debug task, "Sleeping..."
32+
Console.debug task, "Sleeping..."
3333
sleep(1)
34-
Console.logger.debug task, "Waking up!"
34+
Console.debug task, "Waking up!"
3535
end
3636

37-
Console.logger.debug "Waiting for container..."
37+
Console.debug "Waiting for container..."
3838
container.wait
39-
Console.logger.debug "Finished."
39+
Console.debug "Finished."
4040
```
4141

4242
## Controllers
@@ -58,7 +58,7 @@ class Controller < Async::Container::Controller
5858
def setup(container)
5959
container.run count: 2, restart: true do |instance|
6060
while true
61-
Console.logger.debug(instance, "Sleeping...")
61+
Console.debug(instance, "Sleeping...")
6262
sleep(1)
6363
end
6464
end

lib/async/container/controller.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ def restart
109109
if @container
110110
@notify&.restarting!
111111

112-
Console.logger.debug(self) {"Restarting container..."}
112+
Console.debug(self) {"Restarting container..."}
113113
else
114-
Console.logger.debug(self) {"Starting container..."}
114+
Console.debug(self) {"Starting container..."}
115115
end
116116

117117
container = self.create_container
@@ -125,9 +125,9 @@ def restart
125125
end
126126

127127
# Wait for all child processes to enter the ready state.
128-
Console.logger.debug(self, "Waiting for startup...")
128+
Console.debug(self, "Waiting for startup...")
129129
container.wait_until_ready
130-
Console.logger.debug(self, "Finished startup.")
130+
Console.debug(self, "Finished startup.")
131131

132132
if container.failed?
133133
@notify&.error!("Container failed to start!")
@@ -143,7 +143,7 @@ def restart
143143
container = nil
144144

145145
if old_container
146-
Console.logger.debug(self, "Stopping old container...")
146+
Console.debug(self, "Stopping old container...")
147147
old_container&.stop(@graceful_stop)
148148
end
149149

@@ -157,7 +157,7 @@ def restart
157157
def reload
158158
@notify&.reloading!
159159

160-
Console.logger.info(self) {"Reloading container: #{@container}..."}
160+
Console.info(self) {"Reloading container: #{@container}..."}
161161

162162
begin
163163
self.setup(@container)
@@ -166,11 +166,11 @@ def reload
166166
end
167167

168168
# Wait for all child processes to enter the ready state.
169-
Console.logger.debug(self, "Waiting for startup...")
169+
Console.debug(self, "Waiting for startup...")
170170

171171
@container.wait_until_ready
172172

173-
Console.logger.debug(self, "Finished startup.")
173+
Console.debug(self, "Finished startup.")
174174

175175
if @container.failed?
176176
@notify.error!("Container failed to reload!")
@@ -210,7 +210,7 @@ def run
210210
begin
211211
handler.call
212212
rescue SetupError => error
213-
Console.logger.error(self) {error}
213+
Console.error(self) {error}
214214
end
215215
else
216216
raise

lib/async/container/generic.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def status?(flag)
104104
# @returns [Boolean] The children all became ready.
105105
def wait_until_ready
106106
while true
107-
Console.logger.debug(self) do |buffer|
107+
Console.debug(self) do |buffer|
108108
buffer.puts "Waiting for ready:"
109109
@state.each do |child, state|
110110
buffer.puts "\t#{child.class}: #{state.inspect}"
@@ -126,7 +126,7 @@ def stop(timeout = true)
126126
@group.stop(timeout)
127127

128128
if @group.running?
129-
Console.logger.warn(self) {"Group is still running after stopping it!"}
129+
Console.warn(self) {"Group is still running after stopping it!"}
130130
end
131131
ensure
132132
@running = true
@@ -140,7 +140,7 @@ def spawn(name: nil, restart: false, key: nil, &block)
140140
name ||= UNNAMED
141141

142142
if mark?(key)
143-
Console.logger.debug(self) {"Reusing existing child for #{key}: #{name}"}
143+
Console.debug(self) {"Reusing existing child for #{key}: #{name}"}
144144
return false
145145
end
146146

@@ -161,10 +161,10 @@ def spawn(name: nil, restart: false, key: nil, &block)
161161
end
162162

163163
if status.success?
164-
Console.logger.debug(self) {"#{child} exited with #{status}"}
164+
Console.debug(self) {"#{child} exited with #{status}"}
165165
else
166166
@statistics.failure!
167-
Console.logger.error(self) {status}
167+
Console.error(self) {status}
168168
end
169169

170170
if restart

lib/async/container/group.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def wait
6565
# Interrupt all running processes.
6666
# This resumes the controlling fiber with an instance of {Interrupt}.
6767
def interrupt
68-
Console.logger.debug(self, "Sending interrupt to #{@running.size} running processes...")
68+
Console.debug(self, "Sending interrupt to #{@running.size} running processes...")
6969
@running.each_value do |fiber|
7070
fiber.resume(Interrupt)
7171
end
@@ -74,7 +74,7 @@ def interrupt
7474
# Terminate all running processes.
7575
# This resumes the controlling fiber with an instance of {Terminate}.
7676
def terminate
77-
Console.logger.debug(self, "Sending terminate to #{@running.size} running processes...")
77+
Console.debug(self, "Sending terminate to #{@running.size} running processes...")
7878
@running.each_value do |fiber|
7979
fiber.resume(Terminate)
8080
end

lib/async/container/notify/pipe.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def self.open!(environment = ENV)
2222
self.new(::IO.for_fd(descriptor.to_i))
2323
end
2424
rescue Errno::EBADF => error
25-
Console.logger.error(self) {error}
25+
Console.error(self) {error}
2626

2727
return nil
2828
end

lib/async/container/process.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def self.fork(**options)
7474
rescue Interrupt
7575
# Graceful exit.
7676
rescue Exception => error
77-
Console.logger.error(self) {error}
77+
Console.error(self) {error}
7878

7979
exit!(1)
8080
end
@@ -160,7 +160,7 @@ def wait
160160
end
161161

162162
if @status.nil?
163-
Console.logger.warn(self) {"Process #{@pid} is blocking, has it exited?"}
163+
Console.warn(self) {"Process #{@pid} is blocking, has it exited?"}
164164
_, @status = ::Process.wait2(@pid)
165165
end
166166
end

lib/async/container/thread.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def to_s
188188
# Invoked by the @waiter thread to indicate the outcome of the child thread.
189189
def finished(error = nil)
190190
if error
191-
Console.logger.error(self) {error}
191+
Console.error(self) {error}
192192
end
193193

194194
@status = Status.new(error)

0 commit comments

Comments
 (0)