Skip to content

Commit

Permalink
Updated for Crystal 0.35.0
Browse files Browse the repository at this point in the history
  • Loading branch information
naqvis committed Jun 11, 2020
1 parent 7dc085a commit 17f90b0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
4 changes: 2 additions & 2 deletions shard.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: cr-xmpp
version: 0.1.4
version: 0.1.5
description: |
XMPP/Jabber Library for Crystal focusing on simplicity, simple automation, and IoT.
authors:
- Ali Naqvi <syed.alinaqvi@gmail.com>

crystal: 0.34.0
crystal: 0.35.0

license: MIT
2 changes: 1 addition & 1 deletion src/cr-xmpp.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module XMPP
VERSION = "0.1.4"
VERSION = "0.1.5"
end

require "./xmpp"
17 changes: 6 additions & 11 deletions src/xmpp/logger.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@ require "log"
module XMPP::Logger
@@logger : Log = build_logger

private def self.build_logger(output = STDOUT)
backend = Log::IOBackend.new(output)
backend.progname = "Crystal-XMPP"
backend.formatter = Log::Formatter.new do |entry, io|
label = entry.severity.none? ? "ANY" : entry.severity.label
io << "[" << entry.timestamp << " #" << Process.pid << "]"
io << label.rjust(7) << " -- " << backend.progname << ": " << entry.message
end
Log.define_formatter MyFormat, "[#{timestamp} ##{Process.pid}] #{(severity || "ANY").rjust(7)} -- Crystal-XMPP: #{message}"

builder = Log::Builder.new
builder.bind("", :info, backend)
builder.for("")
private def self.build_logger(output = STDOUT)
backend = Log::IOBackend.new(output, formatter: MyFormat)
Log.setup(:info, backend)
Log.for("Crystal-XMPP")
end

{% for method in %w(info debug warn fatal error) %}
Expand All @@ -23,3 +17,4 @@ module XMPP::Logger
end
{% end %}
end

3 changes: 2 additions & 1 deletion src/xmpp/stream_logger.cr
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ module XMPP
n
end

def write(slice : Bytes) : Nil
def write(slice : Bytes) : Int64
@socket.write slice
@socket.flush
if (sp = @log_file)
sp << "SEND:" << "\n" # Prefix
sp << String.new(slice)
sp << "\n\n" # Separator
end
slice.size.to_i64
end

private def do_read(bytes : Slice)
Expand Down

0 comments on commit 17f90b0

Please sign in to comment.