Skip to content

Commit 0195720

Browse files
Update README.md (#10)
* Update README.md * Updated example in README.md * Update README.md * Update README.md * Update README.md
1 parent 1a5d59e commit 0195720

File tree

1 file changed

+32
-90
lines changed

1 file changed

+32
-90
lines changed

README.md

Lines changed: 32 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,53 @@
1-
# co-log
1+
# co-log-core
22

33
![Co-logo](https://user-images.githubusercontent.com/8126674/80955687-92f21a80-8df7-11ea-90d3-422dafdc8391.png)
44

5-
[![GitHub CI](https://github.com/kowainik/co-log/workflows/CI/badge.svg)](https://github.com/kowainik/co-log/actions)
6-
[![Build status](https://img.shields.io/travis/kowainik/co-log.svg?logo=travis)](https://travis-ci.org/kowainik/co-log)
7-
[![Windows build](https://ci.appveyor.com/api/projects/status/github/kowainik/co-log?branch=main&svg=true)](https://ci.appveyor.com/project/kowainik/co-log)
5+
[![GitHub CI](https://github.com/co-log/co-log-core/workflows/CI/badge.svg)](https://github.com/co-log/co-log-core/actions)
6+
[![Hackage][hk-img-core]][hk-core]
7+
[![Stackage LTS][lts-img-core]][lts-core]
88
[![MPL-2.0 license](https://img.shields.io/badge/license-MPL--2.0-blue.svg)](https://github.com/kowainik/co-log/blob/main/LICENSE)
99

10+
`co-log-core` is a lightweight package that provides core types and functions to
11+
work with the @LogAction@ data type which is both simple and powerful.
1012

11-
| | | | |
12-
| :------------ | :--------------------------------- | :---------------------------------------- | :---------------------------------------------------- |
13-
| `co-log-core` | [![Hackage][hk-img-core]][hk-core] | [![Stackage LTS][lts-img-core]][lts-core] | [![Stackage Nightly][nightly-img-core]][nightly-core] |
14-
| `co-log` | [![Hackage][hk-img]][hk] | [![Stackage LTS][lts-img]][lts] | [![Stackage Nightly][nightly-img]][nightly] |
15-
| `co-log-polysemy` | [![Hackage][hk-img-ps]][hk-ps] | [![Stackage LTS][lts-img-ps]][lts-ps] | [![Stackage Nightly][nightly-img-ps]][nightly-ps] |
13+
## How to use
1614

17-
`co-log` is a composable and configurable logging framework. It
18-
combines all the benefits of Haskell idioms to provide a reasonable
19-
and convenient interface. Though it uses some advanced concepts in its
20-
core, we are striving to provide beginner-friendly API. The library
21-
also contains complete documentation with a lot of beginner-friendly
22-
examples, explanations and tutorials to guide users. The combination
23-
of a pragmatic approach to logging and fundamental Haskell abstractions
24-
allows us to create a highly composable and configurable logging
25-
framework.
15+
`co-log-core` is compatible with the following GHC
16+
versions - [supported versions](https://matrix.hackage.haskell.org/#/package/co-log-core)
2617

27-
If you're interested in how different Haskell typeclasses are used to
28-
implement core functions of `co-log`, you can read the following blog
29-
post which goes into detail about internal implementation specifics:
18+
In order to start using `co-log-core` in your project, you
19+
will need to set it up with these steps:
3020

31-
* [co-log: Composable Contravariant Combinatorial Comonadic Configurable Convenient Logging](https://kowainik.github.io/posts/2018-09-25-co-log)
21+
1. Add the dependency on `co-log-core` in your project's
22+
`.cabal` file. For this, you should modify the `build-depends`
23+
section according to the below section:
3224

33-
`co-log` is also modular on the level of packages. We care a lot about a
34-
low dependency footprint so you can build your logging only on top of
35-
the minimal required interface for your use-case. This repository contains
36-
the following packages:
25+
```haskell
26+
build-depends: base ^>= LATEST_SUPPORTED_BASE
27+
, co-log-core ^>= LATEST_VERSION
28+
```
3729

38-
* [`co-log-core`](co-log-core): lightweight package with basic data types and
39-
general idea which depends only on `base`.
40-
* [`co-log`](co-log): taggless final implementation of logging library based on
41-
`co-log-core`.
42-
* [`co-log-polysemy`](co-log-polysemy): implementation of logging library based
43-
on `co-log-core` and the [`polysemy`](http://hackage.haskell.org/package/polysemy) extensible effects library.
44-
* [`co-log-benchmark`](co-log-benchmark): benchmarks of the `co-log` library.
30+
2. To use this package, refer to the below example.
4531

46-
To provide a more user-friendly introduction to the library, we've
47-
created the tutorial series which introduces the main concepts behind `co-log`
48-
smoothly:
32+
```haskell
33+
module Main (main) where
4934

50-
* [Intro: Using `LogAction`](https://github.com/kowainik/co-log/blob/main/co-log/tutorials/1-intro/Intro.md)
51-
* [Using custom monad that stores `LogAction` inside its environment](https://github.com/kowainik/co-log/blob/main/co-log/tutorials/2-custom/Custom.md)
35+
import Prelude hiding (log)
5236

53-
`co-log` also cares about concurrent logging. For this purpose we have the `concurrent-playground`
54-
executable where we experiment with different multithreading scenarios to test the library's behavior.
55-
You can find it here:
37+
import Colog.Core (LogAction, logStringStdout, (<&))
5638

57-
* [tutorials/Concurrent.hs](co-log/tutorials/Concurrent.hs)
5839

59-
## Benchmarks
40+
app :: LogAction IO String -> IO ()
41+
app log = do
42+
log <& "Starting app..."
43+
log <& "Finishing app..."
6044

61-
`co-log` is compared with basic functions like `putStrLn`. Since IO overhead is
62-
big enough, every benchmark dumps 10K messages to output. If a benchmark's name
63-
doesn't contain `Message` then this benchmark simply dumps the string `"message"`
64-
to output, otherwise it works with the `Message` data type from the `co-log`
65-
library.
66-
67-
To run benchmarks, use the following command:
68-
69-
```
70-
cabal v2-run co-log-bench
71-
```
72-
73-
| Benchmarks | Time for 10K messages |
74-
| :------------------------------------------------------ | :-------------------- |
75-
| `Prelude.putStrLn` | ` 5.117ms` |
76-
| `Text.putStrLn` | ` 9.220ms` |
77-
| `ByteString.putStrLn` | ` 2.971ms` |
78-
| `mempty` | ` 1.181ms` |
79-
| `logStringStdout` | ` 5.107ms` |
80-
| `logPrint` | ` 5.248ms` |
81-
| `logTextStdout` | ` 5.351ms` |
82-
| `logByteStringStdout` | ` 2.933ms` |
83-
| `logByteStringStderr` | ` 17.482ms` |
84-
| `ByteString > (stdout <> stderr)` | ` 17.715ms` |
85-
| `Message > format > stdout` | ` 9.188ms` |
86-
| `Message > format > ByteString > stdout` | ` 3.524ms` |
87-
| `Message{callstack} > format > stdout` | ` 9.139ms` |
88-
| `Message{callstack:5} > format > stdout` | ` 9.464ms` |
89-
| `Message{callstack:50} > format > stdout` | ` 9.439ms` |
90-
| `Message{Time,ThreadId} > format > stdout` | ` 54.160ms` |
91-
| `Message{Time,ThreadId} > format > ByteString > stdout` | ` 54.137ms` |
92-
93-
94-
[hk-img]: https://img.shields.io/hackage/v/co-log.svg?logo=haskell
95-
[hk-img-ps]: https://img.shields.io/hackage/v/co-log-polysemy.svg?logo=haskell
45+
main :: IO ()
46+
main = app logStringStdout
47+
```
48+
49+
9650
[hk-img-core]: https://img.shields.io/hackage/v/co-log-core.svg?logo=haskell
97-
[hk]: https://hackage.haskell.org/package/co-log
98-
[hk-ps]: https://hackage.haskell.org/package/co-log-polysemy
9951
[hk-core]: https://hackage.haskell.org/package/co-log-core
100-
[lts-img]: http://stackage.org/package/co-log/badge/lts
101-
[lts-img-ps]: http://stackage.org/package/co-log-polysemy/badge/lts
10252
[lts-img-core]: http://stackage.org/package/co-log-core/badge/lts
103-
[lts]: http://stackage.org/lts/package/co-log
104-
[lts-ps]: http://stackage.org/lts/package/co-log-polysemy
10553
[lts-core]: http://stackage.org/lts/package/co-log-core
106-
[nightly-img]: http://stackage.org/package/co-log/badge/nightly
107-
[nightly-img-ps]: http://stackage.org/package/co-log-polysemy/badge/nightly
108-
[nightly-img-core]: http://stackage.org/package/co-log-core/badge/nightly
109-
[nightly]: http://stackage.org/nightly/package/co-log
110-
[nightly-ps]: http://stackage.org/nightly/package/co-log-polysemy
111-
[nightly-core]: http://stackage.org/nightly/package/co-log-core

0 commit comments

Comments
 (0)