<commit_before>PyLog
====


A simple logging module that mimics the behavior of Python's logging module.

All it does basically is wrap Go's logger with nice multi-level logging calls, and
allows you to set the logging level of your app in runtime.

Logging is done just like calling fmt.Sprintf:

```go
logging.Info("This object is %s and that is %s", obj, that)
```

Logging level can be set to whatever you want it to be, in runtime. Contrary to Python that specifies a minimal level, this logger is set with a bit mask of active levels.

```go
//for INFO and ERROR use:
logging.SetLevel(logging.INFO | logging.ERROR)

// For everything but debug and info use:
logging.SetLevel(logging.ALL &^ (logging.INFO | logging.DEBUG))
```

As with the standard log, you can specify any `io.Writer` type interface and send the log's output to it instead of the default stderr.

### Installation:

```
go get github.com/dvirsky/go-pylog/logging
```

### Usage Example:

```go
package main

import (
	"github.com/dvirsky/go-pylog/logging"
)

func main() {

	logging.Info("All Your Base Are Belong to %s!", "us")

	logging.Critical("And now with a stack trace")
}
```




### Example Output:
<commit_msg>added some documentationn on the new features<commit_after>PyLog
====


A simple logging module that mimics the behavior of Python's logging module.

All it does basically is wrap Go's logger with nice multi-level logging calls, and
allows you to set the logging level of your app in runtime.

Logging is done just like calling fmt.Sprintf:

```go
logging.Info("This object is %s and that is %s", obj, that)
```

Logging level can be set to whatever you want it to be, in runtime. Contrary to Python that specifies a minimal level, this logger is set with a bit mask of active levels.

```go
//for INFO and ERROR use:
logging.SetLevel(logging.INFO | logging.ERROR)

// For everything but debug and info use:
logging.SetLevel(logging.ALL &^ (logging.INFO | logging.DEBUG))
```

As with the standard log, you can specify any `io.Writer` type interface and send the log's output to it instead of the default stderr.

### Installation:

```
go get github.com/dvirsky/go-pylog/logging
```

### Usage Example:

```go
package main

import (
	"github.com/dvirsky/go-pylog/logging"
)

func main() {

	logging.Info("All Your Base Are Belong to %s!", "us")

	logging.Critical("And now with a stack trace")
}
```


### Custom Handlers

By default we just write to Go's log, and you can set the output stream of it. But you can add a custom `handler` that will receive the raw unformatted messages, format them and do whatever it wants with them. 

This was added for the use case of `Scribe`, that needs to receive messages as a pair of category and message. So an io.Writer was not applicable.

### Custom Message formatting

It is possible to change the logger's display format. The default format is 
`"%[1]s @ %[2]s:%[2]d: %[4]s"` - resulting in messages looking like:
`INFO @ db.go:528: Registering plugin REPLICATION`. 

The indexes are there so you can change the order of the formatting elements if you want. [1] means the logging level, [2] is the file, [3] is the line and [4] is the unformatted message passed to the log.

To change the way they are formatted, call `logging.SetFormatString()`.


### Example Output:

{'fraction_non_alphanumeric': 0.0967059534602599, 'fraction_numerical': 0.003324267150196434, 'mean_word_length': 4.100154083204931, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4680897', 'n_tokens_mistral': 1008, 'n_tokens_neox': 950, 'n_words': 475}