mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-08 18:04:14 +01:00
27 lines
438 B
Go
27 lines
438 B
Go
|
package garif
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"io"
|
||
|
)
|
||
|
|
||
|
// Write writes the JSON
|
||
|
func (l *LogFile) Write(w io.Writer) error {
|
||
|
marshal, err := json.Marshal(l)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = w.Write(marshal)
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
// PrettyWrite writes indented JSON
|
||
|
func (l *LogFile) PrettyWrite(w io.Writer) error {
|
||
|
marshal, err := json.MarshalIndent(l, "", " ")
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
_, err = w.Write(marshal)
|
||
|
return err
|
||
|
}
|