zsh-users
 help / Atom feed
* How to obtain a simple use-case: redirect filtered data into file, unfiltered to the terminal?
@ 2019-02-07 13:12 Sebastian Gniazdowski
  2019-02-07 14:27 ` Eric Cook
  2019-02-08  0:22 ` Bart Schaefer
  0 siblings, 2 replies; 3+ messages in thread
From: Sebastian Gniazdowski @ 2019-02-07 13:12 UTC (permalink / raw)
  To: Zsh Users

Hello,
I have a simple use-case that I would want to implement:
1. There is an application that outputs colorized logs.
2. I want the logs to go into a file (say `operation.log') filtered,
i.e. without colors.
3. But at the same time still go to the terminal unfiltered.
4. I want the application to have a positive response from the
iatty(1) function, i.e. that the application is thinking that the
output is to the terminal (well, it really *is*, it's just that it.
*also* goes to the file).

So writing one sentence: a terminal application outputting logs
filtered-and-redirected into a file, preserving the connection and
output to the terminal, i.e. isatty(1) answers positively for the app.

I tried with multios:

scrapy crawl 2nd_MyDom "$@" "${optarray[@]}" \
    > >(ansifilter >>! "scrapy.slog") 1> >/dev/tty

But this solution doesn't realize the 4th item – it doesn't provide
isatty(1) positive response for the app.

-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to obtain a simple use-case: redirect filtered data into file, unfiltered to the terminal?
  2019-02-07 13:12 How to obtain a simple use-case: redirect filtered data into file, unfiltered to the terminal? Sebastian Gniazdowski
@ 2019-02-07 14:27 ` Eric Cook
  2019-02-08  0:22 ` Bart Schaefer
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Cook @ 2019-02-07 14:27 UTC (permalink / raw)
  To: zsh-users

On 2/7/19 8:12 AM, Sebastian Gniazdowski wrote:
> Hello,
> I have a simple use-case that I would want to implement:
> 1. There is an application that outputs colorized logs.
> 2. I want the logs to go into a file (say `operation.log') filtered,
> i.e. without colors.
> 3. But at the same time still go to the terminal unfiltered.
> 4. I want the application to have a positive response from the
> iatty(1) function, i.e. that the application is thinking that the
> output is to the terminal (well, it really *is*, it's just that it.
> *also* goes to the file).

Implement logging in the application.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to obtain a simple use-case: redirect filtered data into file, unfiltered to the terminal?
  2019-02-07 13:12 How to obtain a simple use-case: redirect filtered data into file, unfiltered to the terminal? Sebastian Gniazdowski
  2019-02-07 14:27 ` Eric Cook
@ 2019-02-08  0:22 ` Bart Schaefer
  1 sibling, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2019-02-08  0:22 UTC (permalink / raw)
  To: Sebastian Gniazdowski; +Cc: Zsh Users

On Thu, Feb 7, 2019 at 5:12 AM Sebastian Gniazdowski
<sgniazdowski@gmail.com> wrote:
>
> So writing one sentence: a terminal application outputting logs
> filtered-and-redirected into a file, preserving the connection and
> output to the terminal

The minimal syntax of the "script" command is "script outputfile
command" ... so let's use zsh tools to create the outputfile, and
leave managing the tty stuff to "script":

script >(ansifilter >>! scrapy.slog) scrapy crawl 2nd_MyDom "$@"
"${optarray[@]}"

This will say something like
  Script started, output file is /dev/fd/12
which you can get rid of by "script -q ...".

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-07 13:12 How to obtain a simple use-case: redirect filtered data into file, unfiltered to the terminal? Sebastian Gniazdowski
2019-02-07 14:27 ` Eric Cook
2019-02-08  0:22 ` Bart Schaefer

zsh-users

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-users

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.users


AGPL code for this site: git clone https://public-inbox.org/ public-inbox