Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 74 lines (56 sloc) 1.923 kB
7fd4ad4 @klacke backwards incomp cahnge with flags in gc and sc instead of many bools…
authored
1 %%%-------------------------------------------------------------------
2 %%% File : yaws_log_file_h.erl
3 %%% Author : <klacke@hyber.org>
455578a @vinoski major trailing whitespace cleanup
vinoski authored
4 %%% Description :
7fd4ad4 @klacke backwards incomp cahnge with flags in gc and sc instead of many bools…
authored
5 %%%
6 %%% Created : 11 Mar 2004 by <klacke@hyber.org>
7 %%%-------------------------------------------------------------------
8
9
10 %% Just extending the error_logger_file_h abit,
11 %% If they change the internals of that module, this module
12 %% breaks, but then again, the otp crew doesn't ever appear to
13 %% change anything that might break anything .....
14
15 -module(yaws_log_file_h).
16 -behaviour(gen_event).
317008a @garret-smith fix log rotation on Windows, where fsync() is required to get the act…
garret-smith authored
17 -include_lib("kernel/include/file.hrl").
7fd4ad4 @klacke backwards incomp cahnge with flags in gc and sc instead of many bools…
authored
18
19 -export([init/1,
6e96a14 @klacke indendation cleanup
authored
20 handle_event/2, handle_call/2, handle_info/2,
21 terminate/2, code_change/3]).
7fd4ad4 @klacke backwards incomp cahnge with flags in gc and sc instead of many bools…
authored
22
23
24
25 %% This one is used when we are started directly.
26 init(File) ->
27 init(File, []).
28
29 init(File, PrevHandler) ->
30 process_flag(trap_exit, true),
31 case file:open(File, [write, append]) of
0be3c7e @klacke untabified all of yaws
authored
32 {ok,Fd} ->
33 {ok, {Fd, File, PrevHandler}};
34 Error ->
35 Error
7fd4ad4 @klacke backwards incomp cahnge with flags in gc and sc instead of many bools…
authored
36 end.
37
bf703dc @klacke The final piece in the puzzle by Richard Bucker, yaws now play nicely…
authored
38 handle_call(reopen, {Fd, File, Prev}) ->
39 file:close(Fd),
40 {ok, Fd2} = file:open(File, [write,append]),
41 {ok, ok, {Fd2, File, Prev}};
42
7fd4ad4 @klacke backwards incomp cahnge with flags in gc and sc instead of many bools…
authored
43 handle_call(wrap, {Fd, File, Prev}) ->
44 Old = File ++ ".old",
45 file:delete(Old),
46 file:close(Fd),
47 file:rename(File, Old),
48 {ok, Fd2} = file:open(File, [write,append]),
49 {ok, ok, {Fd2, File, Prev}};
50
317008a @garret-smith fix log rotation on Windows, where fsync() is required to get the act…
garret-smith authored
51 handle_call(size, {Fd, File, Prev}) ->
52 file:sync(Fd),
53 Return = case file:read_file_info(File) of
54 {ok, FI} -> {ok, FI#file_info.size};
55 Error -> Error
56 end,
57 {ok, Return, {Fd, File, Prev}};
58
7fd4ad4 @klacke backwards incomp cahnge with flags in gc and sc instead of many bools…
authored
59 handle_call(X, S) ->
60 error_logger_file_h:handle_call(X,S).
61
62
63 handle_event(X, S) ->
64 error_logger_file_h:handle_event(X, S).
65 handle_info(X, S) ->
66 error_logger_file_h:handle_info(X, S).
67
68
69 terminate(Reason, State) ->
70 error_logger_file_h:terminate(Reason, State).
71
72 code_change(_OldVsn, State, _Extra) ->
73 {ok, State}.
Something went wrong with that request. Please try again.