@larablox/monolog 0.1.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 (70) hide show
  1. package/out/Monolog/Attribute/AsMonologProcessor.d.ts +30 -0
  2. package/out/Monolog/Attribute/AsMonologProcessor.luau +59 -0
  3. package/out/Monolog/Attribute/WithMonologChannel.d.ts +18 -0
  4. package/out/Monolog/Attribute/WithMonologChannel.luau +33 -0
  5. package/out/Monolog/Formatter/FormatterInterface.d.ts +8 -0
  6. package/out/Monolog/Formatter/FormatterInterface.luau +3 -0
  7. package/out/Monolog/Formatter/HtmlFormatter.d.ts +23 -0
  8. package/out/Monolog/Formatter/HtmlFormatter.luau +128 -0
  9. package/out/Monolog/Formatter/JsonFormatter.d.ts +34 -0
  10. package/out/Monolog/Formatter/JsonFormatter.luau +114 -0
  11. package/out/Monolog/Formatter/LineFormatter.d.ts +52 -0
  12. package/out/Monolog/Formatter/LineFormatter.luau +228 -0
  13. package/out/Monolog/Formatter/NormalizerFormatter.d.ts +87 -0
  14. package/out/Monolog/Formatter/NormalizerFormatter.luau +214 -0
  15. package/out/Monolog/Formatter/ScalarFormatter.d.ts +19 -0
  16. package/out/Monolog/Formatter/ScalarFormatter.luau +53 -0
  17. package/out/Monolog/Handler/AbstractHandler.d.ts +22 -0
  18. package/out/Monolog/Handler/AbstractHandler.luau +50 -0
  19. package/out/Monolog/Handler/AbstractProcessingHandler.d.ts +30 -0
  20. package/out/Monolog/Handler/AbstractProcessingHandler.luau +79 -0
  21. package/out/Monolog/Handler/Handler.d.ts +15 -0
  22. package/out/Monolog/Handler/Handler.luau +25 -0
  23. package/out/Monolog/Handler/HandlerInterface.d.ts +12 -0
  24. package/out/Monolog/Handler/HandlerInterface.luau +3 -0
  25. package/out/Monolog/Handler/NullHandler.d.ts +10 -0
  26. package/out/Monolog/Handler/NullHandler.luau +36 -0
  27. package/out/Monolog/Handler/RobloxConsoleHandler.d.ts +55 -0
  28. package/out/Monolog/Handler/RobloxConsoleHandler.luau +141 -0
  29. package/out/Monolog/Handler/TestHandler.d.ts +90 -0
  30. package/out/Monolog/Handler/TestHandler.luau +288 -0
  31. package/out/Monolog/Level.d.ts +38 -0
  32. package/out/Monolog/Level.luau +119 -0
  33. package/out/Monolog/LogRecord.d.ts +43 -0
  34. package/out/Monolog/LogRecord.luau +77 -0
  35. package/out/Monolog/Logger.d.ts +93 -0
  36. package/out/Monolog/Logger.luau +248 -0
  37. package/out/Monolog/LoggerInterface.d.ts +33 -0
  38. package/out/Monolog/LoggerInterface.luau +15 -0
  39. package/out/Monolog/Processor/ClosureContextProcessor.d.ts +13 -0
  40. package/out/Monolog/Processor/ClosureContextProcessor.luau +76 -0
  41. package/out/Monolog/Processor/IntrospectionProcessor.d.ts +33 -0
  42. package/out/Monolog/Processor/IntrospectionProcessor.luau +69 -0
  43. package/out/Monolog/Processor/MemoryPeakUsageProcessor.d.ts +17 -0
  44. package/out/Monolog/Processor/MemoryPeakUsageProcessor.luau +49 -0
  45. package/out/Monolog/Processor/MemoryProcessor.d.ts +20 -0
  46. package/out/Monolog/Processor/MemoryProcessor.luau +41 -0
  47. package/out/Monolog/Processor/MemoryUsageProcessor.d.ts +12 -0
  48. package/out/Monolog/Processor/MemoryUsageProcessor.luau +38 -0
  49. package/out/Monolog/Processor/ProcessIdProcessor.d.ts +13 -0
  50. package/out/Monolog/Processor/ProcessIdProcessor.luau +33 -0
  51. package/out/Monolog/Processor/ProcessorInterface.d.ts +13 -0
  52. package/out/Monolog/Processor/ProcessorInterface.luau +20 -0
  53. package/out/Monolog/Processor/PsrLogMessageProcessor.d.ts +12 -0
  54. package/out/Monolog/Processor/PsrLogMessageProcessor.luau +62 -0
  55. package/out/Monolog/Processor/TagProcessor.d.ts +12 -0
  56. package/out/Monolog/Processor/TagProcessor.luau +46 -0
  57. package/out/Monolog/Processor/UidProcessor.d.ts +18 -0
  58. package/out/Monolog/Processor/UidProcessor.luau +53 -0
  59. package/out/Monolog/Registry.d.ts +21 -0
  60. package/out/Monolog/Registry.luau +86 -0
  61. package/out/Monolog/ResettableInterface.d.ts +11 -0
  62. package/out/Monolog/ResettableInterface.luau +21 -0
  63. package/out/Monolog/Test/MonologTestCase.d.ts +26 -0
  64. package/out/Monolog/Test/MonologTestCase.luau +73 -0
  65. package/out/Monolog/Test/TestCase.d.ts +4 -0
  66. package/out/Monolog/Test/TestCase.luau +25 -0
  67. package/out/Monolog/Utils.d.ts +21 -0
  68. package/out/Monolog/Utils.luau +181 -0
  69. package/out/index.d.ts +1 -0
  70. package/package.json +51 -0
@@ -0,0 +1,181 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ --[[
3
+ *
4
+ * PHP: `Monolog\Utils`.
5
+ *
6
+ * Not ported: `getClass` (no PHP class-name reflection to normalize -- callers
7
+ * that need "what kind of value is this" use `typeOf`/`tostring` directly),
8
+ * `substr`/`canonicalizePath` (mbstring- and filesystem-specific), and
9
+ * `expandIniShorthandBytes`/`detectAndCleanUtf8` (`php.ini` shorthand and
10
+ * mbstring UTF-8 repair, neither of which apply on this platform).
11
+
12
+ ]]
13
+ --* A table produced by `markAsJsonObject` always encodes as `{}`, even empty.
14
+ local FORCE_OBJECT_KEY = "__monolog_json_object__"
15
+ --[[
16
+ *
17
+ * Marks a table so `jsonEncode` renders it as a JSON object (`{}`) rather than
18
+ * an array (`[]`) when it is empty. Luau tables can't tell an empty array from
19
+ * an empty object apart the way PHP's `\stdClass` vs `[]` can -- see
20
+ * `JsonFormatter.ts`, which is the one caller that needs this.
21
+
22
+ ]]
23
+ local function markAsJsonObject(value)
24
+ value[FORCE_OBJECT_KEY] = true
25
+ return value
26
+ end
27
+ local function isForcedObject(value)
28
+ return value[FORCE_OBJECT_KEY] == true
29
+ end
30
+ local function escapeJsonString(value)
31
+ local out = string.gsub(value, "\\", "\\\\")
32
+ out = string.gsub(out, '"', '\\"')
33
+ out = string.gsub(out, "\n", "\\n")
34
+ out = string.gsub(out, "\r", "\\r")
35
+ out = string.gsub(out, "\t", "\\t")
36
+ return out
37
+ end
38
+ local function encodeNumber(value)
39
+ if value ~= value then
40
+ return '"NaN"'
41
+ end
42
+ if value == math.huge then
43
+ return '"INF"'
44
+ end
45
+ if value == -math.huge then
46
+ return '"-INF"'
47
+ end
48
+ return tostring(value)
49
+ end
50
+ local function indent(depth, pretty)
51
+ local _result
52
+ if pretty then
53
+ local _depth = depth
54
+ _result = string.rep(" ", _depth)
55
+ else
56
+ _result = ""
57
+ end
58
+ return _result
59
+ end
60
+ local wrapList, wrapObject
61
+ local function encodeValue(value, pretty, depth)
62
+ if value == nil then
63
+ return "null"
64
+ end
65
+ local _value = value
66
+ if type(_value) == "string" then
67
+ return `"{escapeJsonString(value)}"`
68
+ end
69
+ local _value_1 = value
70
+ if type(_value_1) == "number" then
71
+ return encodeNumber(value)
72
+ end
73
+ local _value_2 = value
74
+ if type(_value_2) == "boolean" then
75
+ return if value then "true" else "false"
76
+ end
77
+ local _value_3 = value
78
+ if not (type(_value_3) == "table") then
79
+ -- No object/resource system to reflect on -- render anything else, such
80
+ -- as a function or an opaque instance, the way an unrecognized PHP value
81
+ -- would end up rendered: as a string.
82
+ return `"{escapeJsonString(tostring(value))}"`
83
+ end
84
+ local bag = value
85
+ local list = value
86
+ local forceObject = isForcedObject(bag)
87
+ if not forceObject and #list > 0 then
88
+ local items = {}
89
+ for _, item in list do
90
+ local _arg0 = encodeValue(item, pretty, depth + 1)
91
+ table.insert(items, _arg0)
92
+ end
93
+ return wrapList(items, pretty, depth)
94
+ end
95
+ local keys = {}
96
+ for key in pairs(bag) do
97
+ if key == FORCE_OBJECT_KEY then
98
+ continue
99
+ end
100
+ local _arg0 = tostring(key)
101
+ table.insert(keys, _arg0)
102
+ end
103
+ table.sort(keys)
104
+ if #keys == 0 then
105
+ -- An empty Luau table is indistinguishable from an empty array, so it
106
+ -- defaults to encoding as `[]` -- matching PHP's own `json_encode([])`,
107
+ -- which is what upstream relies on for an empty context/extra bag.
108
+ -- `markAsJsonObject` opts a specific empty table into `{}` instead
109
+ -- (see `JsonFormatter.ts`, the one caller that needs that).
110
+ return if forceObject then "{}" else "[]"
111
+ end
112
+ local pieces = {}
113
+ for _, key in keys do
114
+ local encodedValue = encodeValue(bag[key], pretty, depth + 1)
115
+ local separator = if pretty then ": " else ":"
116
+ local _arg0 = `{indent(depth + 1, pretty)}"{escapeJsonString(key)}"{separator}{encodedValue}`
117
+ table.insert(pieces, _arg0)
118
+ end
119
+ return wrapObject(pieces, pretty, depth)
120
+ end
121
+ function wrapList(items, pretty, depth)
122
+ if #items == 0 then
123
+ return "[]"
124
+ end
125
+ if not pretty then
126
+ return `[{table.concat(items, ",")}]`
127
+ end
128
+ -- ▼ ReadonlyArray.map ▼
129
+ local _newValue = table.create(#items)
130
+ local _callback = function(item)
131
+ return `{indent(depth + 1, true)}{item}`
132
+ end
133
+ for _k, _v in items do
134
+ _newValue[_k] = _callback(_v, _k - 1, items)
135
+ end
136
+ -- ▲ ReadonlyArray.map ▲
137
+ local inner = table.concat(_newValue, ",\n")
138
+ return `[\n{inner}\n{indent(depth, true)}]`
139
+ end
140
+ function wrapObject(pieces, pretty, depth)
141
+ if not pretty then
142
+ return `\{{table.concat(pieces, ",")}\}`
143
+ end
144
+ return `\{\n{table.concat(pieces, ",\n")}\n{indent(depth, true)}\}`
145
+ end
146
+ local Utils
147
+ do
148
+ Utils = setmetatable({}, {
149
+ __tostring = function()
150
+ return "Utils"
151
+ end,
152
+ })
153
+ Utils.__index = Utils
154
+ function Utils.new(...)
155
+ local self = setmetatable({}, Utils)
156
+ return self:constructor(...) or self
157
+ end
158
+ function Utils:constructor()
159
+ end
160
+ function Utils:jsonEncode(data, pretty)
161
+ if pretty == nil then
162
+ pretty = false
163
+ end
164
+ return encodeValue(data, pretty, 0)
165
+ end
166
+ function Utils:getRecordMessageForException(record)
167
+ local context = ""
168
+ local extra = ""
169
+ if (next(record.context)) ~= nil then
170
+ context = `\nContext: {Utils:jsonEncode(record.context)}`
171
+ end
172
+ if (next(record.extra)) ~= nil then
173
+ extra = `\nExtra: {Utils:jsonEncode(record.extra)}`
174
+ end
175
+ return `\nThe exception occurred while attempting to log: {record.message}{context}{extra}`
176
+ end
177
+ end
178
+ return {
179
+ markAsJsonObject = markAsJsonObject,
180
+ Utils = Utils,
181
+ }
package/out/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "$schema": "https://www.schemastore.org/package.json",
3
+ "name": "@larablox/monolog",
4
+ "version": "0.1.0",
5
+ "description": "The Larablox port of Monolog.",
6
+ "license": "MIT",
7
+ "keywords": ["monolog", "logging", "larablox", "roblox-ts"],
8
+ "homepage": "https://github.com/larablox/monolog",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/larablox/monolog.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/larablox/monolog/issues"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "files": ["out/Monolog", "out/index.d.ts"],
20
+ "types": "out/index.d.ts",
21
+ "type": "module",
22
+ "scripts": {
23
+ "build": "rbxtsc",
24
+ "test:build": "rbxtsc -p tsconfig.tests.json --rojo test.project.json",
25
+ "test:watch": "npm run test:build -- -w",
26
+ "test:serve": "rojo serve test.project.json",
27
+ "clean": "rimraf out out-tests include sourcemap.json tsconfig.tsbuildinfo",
28
+ "watch": "rbxtsc -w",
29
+ "dev": "npm run watch",
30
+ "lint": "eslint .",
31
+ "lint:fix": "eslint . --fix",
32
+ "types:roblox": "curl -sSL -o globalTypes.None.d.luau https://raw.githubusercontent.com/JohnnyMorganz/luau-lsp/main/scripts/globalTypes.None.d.luau",
33
+ "sourcemap": "rojo sourcemap default.project.json --output sourcemap.json",
34
+ "analyze": "npm run build && npm run sourcemap && luau-lsp analyze --platform=roblox --sourcemap=sourcemap.json --definitions=globalTypes.None.d.luau --base-luaurc=.luaurc --settings=luau-lsp.settings.json --ignore=\"**/include/**\" --ignore=\"**/node_modules/**\" out"
35
+ },
36
+ "devDependencies": {
37
+ "@rbxts/compiler-types": "^3.0.0-types.0",
38
+ "@rbxts/testez": "^0.4.2-ts.0",
39
+ "@rbxts/types": "^1.0.943",
40
+ "@typescript-eslint/eslint-plugin": "^8.67.0",
41
+ "@typescript-eslint/parser": "^8.67.0",
42
+ "eslint": "^10.8.1",
43
+ "eslint-config-prettier": "^10.1.8",
44
+ "eslint-plugin-prettier": "^5.5.6",
45
+ "eslint-plugin-roblox-ts": "^1.4.1",
46
+ "prettier": "^3.9.6",
47
+ "rimraf": "^6.1.3",
48
+ "roblox-ts": "^3.0.0",
49
+ "typescript": "^5.9.3"
50
+ }
51
+ }