Re: [go-nuts] Re: Parsing a time as a prefix of a larger string

2022-03-18 Thread ben...@gmail.com
Thanks for the feedback, folks. I think we'll end up using an explicit "log-trim" regex for this. -Ben On Thursday, March 17, 2022 at 3:03:08 PM UTC+13 Rob 'Commander' Pike wrote: > I would approach the problem a different way and ask the question, how > do I split the string to separate the

Re: [go-nuts] Re: Parsing a time as a prefix of a larger string

2022-03-16 Thread Rob Pike
I would approach the problem a different way and ask the question, how do I split the string to separate the time? The time parser doesn't have to be the one to do this. For instance, uou could require a marker (if the word INFO or its substitute isn't already one), such as a spaced hyphen:

[go-nuts] Re: Parsing a time as a prefix of a larger string

2022-03-16 Thread ben...@gmail.com
> How does the user control the format of the timestamp? How do you get the > time.Parse layout? > The project is a lightweight service manager, so the user "controls" the format of the timestamp based on the service they're running. For example, if they're running nginx, it will output logs

[go-nuts] Re: Parsing a time as a prefix of a larger string

2022-03-16 Thread peterGo
On Tuesday, March 15, 2022 at 11:35:06 PM UTC-4 Ben wrote: > We're making a log processing program that needs to parse times from the > prefix of a larger string, in this case in a log line such as: > > 2006-01-02 15:04:05 INFO this is a log message > > We need to parse the "2006-01-02 15:04:05"