glib-web 7.1.0 → 7.2.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/app/models/g_log.rb +92 -0
  3. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e178f9febdf54e054c6415f98e2dba1168d13ca1eea53c3a2e4c7aba62a434e9
4
- data.tar.gz: f882a75e2b6c4c56b09b02419eb67b08e3d771958f5d3445f51ebbd93ffba806
3
+ metadata.gz: f04f2fbd4180b48a75af32ed8bd22321fc818224ecfb00802edc88b04992c287
4
+ data.tar.gz: a5340d00dee67cacb6175428130344910c8ddbeaf69e73a64e0b8bfd8f13f639
5
5
  SHA512:
6
- metadata.gz: 5ad0e0bbe190e4e3c908561a379513b88d134cf2fafc454d8a843b0467a90d51577f9d1d40ab553774588ce23c454bccac19ba6608239fe5503ae2a5cf4ff4cd
7
- data.tar.gz: 02f96c88f95bde1860894cb3e84d849b1a62bf35285178997ead4992ee4f9a8572ea9b48e7a5c73e0bf573cc3be56ee2dc056f2bce008792d180a286b8940813
6
+ metadata.gz: fbe295ea4776d69d9b07f9bf554be771195f1296f5a61c690274c28a72432b43d7f7093884b2fc20cf3d12502880590d86856cb965318c1b0d62383d7952801b
7
+ data.tar.gz: 7cbfcda693f301216d38735f7a288b6d0006f38f1bb59a1a5db6a6837d4ea1dbdea43f1663314b214bbdee046245e40c0a4126cceb4c7b35c2956b1541cd3140
@@ -0,0 +1,92 @@
1
+ # Top-level (NOT namespaced under Glib::) by design — same constraint as
2
+ # SnapshotBlobReference: a top-level name keeps the facade's call-site
3
+ # ergonomics (`DLog.error` → `GLog.error`, one character per site), and the
4
+ # engine's autoloader resolves app/models files as top-level constants anyway.
5
+ #
6
+ # A routing facade, nothing more. The value is the seam: one place where
7
+ # destination, level policy, and (later) redaction live, and call sites that
8
+ # name their destination (`GLog.local_info` vs `GLog.error`).
9
+ module GLog
10
+ # Use this to log functional errors that should not happen, but could happen
11
+ # since it is dependent on external factors.
12
+ def self.error(*args)
13
+ remote(:error, *args)
14
+ end
15
+
16
+ def self.warn(*args)
17
+ remote(:warn, *args)
18
+ end
19
+
20
+ def self.info(*args)
21
+ remote(:info, *args)
22
+ end
23
+
24
+ def self.error_excluding_test(*args)
25
+ if Rails.env.test?
26
+ warn(*args)
27
+ else
28
+ error(*args)
29
+ end
30
+ end
31
+
32
+ def self.local_debug(*args)
33
+ Rails.logger.debug(*args)
34
+ end
35
+
36
+ def self.local_info(*args)
37
+ Rails.logger.info(*args)
38
+ end
39
+
40
+ def self.local_warn(*args)
41
+ Rails.logger.warn(*args)
42
+ end
43
+
44
+ def self.local_error(*args)
45
+ Rails.logger.error(*args)
46
+ end
47
+
48
+ # Remote methods route to Rollbar when the host defines it. The gem itself
49
+ # declares no rollbar dependency (see glib-web.gemspec), so without it they
50
+ # fall through to the local logger tagged [GLog:remote] — non-Rollbar
51
+ # consumers still see the message, and tests can exercise both modes.
52
+ # Tagged receives the bare tag (tagged adds its own brackets), and a logger
53
+ # without `tagged` (a plain BroadcastLogger, no TaggedLogging) gets a
54
+ # prefixed message instead: the fallback must never raise on the logger
55
+ # shape the host configured.
56
+ def self.remote(level, *args)
57
+ if defined?(Rollbar)
58
+ Rollbar.public_send(level, *args)
59
+ else
60
+ log_remotely_locally(level, args)
61
+ end
62
+ end
63
+
64
+ def self.log_remotely_locally(level, args)
65
+ message = format_remote_args(args)
66
+ logger = Rails.logger
67
+ if logger.respond_to?(:tagged)
68
+ logger.tagged('GLog:remote') { |tagged_logger| tagged_logger.public_send(level, message) }
69
+ else
70
+ logger.public_send(level, "[GLog:remote] #{message}")
71
+ end
72
+ end
73
+
74
+ # Rollbar's API is variadic (`Rollbar.error(e, 'msg', extra)`), and the
75
+ # facade inherits that shape; the local logger's level methods take ONE
76
+ # message. Render the argument list into a single line: exceptions as
77
+ # `Class: message`, strings as-is, everything else (context hashes, kwargs
78
+ # collected into a trailing hash) via inspect, joined with ' | '.
79
+ def self.format_remote_args(args)
80
+ args.map do |arg|
81
+ if arg.is_a?(Exception)
82
+ "#{arg.class}: #{arg.message}"
83
+ elsif arg.is_a?(String)
84
+ arg
85
+ else
86
+ arg.inspect
87
+ end
88
+ end.join(' | ')
89
+ end
90
+
91
+ private_class_method :remote, :log_remotely_locally, :format_remote_args
92
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glib-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.0
4
+ version: 7.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-12 00:00:00.000000000 Z
11
+ date: 2026-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activestorage
@@ -272,6 +272,7 @@ files:
272
272
  - app/models/concerns/glib/nilify_blanks.rb
273
273
  - app/models/concerns/glib/snapshot_v2.rb
274
274
  - app/models/concerns/glib/soft_deletable.rb
275
+ - app/models/g_log.rb
275
276
  - app/models/glib/active_storage/attachment.rb
276
277
  - app/models/glib/active_storage/blob.rb
277
278
  - app/models/glib/application_record.rb