Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iosphere/elm-logger
Elm logger with support for log levels and colored console output
https://github.com/iosphere/elm-logger
elm tools
Last synced: 2 months ago
JSON representation
Elm logger with support for log levels and colored console output
- Host: GitHub
- URL: https://github.com/iosphere/elm-logger
- Owner: iosphere
- License: bsd-3-clause
- Created: 2017-01-20T22:11:54.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-13T05:09:35.000Z (almost 7 years ago)
- Last Synced: 2023-08-08T20:39:25.669Z (over 1 year ago)
- Topics: elm, tools
- Language: Elm
- Size: 48.8 KB
- Stars: 17
- Watchers: 7
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# elm-logger
This package provides a generic logger with log levels. Logs will only be
printed if the log level matches or exceeds the minimum log level in the
Configuration.The package's concept is that some other module in the implementation scope of
the app implements convenience functions wrapping a Config and Levels into
single functions. See the following template for an example:module MyUtils
import Logger
loggerConfig : Logger.Config
loggerConfig =
Logger.defaultConfig Logger.Infolog : String -> a -> a
log =
Logger.log loggerConfig Logger.DebuglogVerbose : String -> a -> a
logVerbose =
Logger.log loggerConfig Logger.VerboseThe value `loggerConfig` should be created using `Logger.defaultConfig` with the
minimum log level. By changing the minimum log level in a central module you can
silence any logs in code that fall below that level. The above template
implementation allows you to replace calls to `Debug.log` with `MyUtils.log`.Please have a look at the example app.
## Advanced: color coded console logs
You can provide a custom `ExternalLoggingFunction` via `customConfig` allowing
you to replace the default configuration that uses `Debug.log` for printing the
messages.![Screenshot of a console log using elm-logger](https://github.com/iosphere/elm-logger/raw/1.0.1/console.png)
The example implementation prints nicely colored code logs to the browser's
console.When using the native example implementation in your project, ensure to update
the name of the native function `_iosphere$elm_logger$Native_Logger`
in [Logger.js](src/example/Native/Logger.js) to match the name of your
organization and app. If you get a runtime error reading something like
`ReferenceError: Can't find variable: _org$appname$Native_Logger`
you will need to update the Logger.js to reference that name.You will also need to enable native module's for your elm project by including
the following value in your `elm-package.json`:```json
"native-modules": true,
```